datalad_next.constraints.EnsureDataset
- class datalad_next.constraints.EnsureDataset(installed: bool | None = None, purpose: str | None = None, require_id: bool | None = None)[source]
Bases:
Constraint
Ensure an absent/present Dataset from any path or Dataset instance
Regardless of the nature of the input (Dataset instance or local path) a resulting instance (if it can be created) is optionally tested for absence or presence on the local file system.
Due to the particular nature of the Dataset class (the same instance is used for a unique path), this constraint returns a DatasetParameter rather than a Dataset directly. Consuming commands can discover the original parameter value via its original property, and access a Dataset instance via its ds property.
In addition to any value representing an explicit path, this constraint also recognizes the special value None. This instructs the implementation to find a dataset that contains the process working directory (PWD). Such a dataset need not have its root at PWD, but could be located in any parent directory too. If no such dataset can be found, PWD is used directly. Tests for
installed
are performed in the same way as with an explicit dataset location argument. If None is given andinstalled=True
, but no dataset is found, an exception is raised (this is the behavior of therequired_dataset()
function in the DataLad core package). Withinstalled=False
no exception is raised and a dataset instances matching PWD is returned.