Single File vs. Package
When to use module_style single_file (one optixlog_gen.py) versus package (a directory), and how to configure either.
optixlog generate supports two output layouts controlled by module_style. For most projects the default single-file layout is the right choice; the package layout is useful when your schema grows large enough that one file becomes unwieldy.
single_file (default)
All generated code lands in a single optixlog_gen.py file at your configured output_path:
your-repo/
optixlog.toml
optixlog_gen.py ← entire generated module
ingest.py
tests/Import from it with a plain module import:
from optixlog_gen import OptixClient, Projects, SimulationNodeWhen to use it
- You have a small-to-medium number of projects and node types.
- You want the simplest possible setup.
- You want the generated code in one place for easy review in pull requests.
package
The generated code is split into a package directory named after output_path (without the .py suffix, or a directory you specify):
your-repo/
optixlog.toml
optixlog_gen/
__init__.py ← re-exports OptixClient, Projects, all node classes
_nodes.py ← node dataclasses
_projects.py ← Projects namespace + per-project wrappers
_client.py ← OptixClientImport paths are identical — the __init__.py re-exports everything:
from optixlog_gen import OptixClient, Projects, SimulationNodeWhen to use it
- You have many node types and the single file exceeds a comfortable review size.
- You want finer-grained diffs when only node types or only the client changes.
- Your linter or import checker prefers explicit module structure.
Configuring module_style
Via optixlog.toml
Add or update the [codegen] section:
[optixlog]
api_base_url = "https://optixlog.leidos.com"
[codegen]
output_path = "optixlog_gen.py" # or "optixlog_gen/" for package
module_style = "single_file" # "single_file" | "package"
[[projects]]
id = "proj_grating_7f3a"
name = "Grating Coupler Lab"Via optixlog init
Pass --module-style when running optixlog init to write the setting into optixlog.toml from the start:
optixlog init --all --module-style packageVia optixlog generate
You can override the style for a single generate run without editing optixlog.toml:
# Not a named flag on generate — set it in optixlog.toml or via init.
# Use --output to override the output path on a per-run basis:
optixlog generate --output optixlog_gen.pyOutput is byte-deterministic
Identical input schema always yields identical bytes regardless of module_style. The generated files are safe to commit and diff. Use optixlog generate --check in CI to fail when committed bindings are stale — see the CI codegen check recipe.
Comparison
Prop
Type