Skip to content

Support file-path syntax (path/to/module.py:config) as alternative to dotpath in pconfigs.run #17

Description

@majmin7

Summary

Add support for file-path syntax in pconfigs.run, allowing users to specify configs as path/to/module.py:config_name in addition to the existing dotpath syntax path.to.module.config_name.

Motivation

Code editors make it trivial to copy the file path to a module (e.g., via "Copy Relative Path"), but converting that path to a dotpath requires manual effort: replacing / with ., stripping the .py extension, and prepending the repo package root. This friction is a daily papercut when iterating on experiments. The file-path syntax would let users copy a path directly from their editor and paste it into the run command without any transformation.

Proposed behavior

The runner accepts a colon-delimited file path and config name:

# New syntax — file path with colon-separated config name
python -m pconfigs.run path/to/pconfig/module.py:config

# Existing syntax — unchanged
python -m pconfigs.run path.to.pconfig.module.config

The runner detects which form is being used by checking whether the argument contains a / or ends in .py (before the :). If the file-path form is detected, the runner imports the module from the given path and looks up the named attribute (config in the example above). If no :name is given, the runner could default to config (the conventional instance name) or raise a clear error asking the user to specify one.

Current workaround

Manually convert the file path to a dotpath before running:

# File path from editor:   genrg/pconfig/foo/bar.py
# Must be converted to:
python -m pconfigs.run genrg.pconfig.foo.bar.config

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions