lightcone-cli 0.5.0rc4__tar.gz → 0.5.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/.gitignore +4 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/PKG-INFO +16 -7
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/README.md +8 -6
- lightcone_cli-0.5.1/hatch_build.py +23 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/pyproject.toml +19 -7
- lightcone_cli-0.5.1/src/lightcone/app/__init__.py +120 -0
- lightcone_cli-0.5.1/src/lightcone/app/__main__.py +3 -0
- lightcone_cli-0.5.1/src/lightcone/app/files.py +194 -0
- lightcone_cli-0.5.1/src/lightcone/app/routes.py +128 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/03e9641d6f9e9223.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/0462f03bdf9d9e26.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/0750571032beef1a.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/07ef19e7b06429d4.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/10d95fd3a2a3c8c5.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/1608a09b4aff30c2.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/3b1e59b3ba055bda.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/47373d1e512354bb.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/4aafdb685c2bf1c9.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/5295ba483ad9f51a.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/55fac25845c12663.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/572d331f69425f62.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/577270225ea69a74.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/5916a24fa3ab2b17.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/6258592bdc9387b6.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/6f2bb1dff24614a5.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/70d8b0a530ab8484.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/740484788f643b19.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/7a996c9da2ec18e6.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/7c1871215eef4da8.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/7c9bc82b17fa2586.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/7f51fe034014000e.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/8916142bec8821e7.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/8c5b5494b63adb73.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/9024d815ba48fa55.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/939bc64440a13865.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/94e1e8dc5ff5d517.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/9acaf01c6476f53a.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/9f256b8593ce632e.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/a144ef5840bbd063.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/a79f1c3119cd700d.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/a8709e36220dee77.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/a879cf8383e22737.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/b18f59e1d1359581.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/b4230e7e83f57db8.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/b4c20c84d8259773.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/b67709187bb0654a.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/b74a1a8b2c5d73c2.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/b7f8fe9b5f78a977.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/ba21ed5f8468b2b7.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/bf59d231c34de257.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/bundle.js +7446 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/c3fb5ac22fd413f2.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/cce5b8ecea35407a.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/cfe392c431bfee31.js +2 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/d181c4650dd0c0fe.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/d3c882a649b3f4fa.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/d42a5579b0283025.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/d4d7ba480428fe6e.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/d6b476ecd3949434.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/d97aaf4a1ebf38b0.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/dad44a7fc678e2ca.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/e1e279cbdd2feecd.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/e3f82f9d2724733a.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/eae34984b3dc1874.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/eb2a35646018d68d.js +8 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/ec17d132645b2c86.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/ed38e79f5799ceca.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/f1035d8d5d945108.woff +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/f28c23acad0b6d75.woff2 +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/fabc004aab10cb40.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/favicon.svg +1 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/fbccdabe0ae624b8.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/static/fe9cbbe1a0f37727.ttf +0 -0
- lightcone_cli-0.5.1/src/lightcone/app/templates/index.html +30 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/cli/commands.py +119 -6
- lightcone_cli-0.5.1/src/lightcone/cli/compute.py +286 -0
- lightcone_cli-0.5.1/src/lightcone/engine/__init__.py +3 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/assets.py +12 -6
- lightcone_cli-0.5.1/src/lightcone/engine/compute/__init__.py +302 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/catalog.py +165 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/local.py +584 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/local_runtime.py +128 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/model.py +517 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/output.py +68 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/runtime.py +220 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/slurm.py +676 -0
- lightcone_cli-0.5.1/src/lightcone/engine/compute/slurm_bootstrap.py +189 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/container.py +24 -14
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/crate.py +8 -9
- lightcone_cli-0.5.1/src/lightcone/engine/execution_resources.py +171 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/image.py +2 -2
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/materialize.py +208 -179
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/plan.py +6 -1
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/project.py +5 -8
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/run.py +57 -40
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/boundary.py +56 -17
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/oci.py +25 -1
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/policy.py +35 -3
- lightcone_cli-0.5.1/src/lightcone/engine/serve.py +164 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/pyproject.toml.tmpl +1 -1
- lightcone_cli-0.5.1/src/lightcone/engine/units.py +25 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/worker.py +27 -18
- lightcone_cli-0.5.0rc4/src/lightcone/engine/__init__.py +0 -9
- lightcone_cli-0.5.0rc4/src/lightcone/engine/venue.py +0 -326
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/LICENSE +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/_sandbox_exec.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/cli/__init__.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/dataset.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/identity.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/__init__.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/denial.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/landlock.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/model.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/profiles/base.sbpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/profiles/network.sbpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/profiles/platform-defaults.sbpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/sandbox/seatbelt.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/__init__.py +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/data-README.md.tmpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/datalad-config.tmpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/gitattributes.tmpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/gitignore.tmpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/index.md.tmpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/myst.yml.tmpl +0 -0
- {lightcone_cli-0.5.0rc4 → lightcone_cli-0.5.1}/src/lightcone/engine/templates/files/results-README.md.tmpl +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: lightcone-cli
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.1
|
|
4
4
|
Summary: Lightcone Research's agentic execution layer
|
|
5
5
|
Project-URL: Repository, https://github.com/LightconeResearch/lightcone-cli
|
|
6
6
|
Author: Lightcone Research
|
|
@@ -21,8 +21,15 @@ Classifier: Topic :: Scientific/Engineering
|
|
|
21
21
|
Requires-Python: >=3.11
|
|
22
22
|
Requires-Dist: astra-tools==0.2.18
|
|
23
23
|
Requires-Dist: click>=8.0
|
|
24
|
+
Requires-Dist: cryptography>=44
|
|
24
25
|
Requires-Dist: distributed>=2026.7
|
|
25
26
|
Requires-Dist: git-annex>=10.2026
|
|
27
|
+
Requires-Dist: jupyter-live-content<0.2,>=0.1.2
|
|
28
|
+
Requires-Dist: jupyter-server>=2.21
|
|
29
|
+
Requires-Dist: jupyterlab-server>=2.28
|
|
30
|
+
Requires-Dist: psutil>=6
|
|
31
|
+
Requires-Dist: pydantic<3,>=2.9
|
|
32
|
+
Requires-Dist: pyyaml>=6
|
|
26
33
|
Requires-Dist: rich>=13.0
|
|
27
34
|
Requires-Dist: rocrate>=0.15
|
|
28
35
|
Description-Content-Type: text/markdown
|
|
@@ -49,7 +56,9 @@ Then to install **lightcone-cli**:
|
|
|
49
56
|
uv tool install lightcone-cli
|
|
50
57
|
```
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
Create an ASTRA project and launch the built-in local compute offer; no compute
|
|
60
|
+
configuration is needed. [Configure resource offers](https://docs.lightconeresearch.org) for
|
|
61
|
+
larger local allocations or Slurm:
|
|
53
62
|
|
|
54
63
|
```bash
|
|
55
64
|
lc init my-analysis
|
|
@@ -59,21 +68,21 @@ cd my-analysis
|
|
|
59
68
|
uv add numpy
|
|
60
69
|
# When you are done with your edits, commit:
|
|
61
70
|
git add -A && git commit -m "First analysis"
|
|
62
|
-
|
|
63
|
-
|
|
71
|
+
CLUSTER=$(lc compute launch --wait)
|
|
72
|
+
# Generate outputs with full provenance tracking
|
|
73
|
+
lc materialize "$CLUSTER"
|
|
74
|
+
lc compute down "$CLUSTER"
|
|
64
75
|
```
|
|
65
76
|
|
|
66
77
|
ASTRA specs are plain, structured YAML — they work well hand-written or
|
|
67
78
|
drafted with any AI coding assistant.
|
|
68
79
|
|
|
69
|
-
→ [Full getting-started guide](https://docs.lightconeresearch.org/user/getting-started/)
|
|
70
|
-
|
|
71
80
|
## Capabilities
|
|
72
81
|
|
|
73
82
|
- **Multiverse analysis** — declare methodological decisions with multiple defensible options; `lc` materializes your analysis across every universe you define
|
|
74
83
|
- **Provenance by construction** — every output is committed to git together with a content-addressed manifest and a re-runnable run record; git-annex carries the bytes, so results travel with the repository
|
|
75
84
|
- **Locked, isolated execution** — a project's environment is `pyproject.toml` + `uv.lock`; recipes run in it under a sandbox (Landlock on Linux, Seatbelt on macOS) that keeps undeclared files out and stray writes contained
|
|
76
|
-
- **Containers and HPC** — declare `[tool.lightcone.image]` and recipes run in a content-addressed image archived in the repository itself;
|
|
85
|
+
- **Containers and HPC** — declare `[tool.lightcone.image]` and recipes run in a content-addressed image archived in the repository itself; allocate local or Slurm Dask clusters explicitly with `lc compute`, then pass the cluster name or full ID to `run` or `materialize`
|
|
77
86
|
- **Publication view** — declare a license and `lc materialize` maintains an [RO-Crate](https://www.researchobject.org/ro-crate/) of the project and its provenance, ready to archive or deposit
|
|
78
87
|
|
|
79
88
|
→ [Full documentation](https://docs.lightconeresearch.org)
|
|
@@ -20,7 +20,9 @@ Then to install **lightcone-cli**:
|
|
|
20
20
|
uv tool install lightcone-cli
|
|
21
21
|
```
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Create an ASTRA project and launch the built-in local compute offer; no compute
|
|
24
|
+
configuration is needed. [Configure resource offers](https://docs.lightconeresearch.org) for
|
|
25
|
+
larger local allocations or Slurm:
|
|
24
26
|
|
|
25
27
|
```bash
|
|
26
28
|
lc init my-analysis
|
|
@@ -30,21 +32,21 @@ cd my-analysis
|
|
|
30
32
|
uv add numpy
|
|
31
33
|
# When you are done with your edits, commit:
|
|
32
34
|
git add -A && git commit -m "First analysis"
|
|
33
|
-
|
|
34
|
-
|
|
35
|
+
CLUSTER=$(lc compute launch --wait)
|
|
36
|
+
# Generate outputs with full provenance tracking
|
|
37
|
+
lc materialize "$CLUSTER"
|
|
38
|
+
lc compute down "$CLUSTER"
|
|
35
39
|
```
|
|
36
40
|
|
|
37
41
|
ASTRA specs are plain, structured YAML — they work well hand-written or
|
|
38
42
|
drafted with any AI coding assistant.
|
|
39
43
|
|
|
40
|
-
→ [Full getting-started guide](https://docs.lightconeresearch.org/user/getting-started/)
|
|
41
|
-
|
|
42
44
|
## Capabilities
|
|
43
45
|
|
|
44
46
|
- **Multiverse analysis** — declare methodological decisions with multiple defensible options; `lc` materializes your analysis across every universe you define
|
|
45
47
|
- **Provenance by construction** — every output is committed to git together with a content-addressed manifest and a re-runnable run record; git-annex carries the bytes, so results travel with the repository
|
|
46
48
|
- **Locked, isolated execution** — a project's environment is `pyproject.toml` + `uv.lock`; recipes run in it under a sandbox (Landlock on Linux, Seatbelt on macOS) that keeps undeclared files out and stray writes contained
|
|
47
|
-
- **Containers and HPC** — declare `[tool.lightcone.image]` and recipes run in a content-addressed image archived in the repository itself;
|
|
49
|
+
- **Containers and HPC** — declare `[tool.lightcone.image]` and recipes run in a content-addressed image archived in the repository itself; allocate local or Slurm Dask clusters explicitly with `lc compute`, then pass the cluster name or full ID to `run` or `materialize`
|
|
48
50
|
- **Publication view** — declare a license and `lc materialize` maintains an [RO-Crate](https://www.researchobject.org/ro-crate/) of the project and its provenance, ready to archive or deposit
|
|
49
51
|
|
|
50
52
|
→ [Full documentation](https://docs.lightconeresearch.org)
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"""Build checkout assets; consume bundled assets when installing the sdist."""
|
|
2
|
+
|
|
3
|
+
import subprocess
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class FrontendBuildHook(BuildHookInterface[Any]):
|
|
11
|
+
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
|
|
12
|
+
if version == "editable":
|
|
13
|
+
return
|
|
14
|
+
root = Path(self.root)
|
|
15
|
+
ui = root / "ui"
|
|
16
|
+
if ui.is_dir():
|
|
17
|
+
# An unconditional build includes styles, assets, dependency locks,
|
|
18
|
+
# and compiler/bundler configuration, even after a git checkout.
|
|
19
|
+
subprocess.run(["npm", "ci"], cwd=ui, check=True)
|
|
20
|
+
subprocess.run(["npm", "run", "build"], cwd=ui, check=True)
|
|
21
|
+
for name in ("bundle.js", "favicon.svg"):
|
|
22
|
+
if not (root / "src/lightcone/app/static" / name).is_file():
|
|
23
|
+
raise RuntimeError(f"Missing frontend asset: {name}")
|
|
@@ -30,22 +30,27 @@ dependencies = [
|
|
|
30
30
|
"git-annex>=10.2026",
|
|
31
31
|
"distributed>=2026.7",
|
|
32
32
|
"rocrate>=0.15",
|
|
33
|
+
"cryptography>=44",
|
|
34
|
+
"psutil>=6",
|
|
35
|
+
"pydantic>=2.9,<3",
|
|
36
|
+
"pyyaml>=6",
|
|
37
|
+
"jupyter-server>=2.21",
|
|
38
|
+
"jupyterlab-server>=2.28",
|
|
39
|
+
"jupyter-live-content>=0.1.2,<0.2",
|
|
33
40
|
]
|
|
34
41
|
|
|
35
42
|
[dependency-groups]
|
|
36
43
|
dev = [
|
|
37
44
|
"pytest>=8.0",
|
|
38
45
|
"pytest-cov",
|
|
46
|
+
"hatchling",
|
|
47
|
+
"playwright>=1.58",
|
|
39
48
|
"ruff",
|
|
40
49
|
"mypy",
|
|
41
50
|
"datalad",
|
|
42
51
|
"roc-validator>=0.11.4",
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"zensical>=0.0.33",
|
|
46
|
-
# squidfunk's mike fork — required by zensical's versioning provider.
|
|
47
|
-
# Not on PyPI; install from git.
|
|
48
|
-
"mike @ git+https://github.com/squidfunk/mike.git ; python_version >= '3.10'",
|
|
52
|
+
"types-pyyaml>=6.0.12.20260906",
|
|
53
|
+
"types-psutil>=7.2.2.20260906",
|
|
49
54
|
]
|
|
50
55
|
|
|
51
56
|
|
|
@@ -74,9 +79,16 @@ source = "vcs"
|
|
|
74
79
|
|
|
75
80
|
[tool.hatch.build.targets.wheel]
|
|
76
81
|
packages = ["src/lightcone"]
|
|
82
|
+
# The app's front end, built from ui/ and gitignored.
|
|
83
|
+
artifacts = ["src/lightcone/app/static"]
|
|
77
84
|
|
|
78
85
|
[tool.hatch.build.targets.sdist]
|
|
79
|
-
include = ["src/lightcone"]
|
|
86
|
+
include = ["src/lightcone", "hatch_build.py"]
|
|
87
|
+
artifacts = ["src/lightcone/app/static"]
|
|
88
|
+
|
|
89
|
+
# Checkout distributions rebuild all frontend inputs. Prebuilt sdists need
|
|
90
|
+
# no Node, and editable installs leave the optional frontend build explicit.
|
|
91
|
+
[tool.hatch.build.hooks.custom]
|
|
80
92
|
|
|
81
93
|
[tool.ruff]
|
|
82
94
|
target-version = "py311"
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"""The Lightcone app: one page over one project's ``astra.yaml``.
|
|
2
|
+
|
|
3
|
+
Inspired from JupyterLab's ``examples/app`` (BSD-3-Clause, Copyright (c)
|
|
4
|
+
Jupyter Development Team): a ``LabServerApp`` serving one page, with its
|
|
5
|
+
token, its page config and Jupyter's Contents API. The page reads the
|
|
6
|
+
project through that API and resolves the spec itself; the app's own routes
|
|
7
|
+
(see ``routes``) answer what that API cannot: an output's recorded run, read
|
|
8
|
+
by lc's manifest reader; every output's state, from the engine's own
|
|
9
|
+
classification; and the cited papers in astra's cache, outside the project.
|
|
10
|
+
It serves no settings or themes: the page has no JupyterLab interface to
|
|
11
|
+
configure. The one other extension it loads is
|
|
12
|
+
jupyter-live-content, whose WebSocket tells the page when a file it read
|
|
13
|
+
changed on disk.
|
|
14
|
+
|
|
15
|
+
The token reads and nothing more. The page only reads, so the server keeps
|
|
16
|
+
two of Jupyter's services, the Contents API and ``/files/``, and Jupyter's
|
|
17
|
+
authorizer refuses every write; there are no kernels, sessions or terminals
|
|
18
|
+
for the token to run code with, and no config to write. Three writes Jupyter
|
|
19
|
+
makes outside its authorizer are switched off as well: the login form's
|
|
20
|
+
password change, the notebook trust store, and corrupt-notebook recovery.
|
|
21
|
+
|
|
22
|
+
Run as ``python -m lightcone.app``; ``lc view`` is what starts it.
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
from __future__ import annotations
|
|
26
|
+
|
|
27
|
+
import hashlib
|
|
28
|
+
import os
|
|
29
|
+
import secrets
|
|
30
|
+
from pathlib import Path
|
|
31
|
+
from typing import Any
|
|
32
|
+
|
|
33
|
+
from jupyter_server.auth.authorizer import Authorizer
|
|
34
|
+
from jupyter_server.auth.identity import PasswordIdentityProvider, User
|
|
35
|
+
from jupyter_server.base.handlers import JupyterHandler
|
|
36
|
+
from jupyter_server.serverapp import ServerApp
|
|
37
|
+
from jupyterlab_server import LabServerApp
|
|
38
|
+
from traitlets import Bool, default
|
|
39
|
+
|
|
40
|
+
from lightcone.app import routes
|
|
41
|
+
from lightcone.app.files import ProjectContents
|
|
42
|
+
from lightcone.engine.serve import BUNDLE
|
|
43
|
+
|
|
44
|
+
_HERE = Path(__file__).parent
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _jupyter_server_extension_points() -> list[dict[str, Any]]:
|
|
48
|
+
return [{"module": __name__, "app": LightconeApp}]
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
class ReadOnly(Authorizer):
|
|
52
|
+
"""Let the token read and nothing else."""
|
|
53
|
+
|
|
54
|
+
def is_authorized(
|
|
55
|
+
self, handler: JupyterHandler, user: User, action: str, resource: str
|
|
56
|
+
) -> bool:
|
|
57
|
+
"""Allow ``read``; refuse ``write`` and ``execute`` with a 403."""
|
|
58
|
+
return action == "read"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class TokenLogin(PasswordIdentityProvider):
|
|
62
|
+
"""Jupyter's token login, without the form's offer to set a password."""
|
|
63
|
+
|
|
64
|
+
# Accepting one writes a Jupyter config file and lets that password in
|
|
65
|
+
# beside the token. Not configurable, so no config can turn it back on.
|
|
66
|
+
allow_password_change = Bool(False)
|
|
67
|
+
|
|
68
|
+
@default("token")
|
|
69
|
+
def _token_default(self) -> str:
|
|
70
|
+
# JUPYTER_NO_CONFIG does not suppress JUPYTER_TOKEN[_FILE].
|
|
71
|
+
self.token_generated = True
|
|
72
|
+
return secrets.token_hex(32)
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class LightconeServer(ServerApp):
|
|
76
|
+
"""Jupyter's server with only what the page reads through."""
|
|
77
|
+
|
|
78
|
+
# jupyter_server's documented way to expose a subset of its services; its
|
|
79
|
+
# own tuple's inferred type is what mypy objects to.
|
|
80
|
+
default_services = ("contents", "files") # type: ignore[assignment]
|
|
81
|
+
|
|
82
|
+
@default("cookie_secret")
|
|
83
|
+
def _default_cookie_secret(self) -> bytes:
|
|
84
|
+
# A different user can claim a stopped server's port and receive the
|
|
85
|
+
# old page's cookies. Those cookies must never authenticate a new run.
|
|
86
|
+
return os.urandom(32)
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
class LightconeApp(LabServerApp):
|
|
90
|
+
"""Serve the Lightcone front end and nothing else."""
|
|
91
|
+
|
|
92
|
+
serverapp_class = LightconeServer
|
|
93
|
+
name = "lightcone"
|
|
94
|
+
app_name = "Lightcone"
|
|
95
|
+
# The page's `?v=`. Jupyter serves static/ as immutable by path, so this
|
|
96
|
+
# is all that makes a browser fetch a rebuilt bundle: its bytes, not the
|
|
97
|
+
# package version, which a development build does not move.
|
|
98
|
+
app_version = hashlib.sha256(BUNDLE.read_bytes() if BUNDLE.is_file() else b"").hexdigest()[:16]
|
|
99
|
+
default_url = "/lightcone"
|
|
100
|
+
app_url = "/lightcone"
|
|
101
|
+
serverapp_config = {
|
|
102
|
+
"jpserver_extensions": {"jupyter_live_content": True},
|
|
103
|
+
# jupyter_server still serves a handler that declares no auth rule to
|
|
104
|
+
# anyone; refused instead, every route needs the token, ours included.
|
|
105
|
+
"allow_unauthenticated_access": False,
|
|
106
|
+
"authorizer_class": ReadOnly,
|
|
107
|
+
"identity_provider_class": TokenLogin,
|
|
108
|
+
"contents_manager_class": ProjectContents,
|
|
109
|
+
}
|
|
110
|
+
static_dir = str(BUNDLE.parent)
|
|
111
|
+
templates_dir = str(_HERE / "templates")
|
|
112
|
+
# The page loads no lab extension, so none is advertised to it.
|
|
113
|
+
labextensions_path: list[str] = []
|
|
114
|
+
|
|
115
|
+
def initialize_handlers(self) -> None:
|
|
116
|
+
"""Add the app's routes to the page's own."""
|
|
117
|
+
super().initialize_handlers()
|
|
118
|
+
# Ahead of the catch-all jupyterlab_server ends its own list with
|
|
119
|
+
# (`/lightcone/.*`), which would answer for them with the page.
|
|
120
|
+
self.handlers[:0] = routes.HANDLERS
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"""Confined reads for the viewer, including symlinks in shared projects."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import stat
|
|
7
|
+
from collections.abc import Iterator
|
|
8
|
+
from contextlib import ExitStack, contextmanager
|
|
9
|
+
from datetime import UTC, datetime
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import IO, Any
|
|
12
|
+
|
|
13
|
+
from jupyter_server.base.handlers import AuthenticatedFileHandler
|
|
14
|
+
from jupyter_server.services.contents.largefilemanager import AsyncLargeFileManager
|
|
15
|
+
from nbformat.sign import NotebookNotary
|
|
16
|
+
from tornado import web
|
|
17
|
+
from traitlets import Bool, default
|
|
18
|
+
|
|
19
|
+
from lightcone.engine import assets
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def resolved_path(root: Path, path: Path, *, hidden: bool = False) -> Path:
|
|
23
|
+
"""Allow project-local links, including annex objects, but no escaping links."""
|
|
24
|
+
root = root.resolve()
|
|
25
|
+
try:
|
|
26
|
+
relative = path.relative_to(root)
|
|
27
|
+
resolved = path.resolve(strict=True)
|
|
28
|
+
target = resolved.relative_to(root)
|
|
29
|
+
if not hidden:
|
|
30
|
+
if any(part.startswith(".") for part in relative.parts):
|
|
31
|
+
raise ValueError("hidden path")
|
|
32
|
+
# Locked git-annex artifacts point into this private object store.
|
|
33
|
+
parts = (
|
|
34
|
+
target.parts[3:]
|
|
35
|
+
if target.parts[:3] == (".git", "annex", "objects")
|
|
36
|
+
else target.parts
|
|
37
|
+
)
|
|
38
|
+
if any(part.startswith(".") for part in parts):
|
|
39
|
+
raise ValueError("hidden target")
|
|
40
|
+
return resolved
|
|
41
|
+
except (ValueError, OSError, RuntimeError) as error:
|
|
42
|
+
raise web.HTTPError(404, "File is outside the readable project") from error
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
@contextmanager
|
|
46
|
+
def open_fd(
|
|
47
|
+
root: Path, path: Path, *, directory: bool = False, hidden: bool = False
|
|
48
|
+
) -> Iterator[int]:
|
|
49
|
+
"""Open beneath root without following links swapped in after resolution.
|
|
50
|
+
|
|
51
|
+
Directory descriptors anchor every step. O_NONBLOCK and fstat reject
|
|
52
|
+
special files without hanging on a FIFO planted by another project writer.
|
|
53
|
+
"""
|
|
54
|
+
root = root.resolve()
|
|
55
|
+
path = resolved_path(root, path, hidden=hidden)
|
|
56
|
+
try:
|
|
57
|
+
with ExitStack() as stack:
|
|
58
|
+
flags = os.O_RDONLY | os.O_NOFOLLOW | os.O_DIRECTORY
|
|
59
|
+
parent = os.open(root, flags)
|
|
60
|
+
stack.callback(os.close, parent)
|
|
61
|
+
parts = path.relative_to(root).parts
|
|
62
|
+
for part in parts[:-1]:
|
|
63
|
+
parent = os.open(part, flags, dir_fd=parent)
|
|
64
|
+
stack.callback(os.close, parent)
|
|
65
|
+
flags = os.O_RDONLY | os.O_NOFOLLOW | os.O_NONBLOCK
|
|
66
|
+
if directory:
|
|
67
|
+
flags |= os.O_DIRECTORY
|
|
68
|
+
fd = os.open(parts[-1] if parts else ".", flags, dir_fd=parent)
|
|
69
|
+
stack.callback(os.close, fd)
|
|
70
|
+
mode = os.fstat(fd).st_mode
|
|
71
|
+
if not (stat.S_ISDIR(mode) if directory else stat.S_ISREG(mode)):
|
|
72
|
+
raise web.HTTPError(404, "Not a regular file")
|
|
73
|
+
yield fd
|
|
74
|
+
except OSError as error:
|
|
75
|
+
raise web.HTTPError(404, "File is unavailable") from error
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
class ProjectFileHandler(AuthenticatedFileHandler):
|
|
79
|
+
"""Jupyter's authentication and HTTP ranges over a confined, open file."""
|
|
80
|
+
|
|
81
|
+
def validate_absolute_path(self, root: str, absolute_path: str) -> str:
|
|
82
|
+
# The opener checks containment and hidden paths, allowing annex links.
|
|
83
|
+
# Keep the requested alias for MIME detection and subsequent reads:
|
|
84
|
+
# its resolved target may legitimately live under .git/annex/objects.
|
|
85
|
+
with open_fd(Path(root), Path(absolute_path)) as fd:
|
|
86
|
+
self._stat_result = os.fstat(fd)
|
|
87
|
+
return absolute_path
|
|
88
|
+
|
|
89
|
+
# Tornado's classmethod reads by path. This instance needs the serving root
|
|
90
|
+
# as well; compute_etag is disabled by Jupyter, so no class-level caller runs.
|
|
91
|
+
def get_content( # type: ignore[override]
|
|
92
|
+
self, abspath: str, start: int | None = None, end: int | None = None
|
|
93
|
+
) -> Iterator[bytes]:
|
|
94
|
+
with (
|
|
95
|
+
open_fd(Path(self.root), Path(abspath)) as fd,
|
|
96
|
+
os.fdopen(fd, "rb", closefd=False) as file,
|
|
97
|
+
):
|
|
98
|
+
file.seek(start or 0)
|
|
99
|
+
remaining = None if end is None else end - (start or 0)
|
|
100
|
+
while remaining is None or remaining > 0:
|
|
101
|
+
chunk = file.read(65_536 if remaining is None else min(65_536, remaining))
|
|
102
|
+
if not chunk:
|
|
103
|
+
break
|
|
104
|
+
if remaining is not None:
|
|
105
|
+
remaining -= len(chunk)
|
|
106
|
+
yield chunk
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
class ProjectContents(AsyncLargeFileManager):
|
|
110
|
+
"""Confined project reads, without hashing or persistent notebook trust."""
|
|
111
|
+
|
|
112
|
+
# Notebook reads otherwise recover a corrupt file by renaming its atomic
|
|
113
|
+
# intermediate into place, a write that bypasses Jupyter's authorizer.
|
|
114
|
+
use_atomic_writing = Bool(False)
|
|
115
|
+
|
|
116
|
+
@default("files_handler_class")
|
|
117
|
+
def _files_handler_class_default(self) -> type[ProjectFileHandler]:
|
|
118
|
+
return ProjectFileHandler
|
|
119
|
+
|
|
120
|
+
def _get_os_path(self, path: str) -> str:
|
|
121
|
+
os_path: str = super()._get_os_path(path) # type: ignore[no-untyped-call]
|
|
122
|
+
resolved_path(Path(self.root_dir), Path(os_path))
|
|
123
|
+
return os_path
|
|
124
|
+
|
|
125
|
+
def _base_model(self, path: str) -> dict[str, Any]:
|
|
126
|
+
model: dict[str, Any] = super()._base_model(path) # type: ignore[no-untyped-call]
|
|
127
|
+
os_path = Path(self._get_os_path(path))
|
|
128
|
+
with open_fd(Path(self.root_dir), os_path, directory=os_path.is_dir()) as fd:
|
|
129
|
+
info = os.fstat(fd)
|
|
130
|
+
# lstat describes the symlink itself. Previews and cache tokens must
|
|
131
|
+
# instead describe the bytes that will be served through that link.
|
|
132
|
+
model.update(size=info.st_size, writable=False)
|
|
133
|
+
for field, timestamp in (("last_modified", info.st_mtime), ("created", info.st_ctime)):
|
|
134
|
+
try:
|
|
135
|
+
model[field] = datetime.fromtimestamp(timestamp, UTC)
|
|
136
|
+
except (ValueError, OverflowError, OSError):
|
|
137
|
+
model[field] = datetime.fromtimestamp(0, UTC)
|
|
138
|
+
return model
|
|
139
|
+
|
|
140
|
+
@contextmanager
|
|
141
|
+
def open(self, os_path: str, mode: str = "r", **kwargs: Any) -> Iterator[IO[Any]]:
|
|
142
|
+
with open_fd(Path(self.root_dir), Path(os_path)) as fd:
|
|
143
|
+
with open(fd, mode, closefd=False, **kwargs) as file:
|
|
144
|
+
yield file
|
|
145
|
+
|
|
146
|
+
async def get(
|
|
147
|
+
self,
|
|
148
|
+
path: str,
|
|
149
|
+
content: bool = True,
|
|
150
|
+
type: str | None = None,
|
|
151
|
+
format: str | None = None,
|
|
152
|
+
require_hash: bool = False,
|
|
153
|
+
) -> dict[str, Any]:
|
|
154
|
+
# Live-content asks for a hash even for metadata-only reads. The page
|
|
155
|
+
# never uses it, and Jupyter would read the entire artifact to produce it.
|
|
156
|
+
model: dict[str, Any] = await super().get( # type: ignore[no-untyped-call]
|
|
157
|
+
path, content, type, format, require_hash=False
|
|
158
|
+
)
|
|
159
|
+
if model["type"] != "directory":
|
|
160
|
+
root = Path(self.root_dir)
|
|
161
|
+
target = resolved_path(root, root / model["path"])
|
|
162
|
+
model["watchPaths"] = [
|
|
163
|
+
target.relative_to(root).as_posix(),
|
|
164
|
+
assets.manifest_path(Path(model["path"])).as_posix(),
|
|
165
|
+
]
|
|
166
|
+
return model
|
|
167
|
+
|
|
168
|
+
async def _dir_model(self, path: str, content: bool = True) -> dict[str, Any]:
|
|
169
|
+
model: dict[str, Any] = await super()._dir_model( # type: ignore[no-untyped-call]
|
|
170
|
+
path, content=False
|
|
171
|
+
)
|
|
172
|
+
if content:
|
|
173
|
+
with open_fd(Path(self.root_dir), Path(self._get_os_path(path)), directory=True) as fd:
|
|
174
|
+
names = os.listdir(fd)
|
|
175
|
+
children = []
|
|
176
|
+
for name in names:
|
|
177
|
+
if not self.should_list(name): # type: ignore[no-untyped-call]
|
|
178
|
+
continue
|
|
179
|
+
try:
|
|
180
|
+
children.append(await self.get(f"{path}/{name}".strip("/"), content=False))
|
|
181
|
+
except (web.HTTPError, OSError):
|
|
182
|
+
# A hidden, escaping, absent or unreadable child must not
|
|
183
|
+
# prevent the rest of the directory from being listed.
|
|
184
|
+
continue
|
|
185
|
+
model.update(content=children, format="json")
|
|
186
|
+
return model
|
|
187
|
+
|
|
188
|
+
@default("notary")
|
|
189
|
+
def _notary_default(self) -> NotebookNotary:
|
|
190
|
+
# Reading a notebook checks its signature, which by default creates
|
|
191
|
+
# Jupyter's signature database and secret in the user's data directory.
|
|
192
|
+
return NotebookNotary( # type: ignore[no-untyped-call]
|
|
193
|
+
parent=self, db_file=":memory:", secret=os.urandom(32)
|
|
194
|
+
)
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
"""The app's own routes: what the page needs and the Contents API cannot give.
|
|
2
|
+
|
|
3
|
+
An output's recorded run, read by lc's own manifest reader, so the page
|
|
4
|
+
never parses lc's format and the server never has to open dotfiles to it;
|
|
5
|
+
every output's state, classified by the engine exactly as ``lc status``
|
|
6
|
+
does, so the page holds no copy of that rule; and the cited papers in
|
|
7
|
+
astra's paper cache, which lies outside the
|
|
8
|
+
project (``astra paper add`` fills it, and quotes are verified against it).
|
|
9
|
+
The paper routes are adapted from jupyterlab-lightcone's ``routes.py``
|
|
10
|
+
(BSD-3-Clause, Lightcone Research), without its fetch route: nothing here
|
|
11
|
+
writes the cache. Every route needs the token, like the rest of the server.
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
from __future__ import annotations
|
|
15
|
+
|
|
16
|
+
import asyncio
|
|
17
|
+
import os
|
|
18
|
+
from pathlib import Path
|
|
19
|
+
from typing import Any
|
|
20
|
+
|
|
21
|
+
from astra.papers.cache import CachedPaper, PaperCache
|
|
22
|
+
from jupyter_core.utils import ensure_async
|
|
23
|
+
from jupyter_server.base.handlers import APIHandler
|
|
24
|
+
from jupyter_server.utils import url_path_join
|
|
25
|
+
from tornado import web
|
|
26
|
+
|
|
27
|
+
from lightcone.app.files import ProjectFileHandler, open_fd
|
|
28
|
+
from lightcone.engine import assets, materialize
|
|
29
|
+
from lightcone.engine.project import ProjectError, current_project
|
|
30
|
+
|
|
31
|
+
_PAPERS = PaperCache().cache_dir
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def _cached() -> dict[str, CachedPaper]:
|
|
35
|
+
"""Every cached paper by DOI as the SDK normalizes it, unversioned first."""
|
|
36
|
+
papers: dict[str, CachedPaper] = {}
|
|
37
|
+
for paper in PaperCache().list_papers():
|
|
38
|
+
doi = paper.metadata.doi.strip().lower()
|
|
39
|
+
if doi not in papers or paper.metadata.version is None:
|
|
40
|
+
papers[doi] = paper
|
|
41
|
+
return papers
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class PapersHandler(APIHandler):
|
|
45
|
+
"""Title, authors and PDF of the cited DOIs the cache holds."""
|
|
46
|
+
|
|
47
|
+
@web.authenticated
|
|
48
|
+
async def get(self) -> None:
|
|
49
|
+
"""Answer the repeated ``doi`` arguments from one scan of the cache."""
|
|
50
|
+
cached = await asyncio.to_thread(_cached)
|
|
51
|
+
papers: dict[str, dict[str, str]] = {}
|
|
52
|
+
for doi in self.get_arguments("doi"):
|
|
53
|
+
if (paper := cached.get(doi)) is None:
|
|
54
|
+
continue
|
|
55
|
+
pdf = paper.pdf_path.relative_to(_PAPERS).as_posix()
|
|
56
|
+
metadata = {
|
|
57
|
+
"title": paper.metadata.title,
|
|
58
|
+
"authors": ", ".join(paper.metadata.authors or []),
|
|
59
|
+
"pdfUrl": url_path_join(self.base_url, "lightcone/papers", pdf),
|
|
60
|
+
}
|
|
61
|
+
papers[doi] = {key: value for key, value in metadata.items() if value}
|
|
62
|
+
self.set_header("Cache-Control", "private, no-store")
|
|
63
|
+
self.finish({"papers": papers})
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class RunHandler(APIHandler):
|
|
67
|
+
"""The run lc recorded for one output, or ``null`` when there is none."""
|
|
68
|
+
|
|
69
|
+
@web.authenticated
|
|
70
|
+
async def get(self) -> None:
|
|
71
|
+
"""Read the manifest beside the output the ``path`` argument names."""
|
|
72
|
+
# Whether the path is a file in the project is the contents manager's
|
|
73
|
+
# to say, as it does for /files/: outside the root, hidden, absent or
|
|
74
|
+
# a directory is refused before anything is read.
|
|
75
|
+
cm: Any = self.contents_manager # its methods are untyped
|
|
76
|
+
path = self.get_query_argument("path")
|
|
77
|
+
if not cm.allow_hidden and await ensure_async(cm.is_hidden(path)):
|
|
78
|
+
raise web.HTTPError(404)
|
|
79
|
+
model = await ensure_async(cm.get(path, type="file", content=False))
|
|
80
|
+
# The sidecar is hidden, but uses the same confined opener as artifacts.
|
|
81
|
+
root = Path(cm.root_dir).resolve()
|
|
82
|
+
sidecar = assets.manifest_path(root / model["path"])
|
|
83
|
+
try:
|
|
84
|
+
with open_fd(root, sidecar, hidden=True) as fd:
|
|
85
|
+
with os.fdopen(fd, "r", closefd=False) as file:
|
|
86
|
+
manifest = assets.loads(file.read())
|
|
87
|
+
except (web.HTTPError, UnicodeDecodeError):
|
|
88
|
+
manifest = None
|
|
89
|
+
run: dict[str, Any] | None = None
|
|
90
|
+
if manifest is not None:
|
|
91
|
+
run = {
|
|
92
|
+
"finishedAt": manifest.finished_at,
|
|
93
|
+
"gitRevision": manifest.git_sha,
|
|
94
|
+
"recipe": manifest.recipe,
|
|
95
|
+
"environment": manifest.env_version,
|
|
96
|
+
"cliVersion": manifest.lc_version,
|
|
97
|
+
"inputVersions": manifest.input_versions,
|
|
98
|
+
}
|
|
99
|
+
self.set_header("Cache-Control", "private, no-store")
|
|
100
|
+
self.finish({"run": run})
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
class StatusHandler(APIHandler):
|
|
104
|
+
"""What state every output is in: the engine's answer, as `lc status` gives it."""
|
|
105
|
+
|
|
106
|
+
@web.authenticated
|
|
107
|
+
async def get(self) -> None:
|
|
108
|
+
"""Classify every output; a project the engine cannot read is a 422."""
|
|
109
|
+
root = Path(self.contents_manager.root_dir)
|
|
110
|
+
try:
|
|
111
|
+
# Classification hashes the declared inputs, so it runs off the loop.
|
|
112
|
+
report = await asyncio.to_thread(materialize.status, current_project(root))
|
|
113
|
+
except ProjectError as error:
|
|
114
|
+
raise web.HTTPError(422, str(error)) from error
|
|
115
|
+
outputs = {o.output: {"state": o.status, "detail": o.why} for o in report.outputs}
|
|
116
|
+
self.set_header("Cache-Control", "private, no-store")
|
|
117
|
+
# The warnings qualify the verdicts — an unfetched input reads as
|
|
118
|
+
# "changed" without the line saying it is merely not in this clone.
|
|
119
|
+
self.finish({"outputs": outputs, "warnings": report.warnings})
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
HANDLERS = [
|
|
123
|
+
("/lightcone/api/papers", PapersHandler),
|
|
124
|
+
("/lightcone/api/run", RunHandler),
|
|
125
|
+
("/lightcone/api/status", StatusHandler),
|
|
126
|
+
# Jupyter's own file handler: ranges for pdf.js, 304s on reopening.
|
|
127
|
+
("/lightcone/papers/(.*)", ProjectFileHandler, {"path": str(_PAPERS)}),
|
|
128
|
+
]
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|