Skip to content
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

Add a --volume flag to modal shell #2067

Merged
merged 1 commit into from
Aug 2, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion modal/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from ..image import Image
from ..runner import deploy_app, interactive_shell, run_app
from ..serving import serve_app
from ..volume import Volume
from .import_refs import import_app, import_function
from .utils import ENV_OPTION, ENV_OPTION_HELP, stream_app_logs

Expand Down Expand Up @@ -332,7 +333,10 @@ def serve(
def shell(
func_ref: Optional[str] = typer.Argument(
default=None,
help="Path to a Python file with an App or Modal function whose container to run.",
help=(
"Path to a Python file with an App or Modal function with container parameters."
" Can also include a function specifier, like `module.py::func`, when the file defines multiple functions."
),
metavar="FUNC_REF",
),
cmd: str = typer.Option(default="/bin/bash", help="Command to run inside the Modal image."),
Expand All @@ -341,6 +345,13 @@ def shell(
default=None, help="Container image tag for inside the shell (if not using FUNC_REF)."
),
add_python: Optional[str] = typer.Option(default=None, help="Add Python to the image (if not using FUNC_REF)."),
volume: Optional[typing.List[str]] = typer.Option(
default=None,
help=(
"Name of a `modal.Volume` to mount inside the shell at `/mnt/{name}` (if not using FUNC_REF)."
" Can be used multiple times."
),
),
cpu: Optional[int] = typer.Option(
default=None, help="Number of CPUs to allocate to the shell (if not using FUNC_REF)."
),
Expand Down Expand Up @@ -419,13 +430,15 @@ def shell(
)
else:
modal_image = Image.from_registry(image, add_python=add_python) if image else None
volumes = {} if volume is None else {f"/mnt/{vol}": Volume.from_name(vol) for vol in volume}
start_shell = partial(
interactive_shell,
image=modal_image,
cpu=cpu,
memory=memory,
gpu=gpu,
cloud=cloud,
volumes=volumes,
region=region.split(",") if region else [],
)

Expand Down
Loading