Skip to content

chore(config): move shared config primitives into runtime package#123

Open
samet-akcay wants to merge 3 commits into
mainfrom
feat/shared-config-runtime
Open

chore(config): move shared config primitives into runtime package#123
samet-akcay wants to merge 3 commits into
mainfrom
feat/shared-config-runtime

Conversation

@samet-akcay
Copy link
Copy Markdown
Contributor

@samet-akcay samet-akcay commented May 19, 2026

Summary

  • add a runtime-owned physicalai.config package for shared configuration utilities
  • move ComponentSpec out of physicalai.inference.manifest while keeping the old import path as a compatibility re-export
  • update runtime inference code to use the shared config primitive directly

Why

Config, ComponentSpecand the generic config helpers need to live in the torch-free runtime package so both the runtime repo and the training library can use the same primitive. This keeps configuration ownership in one place and removes the long-term duplicatephysicalai.config` implementation.

Compatibility

This PR keeps the existing import path working:

from physicalai.inference.manifest import ComponentSpec

New code can use:

from physicalai.config import ComponentSpec

⚠️ Follow-up

This is the first half of the migration. The paired training-library PR removes the duplicate library/src/physicalai/config package and switches library imports to the runtime-owned physicalai.config module.

Copilot AI review requested due to automatic review settings May 19, 2026 13:41
@samet-akcay samet-akcay requested a review from a team as a code owner May 19, 2026 13:41
@samet-akcay samet-akcay changed the title Move shared config primitives into runtime package chore(config): move shared config primitives into runtime package May 19, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces a runtime-owned physicalai.config package to centralize shared configuration primitives (notably ComponentSpec) so both runtime and training code can depend on a torch-free implementation, while preserving backward compatibility via re-exports from physicalai.inference.manifest.

Changes:

  • Added new physicalai.config package (Config base, ComponentSpec, instantiation + serialization helpers).
  • Moved ComponentSpec out of physicalai.inference.manifest and updated inference code to import it from physicalai.config.
  • Added a unit test asserting the legacy physicalai.inference.manifest.ComponentSpec import remains compatible.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit/inference/test_manifest.py Updates imports and adds a test asserting ComponentSpec is re-exported from the legacy path.
src/physicalai/inference/runners/factory.py Switches runner-spec validation to use physicalai.config.ComponentSpec.
src/physicalai/inference/model.py Removes runtime import of ComponentSpec from manifest; keeps type-only reference to the shared primitive.
src/physicalai/inference/manifest.py Removes local ComponentSpec definition and imports ComponentSpec from physicalai.config to maintain compatibility.
src/physicalai/inference/component_factory.py Updates doc/type references to point to physicalai.config.ComponentSpec.
src/physicalai/config/init.py Exposes the new shared config primitives as a public package API.
src/physicalai/config/base.py Adds dataclass-backed Config helper for dict/YAML roundtrips.
src/physicalai/config/component.py Adds the shared ComponentSpec Pydantic model.
src/physicalai/config/instantiate.py Adds generic instantiation utilities for {class_path, init_args}-style configs.
src/physicalai/config/mixin.py Adds FromConfig mixin + decorator for config-based constructors.
src/physicalai/config/serializable.py Adds dataclass (de)serialization helpers with basic type-hint reconstruction.
Comments suppressed due to low confidence (2)

src/physicalai/config/instantiate.py:58

  • After config = config[key], config is no longer guaranteed to be a dict. The subsequent if "class_path" in config: and later config.keys() usages will raise TypeError/AttributeError if the selected value is not a mapping. Add an isinstance(config, dict) check (and a clear ValueError) after extracting key to enforce the expected shape.
    if key is not None:
        if key not in config:
            msg = f"Configuration must contain '{key}' key. Got keys: {list(config.keys())}"
            raise ValueError(msg)
        config = config[key]

    if "class_path" in config:
        cls = _import_class(config["class_path"])

src/physicalai/config/instantiate.py:115

  • yaml.safe_load() can return None (empty file) or a non-dict top-level value; passing that directly into instantiate_obj_from_dict() will crash with a non-obvious TypeError (e.g. 'NoneType' is not iterable). Consider validating that the loaded config is a dict (or defaulting None to {}) and raising a helpful error if not.
    """Instantiate an object from a YAML/JSON configuration file."""
    with Path(file_path).open("r", encoding="utf-8") as f:
        config = yaml.safe_load(f)
    return instantiate_obj_from_dict(config, key=key, target_cls=target_cls)


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/physicalai/config/mixin.py
Comment thread src/physicalai/config/base.py
Comment thread src/physicalai/config/instantiate.py
@samet-akcay
Copy link
Copy Markdown
Contributor Author

Just reading through https://jsonargparse.readthedocs.io/en/stable/ and feel like we could re-write all of this stuff using just jsonargparse

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants