-
Notifications
You must be signed in to change notification settings - Fork 19
Offline Python #679
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Offline Python #679
Conversation
dockerfiles/py.Dockerfile
Outdated
# 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 |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
dockerfiles/py.Dockerfile
Outdated
# 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 |
There was a problem hiding this comment.
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
.
There was a problem hiding this comment.
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.
c0cafc3
to
4123645
Compare
Tested via
|
sdkbuild/python.go
Outdated
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) |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
sdkbuild/python.go
Outdated
// Set environment variables for offline operation | ||
cmd.Env = append(os.Environ(), "UV_NO_SYNC=1", "UV_FROZEN=1", "UV_OFFLINE=1") |
There was a problem hiding this comment.
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.
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. |
What was changed
Make Python image work offline.
Why?
More predictable behavior; and works in offline environments.
Checklist
Closes
How was this tested: