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 and installed=True, but no dataset is found, an exception is raised (this is the behavior of the required_dataset() function in the DataLad core package). With installed=False no exception is raised and a dataset instances matching PWD is returned.

short_description() str[source]

This method is deprecated. Use input_synopsis instead