Skip to content

Convert a value to Path when the parameter is annotated Path #40

Description

@vertix

What to do

Convert a value to Path when the target parameter's annotation asks for Path. The resolver
already reads the signature.

Why

configuronic builds a value from the CLI text with ast.literal_eval, and keeps a str when that
read fails. An int, a float and a bool survive that read. A path does not. So
--output_dir=/tmp/run reaches the function as a str. An .override string reaches it unchanged
for the same result.

A caller cannot annotate the parameter Path today. The annotation disagrees with the value that
arrives, and a type checker believes the annotation. So a path parameter carries str | Path | None,
and the function converts the value again.

The URL case

A path parameter also takes a URL, for example --output_dir=s3://bucket/run. The remote store parses
that URL. Path keeps the text on Linux and on macOS, and changes a separator on Windows. Write a
test for this case.

Who waits for it

positronic annotates each path parameter str | Path | None for this reason. It drops the str half
after this change. prepare_output_dir in positronic/cli/eval/run.py carries a TODO that points
here.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions