Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement resolve_path as a constraint #270

Closed
mih opened this issue Mar 2, 2023 · 1 comment · Fixed by #271
Closed

Implement resolve_path as a constraint #270

mih opened this issue Mar 2, 2023 · 1 comment · Fixed by #271

Comments

@mih
Copy link
Member

mih commented Mar 2, 2023

With #260 merged, we can enhance EnsurePath to automatically perform DataLad-unique way of resolving relative paths.

@adswa
Copy link
Member

adswa commented Mar 2, 2023

yes, that would be nice! I just ran into that

@mih mih changed the title Implement EnsurePathInDataset Implement resolve_path as a constraint Mar 2, 2023
mih added a commit to mih/datalad-next that referenced this issue Mar 2, 2023
This implements DataLad's standard path resolution approach (relative
is relative to CWD, unless a `Dataset` instance is given).

This now makes it possible to perform this standard resolution pattern
during command parameter validation, like so:

```py
\# example validator for a command with two args
EnsureCommandParameterization(
    param_constraints=dict(
        dataset=EnsureDataset(),
        path=EnsurePath(),
    ),
    tailor_for_dataset=dict(path='dataset'),
)
```

This will:

- cause the 'dataset' validator to run first
- auto-generate an `EnsurePath` variant that resolves against that
  dataset
- ensures that the command always receives absolute paths, resolved
  against the dataset whenever the rules require it.

Closes datalad#270
mih added a commit to mih/datalad-next that referenced this issue Mar 3, 2023
This implements DataLad's standard path resolution approach (relative
is relative to CWD, unless a `Dataset` instance is given).

This now makes it possible to perform this standard resolution pattern
during command parameter validation, like so:

```py
\# example validator for a command with two args
EnsureCommandParameterization(
    param_constraints=dict(
        dataset=EnsureDataset(),
        path=EnsurePath(),
    ),
    tailor_for_dataset=dict(path='dataset'),
)
```

This will:

- cause the 'dataset' validator to run first
- auto-generate an `EnsurePath` variant that resolves against that
  dataset
- ensures that the command always receives absolute paths, resolved
  against the dataset whenever the rules require it.

Closes datalad#270
@mih mih closed this as completed in #271 Mar 3, 2023
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 a pull request may close this issue.

2 participants