Skip to content

Conversation

@thomasjpfan
Copy link
Contributor

@thomasjpfan thomasjpfan commented Nov 4, 2025

Describe your changes

Every so often, when debugging an image, I find myself creating a function just so I can shell into it. With this PR, you can now run modal shell im-*.

Aside: One downside is that Image IDs do not contain your mounts (by design). From a DevX prospective, it'll be nice to also have a modal shell my_mod.py::my_image, where it builds the image and shells into it with all your mounts. It'll make it faster to iterate on an image definition.

Checklists

Compatibility checklist

Check these boxes or delete any item (or this section) if not relevant for this PR.

  • Client+Server: this change is compatible with old servers
  • Client forward compatibility: this change ensures client can accept data intended for later versions of itself

Note on protobuf: protobuf message changes in one place may have impact to
multiple entities (client, server, worker, database). See points above.


Release checklist

If you intend for this commit to trigger a full release to PyPI, please ensure that the following steps have been taken:

  • Version file (modal_version/__init__.py) has been updated with the next logical version
  • Changelog has been cleaned up and given an appropriate subhead

Changelog

  • modal shell now supports Image IDs for debugging image builds or exploring the files on your image.

@mwaskom
Copy link
Contributor

mwaskom commented Nov 4, 2025

There might be a conflict here with some broader refactoring that @ehdr is doing, let's check in with him to avoid any issues before merging.

One downside is that Image IDs do not contain your mounts (by design).

I think this design is subject to change by the way.

@ehdr
Copy link
Contributor

ehdr commented Nov 4, 2025

Thanks for flagging, but no need to block on that! It's not urgent and not sure when(/if) I'll finish it, so go ahead!

Comment on lines +641 to +653
volumes = {} if volume is None else {f"/mnt/{vol}": Volume.from_name(vol) for vol in volume}
secrets = [] if secret is None else [Secret.from_name(s) for s in secret]
start_shell = partial(
interactive_shell,
image=modal_image,
cpu=cpu,
memory=memory,
gpu=gpu,
cloud=cloud,
volumes=volumes,
secrets=secrets,
region=region.split(",") if region else [],
pty=pty,
Copy link
Contributor

@mwaskom mwaskom Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing that bothers me about this (and where we got stuck in @ehdr's previous effort, motivating his attempt at a refactor) is that it makes it harder to explain the modal shell parameterization. Currently we have a (relatively) understandable heuristic that you pass REF or you pass a specification in the flags. This adds complexity because you need to say "If not passing REF, or if REF is an image ID".

OTOH it's not actively in conflict like it is with a task / sandbox ID (Function reference is more ambiguous since you could define "override" semantics for the additional flags, we just don't currently do that) and I can see how it might be useful to drop into a specific Image with a GPU etc...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I'd be 👍 if we can plan to implement "override" semantics in the function reference case, so that the additional flags work where they "could" and it's not too hard to explain why you can't, e.g., start a shell into an existing container and add a GPU.

Comment on lines 525 to 531
ref: Optional[str] = typer.Argument(
default=None,
help=(
"ID of running container or Sandbox, or path to a Python file containing an App."
" Can also include a Function specifier, like `module.py::func`, if the file defines multiple Functions."
),
),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need some doc improvements too right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants