{"id":50714007,"url":"https://github.com/cphyc/storyt","last_synced_at":"2026-06-09T17:30:54.357Z","repository":{"id":357573093,"uuid":"1237546951","full_name":"cphyc/storyt","owner":"cphyc","description":"Manage data products from simulations.","archived":false,"fork":false,"pushed_at":"2026-05-13T09:58:50.000Z","size":53,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-13T11:37:54.753Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cphyc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-13T09:30:14.000Z","updated_at":"2026-05-13T09:58:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/cphyc/storyt","commit_stats":null,"previous_names":["cphyc/storyt"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/cphyc/storyt","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fstoryt","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fstoryt/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fstoryt/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fstoryt/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cphyc","download_url":"https://codeload.github.com/cphyc/storyt/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cphyc%2Fstoryt/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34118750,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-09T02:00:06.510Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-06-09T17:30:50.192Z","updated_at":"2026-06-09T17:30:54.351Z","avatar_url":"https://github.com/cphyc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# storyt\n\n`storyt` manages a hierarchy of static/dynamic assets (filesystem objects like simulation outputs) and caches computed properties in a SQLite database. It also ships a **web viewer** that exports the asset tree as a static site you can browse in any browser.\n\n---\n\n## Installation\n\n```bash\npip install storyt\n# or for development:\npip install -e .\n```\n\n---\n\n## Quick start\n\n```python\nimport storyt as st\n\nproject = st.StaticAsset(path=\"./MyProject\", name=\"project\")\nsim = project.add_children(path=[\"run1\", \"run2\"], name=\"simulation\")\noutput = sim.add_children(re=r\"output_(?P\u003ciout\u003e\\d{5})\", name=\"output\")\n\nproject.discover()\n\nfor inst in output.instances(iout=\"00010\"):\n    print(inst.path, inst.keys)\n```\n\n---\n\n## Key concepts\n\n- **StaticAsset** — a node in the asset hierarchy (e.g. a project, a simulation, an output directory).\n- **Instances** — concrete filesystem paths that match an asset's pattern.\n- **Properties** — named computed values cached in SQLite (e.g. `gas_mass`, `stellar_mass`).\n- **Bindings** — links between sibling assets that share a common key (e.g. `iout`).\n\n---\n\n## API reference\n\n| Method | Description |\n|---|---|\n| `StaticAsset(path, name)` | Create a root asset at `path`. |\n| `asset.add_children(path=…/re=…/callable, name=…)` | Add child asset type (static list, regex pattern, or callable). |\n| `st.bind((a, \"key\"), (b, \"key\"), …)` | Declare a binding between siblings sharing a key. |\n| `asset.reader(cls)` | Register a reader class for instances of this asset. |\n| `asset.add_property(name, fn)` | Register a computed property (lazily cached). |\n| `asset.discover()` | Walk the filesystem and populate instance records. |\n| `asset.instances(**filters)` | Iterate instances (optionally filtered by key values). |\n| `inst.get(prop_name)` / `inst.prop_name` | Compute and cache a property value. |\n\n### Discover logging\n\n`discover()` now emits optional colored, timestamped debug logs for key steps\n(registration, scans, recursion, bindings).\n\nEnable via environment variable:\n\n```bash\nexport STORYT_DISCOVER_LOG=1\npython your_script.py\n```\n\nOr configure once in Python:\n\n```python\nimport storyt as st\n\nst.logger.setLevel(\"DEBUG\")\nproject.discover()\n```\n\n---\n\n## Web viewer\n\n### 1. Install frontend dependencies\n\n```bash\ncd storyt/viewer/frontend\nnpm install\n```\n\n### 2. Build the frontend\n\n```bash\nnpm run build\n```\n\nThis produces `storyt/viewer/frontend/dist/`.\n\n### 3. Export from Python\n\n```python\nfrom pathlib import Path\nfrom storyt.viewer import export_db\n\nexport_db(db=project._db, output_dir=\"./site\", root_path=Path(\"./MyProject\"))\n```\n\nThis copies `dist/` contents and all `data/*.json` files into `./site/`.\n\n### 4. Serve\n\n```bash\ncd site \u0026\u0026 python -m http.server 8080\n```\n\nOpen \u003chttp://localhost:8080\u003e.\n\n---\n\n## Demo\n\nA full worked example with a mock simulation is in `example/build_demo.py`:\n\n```bash\n# activate venv first\nsource .venv/bin/activate\n\n# build the demo site (builds frontend automatically if dist/ is missing)\npython example/build_demo.py\n\n# serve\ncd example/site \u0026\u0026 python -m http.server 8080\n```\n\n---\n\n## Development\n\n### Running tests\n\n```bash\nsource .venv/bin/activate\npython -m pytest tests/ -q\n```\n\n### Frontend dev server\n\nFor live-reload development of the frontend UI:\n\n```bash\ncd storyt/viewer/frontend\nnpm run dev\n```\n\n\u003e **Note:** the dev server needs a `data/` directory at the root of the served path to load hierarchy and instance data.  Copy fixture data or export a real database first.\n\n---\n\n## Database design\n\nSee [`docs/database.md`](docs/database.md) for the full SQLite schema.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcphyc%2Fstoryt","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcphyc%2Fstoryt","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcphyc%2Fstoryt/lists"}