Skip to content

Commit

Permalink
Add a --volume flag to modal shell (#2067)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwaskom committed Aug 2, 2024
1 parent 525b88b commit feb0342
Showing 1 changed file with 14 additions and 1 deletion.
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

0 comments on commit feb0342

Please sign in to comment.