Skip to content

P0: cli.py resolves config and writes outputs relative to the installed package #8

Description

@wiyth00

Problem

chained_eclipse/cli.py computes:

ROOT = Path(__file__).resolve().parents[1]
DEFAULT_CONFIG = ROOT / "config" / "baseline.yaml"
DEFAULT_OUTPUTS = ROOT / "outputs"

Under a non-editable install — exactly what CI does (uv sync --no-editable) and what any pip install chained-eclipse user gets — ROOT resolves to site-packages/. Consequences:

  1. DEFAULT_CONFIG does not exist there, so the CLI is unusable without --config.
  2. Worse, run_full() / run_design_only() write optimized_system.yaml into ROOT / "config", i.e. the CLI silently writes YAML into site-packages.
  3. run_fixed_only / run_stability_only fall back to ROOT/config/optimized_system.yaml, which inherits the same breakage.

It only works from a source checkout.

Proposed fix

  • Resolve the default config via importlib.resources, after moving config/baseline.yaml to chained_eclipse/config/baseline.yaml and packaging it as package data — or require --config when the default is missing, with a clear error message rather than a confusing FileNotFoundError.
  • Never write into ROOT / "config". The optimized-system mirror already goes to <output>/optimized_system.yaml; drop the second copy, or gate it behind an explicit --save-config PATH flag.
  • Update the run_fixed_only / run_stability_only fallback to read from the output directory, and document the new lookup order.

Test

A subprocess test that invokes chained-eclipse --help plus a monkeypatched-config smoke path, asserting no writes land outside the temporary output directory.

Scientific impact

None expected — packaging and path resolution only. No solver or geometry code changes.

From the work plan, item P0 / 3. Left unimplemented because the packaging approach (package-data vs. required --config) is a maintainer decision that changes the documented user-facing invocation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions