Quick Start
Quick Start
What this page is: Copy-pasteable Python snippets for the two most common COGANT API entry points: a manual
Sessionand an orchestratedPipelineRunner.Prerequisites: Installation and the API overview.
Reading time: ~5 minutes
Next steps: Session API · PipelineRunner API · Bundle API
# doctest: +SKIP # example requires runtime context or external resources
from cogant import Session, PipelineRunner, Bundle
from cogant.api.pipeline import PipelineConfig
# Method 1: Simple Session
session = Session.from_target("./my_repo")
session.extract_static()
session.build_graph()
session.translate_to_gnn()
session.export_all("output/")
# Method 2: Orchestrated Pipeline
runner = PipelineRunner()
config = PipelineConfig(output_dir="output/")
bundle = runner.run("./my_repo", config)
# Access results
print(bundle.repo_summary())
bundle.save_json("output/bundle.json") # same artifact as `cogant translate --output output/`
bundle.render_site("html_site/")
Examples
The two snippets above are run end-to-end against real targets in:
- Zoo:
examples/zoo/01_simple_state/— pointSession.from_target("./examples/zoo/01_simple_state")here for the smallest reproducible run. - Zoo:
examples/zoo/12_full_pomdp/— exercises every stage inPipelineConfig.stageson a non-trivial repo. - Cookbook: Recipe 1: Scan your first Python project — Method 1 (Session) recipe.
- Cookbook: Recipe 2: JSON output — Method 2 (PipelineRunner +
bundle.save_json). - Tutorial: Tutorial 1: Quickstart — five-minute walkthrough that maps directly onto Method 1.
- Tutorial: Tutorial 3: Flask walkthrough — same API on a real-world six-module Flask app.