{"id":50589796,"url":"https://github.com/apahl/marimo_graph","last_synced_at":"2026-06-05T09:30:44.178Z","repository":{"id":351286259,"uuid":"1210346583","full_name":"apahl/marimo_graph","owner":"apahl","description":"Visualize Marimo notebooks as graphs.","archived":false,"fork":false,"pushed_at":"2026-04-14T10:31:57.000Z","size":103,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-26T07:37:43.724Z","etag":null,"topics":["marimo","python"],"latest_commit_sha":null,"homepage":"","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/apahl.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-04-14T10:22:26.000Z","updated_at":"2026-04-14T13:37:49.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/apahl/marimo_graph","commit_stats":null,"previous_names":["apahl/marimo_graph"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/apahl/marimo_graph","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apahl%2Fmarimo_graph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apahl%2Fmarimo_graph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apahl%2Fmarimo_graph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apahl%2Fmarimo_graph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/apahl","download_url":"https://codeload.github.com/apahl/marimo_graph/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/apahl%2Fmarimo_graph/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33939226,"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-05T02:00:06.157Z","response_time":120,"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":["marimo","python"],"created_at":"2026-06-05T09:30:42.334Z","updated_at":"2026-06-05T09:30:44.159Z","avatar_url":"https://github.com/apahl.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# marimo_graph\n\nGenerate Mermaid flowcharts from Marimo notebook Python files.\n\n![graph](example/graph.png)\n\nThis project parses Marimo cells from a `.py` notebook file, infers dependencies from function arguments and return values, and produces a Mermaid flowchart representation of the cell DAG. It can also generated graphs directly inside a Marimo notebook.\n\n## HOw it works\n\n- Detects Marimo cells decorated with `@app.cell` (and `@cell` fallback).\n- When a cell has been re-named, the name of the cell is used, otherwise incremental numbers are used.\n- Doc comments at the top of cells can used to give additional comments.\n- Builds dependency edges from:\n  - Cell input arguments (what a cell consumes)\n  - Returned names (what a cell produces)\n- Skips cells that contain import statements to keep the graph focused on notebook logic.\n- Removes isolated cells that are not connected to any dependency edge.\n- Emits Mermaid flowchart output with frontmatter config.\n- Supports optional inline icon metadata in cell docstrings using:\n  - `::icon:path/to/icon.svg::`\n\n\n## Requirements\n\n- Python 3.10+ recommended.\n- No external dependencies required for DAG generation.\n\n## Installation\n\nClone the repository and install with pip.\n\n```bash\ngit clone \u003cyour-repo-url\u003e\ncd marimo_graph\npip install .\nmarimo-dag-to-mermaid --help\n```\n\nYou can also run the script directly without installing:\n\n```bash\npython marimo_dag_to_mermaid.py --help\n```\n\n## Usage\n\n### 1) Command Line\n\nFrom the project root:\n\n```bash\nmarimo-dag-to-mermaid example/test.py -o example/test_dag.mmd\n```\n\nIf `-o` is omitted, Mermaid output is printed to stdout:\n\n```bash\nmarimo-dag-to-mermaid example/test.py\n```\n\nEquivalent direct-script form:\n\n```bash\npython marimo_dag_to_mermaid.py example/test.py -o example/test_dag.mmd\n```\n\n### 2) Inside a Marimo Notebook\n\nThe graphs can be rendered directly in the Marimo notebooks:\n\n```python\n# Cell 1\nimport marimo as mo\n\nfrom marimo_dag_to_mermaid import mermaid_from_path\n\n# Cell 2..X: Do stuff\n\n#Cell Y:\nmo.mermaid(mermaid_from_path(__file__))\n```\n\nThe graph-creating cell has to be run manually, a re-run is not triggered automatically when the notebook is changed.\n\n![notebook](example/notebook.png)\n\n## API\n\n### `mermaid_from_path(path, title=\"Marimo DAG\") -\u003e str`\n\nReads a Marimo notebook Python file and returns Mermaid diagram text.\n\n### `parse_cells(source: str) -\u003e list[CellInfo]`\n\nParses source code into structured cell metadata.\n\n### `to_mermaid(cells, title=\"Marimo DAG\") -\u003e str`\n\nTransforms parsed cells into Mermaid flowchart syntax.\n\n## How Dependency Inference Works\n\nFor each detected cell:\n\n- Inputs: function parameters (for example `def _(df): ...`) are treated as dependencies.\n- Outputs: return values are parsed from `return ...` expressions.\n- Producer mapping: a variable is linked to the latest cell that produced it.\n- Edge creation: if a cell input was produced by another cell, an edge is added.\n\n## Notes and Limitations\n\n- Cells with imports are intentionally excluded from graph rendering.\n- Only connected cells are rendered.\n- Output inference is based on return statements, so cells that only display values without returning them may not contribute outputs.\n- If multiple cells overwrite the same returned variable name, the latest producer is used.\n\n## Development\n\nRun script directly while iterating:\n\n```bash\npython marimo_dag_to_mermaid.py example/test.py\n```\n\n## License\n\nMIT License. See `LICENSE`.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapahl%2Fmarimo_graph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapahl%2Fmarimo_graph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapahl%2Fmarimo_graph/lists"}