Skip to content

hand_run

Resolve a configuration into what a hand run's manifest must say.

The platform turns a configuration and a selection of channels into a manifest: the cores and memory it reserves, the parameters typed and defaulted, the slots bound. yousleep-manifest --config does the same for a run outside the platform, and refuses a selection the platform would refuse, so that a hand run is the run the platform will do. Without an explicit selection it selects the channels as the platform does, through :mod:yousleep_common.utils.channel_matching.

HandRunError

Bases: ValueError

The selection or the parameters are not ones the platform would accept.

RunPlan dataclass

What the configuration decides for this run.

describe_selection(refs, left_out)

Say which channels a selection without a choice kept and which it left out, and why.

plan_run(config, refs, *, duration_ms, parameters, select=False)

Decide a hand run from the configuration, or refuse it as the platform would.

Parameters:

Name Type Description Default
config AnalysisConfig

The analysis configuration.

required
refs list[ChannelRef]

The selected channels, as the manifest will name them; with select, every channel of the recording.

required
duration_ms int | None

The recording's length, when the header states it.

required
parameters dict[str, ParameterValue]

Values given on the command line, keyed as the configuration declares them.

required
select bool

Select from refs as the platform does when no channel is chosen, instead of taking them as chosen.

False

Returns:

Type Description
RunPlan

The plan: configuration id and hash, cores, memory projected for

RunPlan

this recording, parameters with defaults filled in, channels with

RunPlan

slots bound.

Raises:

Type Description
HandRunError

Listing every reason the platform would refuse.

select_as_platform(config, refs)

Select channels from a recording's as the platform does when none are chosen.

Channels matching the configuration's exact and type requirements are kept, at an accepted sampling rate; where a type matches more channels than it takes, the first ones in montage order are kept.

Parameters:

Name Type Description Default
config AnalysisConfig

The analysis configuration.

required
refs list[ChannelRef]

Every channel of the recording, in montage order.

required

Returns:

Type Description
list[ChannelRef]

The channels kept, in the order the platform gives them, and the

list[tuple[str, str]]

channels of a type the analysis reads that were left out, as

tuple[list[ChannelRef], list[tuple[str, str]]]

(header label, reason) pairs.

Raises:

Type Description
HandRunError

The configuration binds sided slots, which the platform fills by each channel's recorded side, a fact a header does not reliably state. Such a run takes an explicit selection.