Skip to content

T2-3: Replace config singleton in ingestion commands with load_project() injection #94

Description

@JesuFemi-O

Milestone: #83
Depends on: #90

Context

src/tycoon/commands/sources.py, run_all.py, sync_cmd.py, explore.py all use from tycoon.config import config and access config.sources, config.raw_db, config.root. The singleton is constructed at import time, which complicates testing and prevents the project path from being determined at invocation time.

Goal

In each of the four files, replace the module-level config import with local load_project() calls inside each command function body. Pattern:

# Before
from tycoon.config import config
def list_sources(...):
    _require_project()
    sources = config.sources

# After
from tycoon.project import load_project

def _require_project_here():
    root = _find_project_root()  # walk up from cwd looking for tycoon.yml
    project = load_project(root)
    if project is None:
        error("No tycoon.yml found. Run 'tycoon init' first.")
        raise typer.Exit(1)
    return project, root

def list_sources(...):
    project, root = _require_project_here()
    sources = project.sources

The TycoonConfig class and config singleton remain unchanged in config.py — this is a partial migration.

Acceptance

  • pytest tests/test_sources.py passes without monkey-patching the config singleton
  • tycoon data sources list works in a temp directory with a valid tycoon.yml

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent-readyClear AC, no open design decisionsarea: configtycoon.yml schema + config singletontype: taskIndividual implementation tasks

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions