nandi/frqpublic Fork 0
4dfc71908cc3f12174bb0d6dd8688ff3164879c3
Commits
Clone
git clone https://git.rickub.com/nandi/frq.git
git clone ssh://git@rickub.com/nandi/frq.git

Host key fingerprint (ed25519): SHA256:iycHnxEyq0Q7uyVpB7JlznP0G7JrTPXLYRcAU5CSLhc — verify it before your first connect.

container.py · 45 lines · 1.7 KBPython Blame HistoryRaw
A third target, and the seam that was already waiting for it f54ca45 nandi 2d ago1"""Generated stub -- the container is defined by container.toml.
2
3Edit container.toml, not this file.
4"""
5
6import os
7import sys
8
9sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
10
11from _loader import Container # noqa: E402
12
13c = Container.from_toml(__file__)
14image, app = c.image, c.app
15
16
17# No @app.function here: a Sandbox runs its command as its own process and
18# nothing of this module is imported into it. Registering a Function would be
19# dead weight, and its kwargs are where vm_runtime would be wrongly applied.
20# One entrypoint, not two: a second `@app.local_entrypoint` makes plain
21# `modal run container.py` ambiguous, and Modal refuses it rather than
22# picking. `--shell` is a flag on the one there is.
23@app.local_entrypoint()
24def main(command: str = "", shell: bool = False):
25 if not shell:
26 c.run_sandbox(command)
27 return
28
Six verbs, and the last of the nix 2e24e64 nandi 17h ago29 # `modal shell --image` takes a registry reference and nothing else, so
30 # it cannot be pointed at the image this container actually runs -- the
31 # one with its setup steps and its source copy in it. Attaching to a
32 # running Sandbox can, and that Sandbox is this container: same image,
33 # same volumes, same env.
A third target, and the seam that was already waiting for it f54ca45 nandi 2d ago34 sb = c.open_sandbox()
35 print(f"sandbox {sb.object_id} up, with {', '.join(c.volumes) or 'no volumes'}")
36 print(f" attach: modal shell {sb.object_id} (from another terminal)")
37 print("Ctrl-C here takes it down.")
38 # Blocks on `sleep infinity`, which is the point: an ephemeral app stops
39 # when its local entrypoint returns, and stopping the app terminates the
40 # Sandbox with it -- so returning here would leave nothing to attach to.
41 try:
42 sb.wait()
43 except KeyboardInterrupt:
44 print("terminating")
45 sb.terminate()