nandi/frqpublic Fork 0
d333b6f7b4be024f494b613751b18edbeed856bc
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 · 44 lines · 1.7 KBPython Blame HistoryRaw
The window opens, and a devShell that remembers what it built c20643a nandi 5d 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.
A shell that is already the devShell, and two recipes to reach it e853593 nandi 5d ago20# 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.
The window opens, and a devShell that remembers what it built c20643a nandi 5d ago23@app.local_entrypoint()
A shell that is already the devShell, and two recipes to reach it e853593 nandi 5d ago24def main(command: str = "", shell: bool = False):
25 if not shell:
26 c.run_sandbox(command)
27 return
28
29 # `modal shell --image` only takes registry references, so it cannot be
30 # pointed at a published Modal image like arch-nix. Attaching to a running
31 # Sandbox can, and that Sandbox is this container: same image, same
32 # volumes, same env.
The window opens, and a devShell that remembers what it built c20643a nandi 5d ago33 sb = c.open_sandbox()
34 print(f"sandbox {sb.object_id} up, with {', '.join(c.volumes) or 'no volumes'}")
35 print(f" attach: modal shell {sb.object_id} (from another terminal)")
36 print("Ctrl-C here takes it down.")
37 # Blocks on `sleep infinity`, which is the point: an ephemeral app stops
38 # when its local entrypoint returns, and stopping the app terminates the
39 # Sandbox with it -- so returning here would leave nothing to attach to.
40 try:
41 sb.wait()
42 except KeyboardInterrupt:
43 print("terminating")
44 sb.terminate()