symfonic.cli.examples¶
examples ¶
symfonic examples -- copy a runnable example into the user's project.
Examples are not importable modules shipped in the wheel; they are bundled
as data under symfonic/cli/example_data/ (via a build-time hatch
force-include mapping the repo-root examples/ tree). This command copies
a curated example out into the caller's working directory so an installed-only
consumer -- someone who ran pip install symfonic-core and never cloned the
repo -- can run it in seconds, without us shipping the whole codebase inside the
package.
Two resolution roots are supported so the command behaves identically in a wheel install and in a source checkout / editable install:
- Packaged data --
symfonic/cli/example_data/(present in built wheels). - Repo checkout fallback -- the sibling
examples/tree at the repo root (present in editable installs and when running the tests).
Both roots carry the same relative layout for the curated set, so the
:data:CURATED specs resolve against either without branching.
ExampleSpec
dataclass
¶
ExampleSpec(
name: str,
summary: str,
run: str,
srcdir: str | None = None,
srcfile: str | None = None,
requires: str | None = None,
)
A curated, copy-out example.
srcdir and srcfile are mutually exclusive and are given relative to
the resolved examples root. Exactly one must be set.
requires
class-attribute
instance-attribute
¶
Human note on prerequisites (extra + credentials), or None for
a base-install example that runs on MockModelProvider.
ExamplesError ¶
Bases: RuntimeError
Raised when an example cannot be listed or copied.
add_example ¶
Copy the curated example name into dest_dir/<name>/.
Returns the created target directory. Raises :class:ExamplesError for an
unknown name, a missing source, or an existing target when force is
False.
Source code in src/symfonic/cli/examples.py
available_examples ¶
resolve_examples_root ¶
Locate the directory that holds the curated example sources.
Prefers the packaged example_data (wheel installs); falls back to the
repo-root examples/ tree (editable installs / source checkouts).