Skip to content

Conversation

stephanos
Copy link
Contributor

@stephanos stephanos commented Oct 4, 2025

What was changed

Make Python image work offline.

Why?

More predictable behavior; and works in offline environments.

Checklist

  1. Closes

  2. How was this tested:

  1. Any docs updates needed?

@stephanos stephanos marked this pull request as ready for review October 4, 2025 16:59
@stephanos stephanos requested a review from Sushisource October 4, 2025 16:59
Comment on lines 49 to 52
# Download the worker dependencies for offline use
WORKDIR /app/prepared
RUN uv lock && uv sync --frozen
ENV UV_NO_SYNC=1 UV_FROZEN=1 UV_OFFLINE=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like something the prepare call should be able to do for anyone, not just docker correct? I admit I haven't looked, but when it comes to downloading dependencies locally for other languages, is that done in prepare or in docker files? I wonder if a --local-dependencies option makes sense.

Copy link
Contributor Author

@stephanos stephanos Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can move it up the stack into prepare.

TypeScript for example runs npm ci, Go runs go mod tidy, Java runs gradlew build. Python is the only one that doesn't result in offline use (despite running uv sync). So I feel like that should come out of the box without a flag.

Comment on lines 49 to 52
# Download the worker dependencies for offline use
WORKDIR /app/prepared
RUN uv lock && uv sync --frozen
ENV UV_NO_SYNC=1 UV_FROZEN=1 UV_OFFLINE=1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you confirm which of the languages you know of download dependencies locally? Don't have to check them all, just curious if any of them do to confirm this is what is expected of these docker files. For instance, does the go.Dockerfile download locally in prepare? I haven't looked, but usually I would expect those dependencies to be cached in a general system location that I don't see being brought over in a COPY.

Copy link
Contributor Author

@stephanos stephanos Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can confirm that the Python Dockerfile is the only one that doesn't work offline out of the box; I've used all others successfully in an offline-only environment.

@stephanos stephanos changed the title Offline Python worker Offline Python Oct 7, 2025
@stephanos
Copy link
Contributor Author

stephanos commented Oct 7, 2025

Tested via

docker build -f dockerfiles/py.Dockerfile -t features-py-test --build-arg SDK_VERSION="temporalio>=1.13.0,<2" --build-arg REPO_DIR_OR_PLACEHOLDER=.gitignore .

docker run --entrypoint=/bin/sh features-py-test -c "/app/temporal-features run --lang py --prepared-dir prepared"

Comment on lines 115 to 119
if err := executeCommand("uv", "sync"); err != nil {
return nil, fmt.Errorf("failed installing: %w", err)
// Lock dependencies and sync for offline use
if err := executeCommand("uv", "lock"); err != nil {
return nil, fmt.Errorf("failed locking dependencies: %w", err)
}
if err := executeCommand("uv", "sync", "--frozen"); err != nil {
return nil, fmt.Errorf("failed syncing with frozen lockfile: %w", err)
Copy link
Member

@cretz cretz Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just out of curiosity, what happens if you don't change this code but keep the env vars?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was a bit trigger happy with my comment ha! I'm currently trying to assess which exact part makes it work.

Comment on lines 192 to 193
// Set environment variables for offline operation
cmd.Env = append(os.Environ(), "UV_NO_SYNC=1", "UV_FROZEN=1", "UV_OFFLINE=1")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is the thing I think should remain in the Docker file. These are environment specific things and we should not assume every caller of omes wants these.

@stephanos
Copy link
Contributor Author

Alright; I tried to get it tested on CI but that seemed to be difficult (it downloads the CLI so you cannot just disable the network). From my local testing (see commands above), it seems only setting the ENV vars in the Dockerfile is sufficient.

@stephanos stephanos requested a review from cretz October 7, 2025 17:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants