-
Notifications
You must be signed in to change notification settings - Fork 41
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
[WIP] CLI-227: add implicit context_mount
to Image
docker methods
#2582
Conversation
dcacc4a
to
10f0df6
Compare
bffa50d
to
a650752
Compare
…rom/cli-227-remove-context_mount-from
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.
Haven't looked at the details too much, but looks good on the surface!
I just realized we might also want to (separately) add more fine grained control mechanisms/filter support to give people a way to exclude particular files they don't want to include (dockerignore style) before we can forcibly push people to use this.
As a start, maybe we could just start exposing condition
in a more user-friendly way. Will discuss separately in slack
…rom/cli-227-remove-context_mount-from
…rom/cli-227-remove-context_mount-from
Image
docker methods
Image
docker methodscontext_mount
to Image
docker methods
…rom/cli-227-remove-context_mount-from
…rom/cli-227-remove-context_mount-from
@@ -1162,6 +1181,24 @@ def dockerfile_commands( | |||
if not cmds: | |||
return self | |||
|
|||
if context_mount is not None: |
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.
Might want to add the ignore
argument here as well if people want manual inline ignore patterns without external files, as a replacement for context_mount. And the pending deprecation could point people towards that argument
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.
(or dockerignore obviously)
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.
Wait, does dockerfile_commands support dockerignore with this? We only call find_dockerignore_file in from_dockerfile right? 🤔
No biggie if it doesn't - as long as we support ignore
for now
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.
added to dockerfile_commands
as well -- currently both methods will try to find a dockerignore file unless a custom ignore argument is passed
…rom/cli-227-remove-context_mount-from
…rom/cli-227-remove-context_mount-from
modal/_utils/docker_utils.py
Outdated
return True | ||
|
||
|
||
AUTO_DOCKERIGNORE = _AutoDockerIgnore().with_repr(f"{__name__}.AUTO_DOCKERIGNORE") |
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.
what's all this repr magic used for?
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.
Moved the repr inside the class, but it's just a placeholder value for type hints & docs to make it simpler to understand what will happen if you don't pass in a custom ignore pattern-list or callable --> then we default to trying to find a matching dockerignore to your dockerfile (or just a generic one if you're using docker_commands
) -- same as we have for add_local_python_source
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.
TLDR for why it's needed (this was my suggestion)
It's so that we can use these as default values in signatures and still emit valid python signatures in our type stubs, since things like inspect.signature(...)
will just use the repr of all default values, and can't figure out stuff like import path of the specific constant we use as a default.
It's definitely a bit of a hack, but not something users should see. An alternative would be to do a bunch of ast
magic to extract the signatures.
Adds deprecation warning when using
context_mount
parameter onImage
docker methods as part of the effort to remove mounts. This parameter which used to be necessary forCOPY
commands to work.This PR instead creates an implicit context mount from the dockerfile/docker commands by parsing the
COPY
source patterns and use them as mount filters for the current directory.Also adds support for finding a dockerignore file that matches the given dockerfile or if there's a generic one if using docker commands