-
Notifications
You must be signed in to change notification settings - Fork 27
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
Use mount basename handling in copy_local_* #584
base: main
Are you sure you want to change the base?
Conversation
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.
Auto-approved 👍. This diff qualified for automatic approval and doesn't need follow up review.
Looks good assuming this works against the integration test I just added (but didn't merge) to our internal repo |
It does not pass the last assertion in that test, since this changes how the default remote_path argument works for local_files_stub = Stub(
image=(
make_image()
.copy_local_dir(supports_path, "/xyz")
.copy_local_file(supports_path / "local_file.txt", "/pqr/banana.txt")
.copy_local_file(supports_path / "local_file.txt") # Copy into /root
.copy_local_dir(supports_path / "dir") # Copy into /root too
)
)
def test_copy_local_file(client):
with local_files_stub.run(client):
assert read_file.call("/xyz/local_file.txt") == "Hello, world!\n"
assert read_file.call("/pqr/banana.txt") == "Hello, world!\n"
assert read_file.call("/local_file.txt") == "Hello, world!\n"
# the following breaks, since the file ends up in "/dir/another_file.txt"
assert read_file.call("/another_file.txt") == "Hello, another world!\n" The inconsistency with |
I'm fine breaking stuff if it makes it more consistent. It's not very obvious what should happen with some of those cases. Minor preference for trying to keep it consistent with Docker though |
The COPY command in docker doesn't have a default destination, and this change shouldn't affect explicit destinations, so it should still be docker-consistent. The intention is that it should reuse a bit more of the existing Another unfortunate side effect is that it will cause image rebuilds in places where people use If we still want this, lets schedule it for a version bump. Perhaps we should release another patch first where we add a warning to people using |
Just realized there is a bug here if users change workdir during their image building. Adding some additional integration tests to prevent regressions going forward |
A alternative/further mini fix on top of #583
Relies on the logic of the Mount methods to put files/directories into the right basename dir depending on the argument to remote_path (by defaulting to None, like the mount methods).
This makes the default argument (no argument) to
copy_local_dir
work like the equivalentadd_local_dir
of Mount, i.e. copies to a directory with the same name as the source, e.g.:modal.Image.debian_slim().copy_local_dir("config").run_commands("ls -l config")
Instead of copying all the contents of the dir into the current working directory (this can still be performed by using "." as the remote_path explicitly)