datalad_core.commands

Components for implementing DataLad commands

At the very core, a DataLad command is function that documents and validates its parameters in a particular way, and yields return values that follow particular conventions.

In its simplest form, a DataLad command can be created like this:

>>> @datalad_command()
... def my_command(some_arg):
...     # do processing ...
...     return  # typically one or more results are returned/yielded

The datalad_command() decorator wraps a function, and automatically establishes the conventions expected for a DataLad command (see its documentation for details).

Beyond this simplest use, the decorator can be used to customize parameter validation, and result handling. Both aspects are handled by customizable classes.

datalad_command(*[, preproc, postproc_cls, ...])

Wrap a callable with parameter preprocessing and result post-processing

ResultHandler(cmd_kwargs)

Abstract base class for result handlers

StandardResultHandler(cmd_kwargs)

Result handler commonly used by commands

PassthroughHandler(cmd_kwargs)

Minimal handler that relays any return value unmodified

get_default_result_handler()

Get the default result handler class used by @datalad_command

set_default_result_handler(handler_cls)

Set a default result handler class for use by @datalad_command

Dataset(spec)

Dataset parameter type for DataLad command implementations

EnsureDataset(*[, installed])

Ensure an absent/present Dataset from any path or Dataset instance

ParamProcessor()

Abstract base class for parameter processors

JointParamProcessor(param_constraints, *[, ...])

Parameter preprocessor with support for multi-parameter set handling

ParamConstraintContext(param_names[, ...])

Representation of a parameter constraint context

ParamErrors(exceptions)

Exception for command parameter constraint violations

ParamSetConstraint(param_names, *[, aspect])

Base class for constraints of command parameter sets