config
Top-level analysis configuration models: the shared base, the full configuration, and the catalogue response.
AnalysisConfig
pydantic-model
¶
Bases: AnalysisConfigBase
The full analysis configuration: what is stored, hashed and run.
Adds what the catalogue does not serve: the image, the scheduling priority and the resources the analysis claims.
Config:
frozen:True
Fields:
-
identification(Identification) -
purpose(Purpose) -
provenance(Provenance) -
licence(Licence | LegalDocumentShort) -
evidence(Evidence) -
inputs(Inputs) -
outputs(Outputs) -
parameters(Parameters) -
cost(CostModel) -
runs_at(list[RunPlace]) -
docker(DockerSettings) -
priority(Priority) -
resources(ResourceRequirements)
Validators:
-
_provenance_written_before_it_existed -
runs_on_the_platform→runs_at -
the_declaration_covers_the_licence_class -
validated_regime_is_yousleeps_own_claim
priority
pydantic-field
¶
Scheduling priority. A platform decision; an author leaves it out.
compute_config_sha1()
¶
Compute the SHA1 hash of the analysis configuration JSON serialized.
load_validated_analysis_config(config_id, configs_dir)
classmethod
¶
Load and validate an analysis configuration from a YAML file by its filename.
:param config_id: ID of the analysis configuration file. :param configs_dir: Directory where the analysis configuration files are stored. :return: Validated analysis configuration.
AnalysisConfigBase
pydantic-model
¶
Bases: BaseModel
What an analysis configuration says that anyone may read.
The shared part of two models: AnalysisConfig, the full configuration
that is stored, hashed and run, and AnalysisConfigOut, what the
catalogue serves. What the platform knows about an analysis rather than
what the configuration says (whether its image is present, who it is
offered to) lives on the response model only, so it never enters a
configuration's identity.
Fields:
-
identification(Identification) -
purpose(Purpose) -
provenance(Provenance) -
licence(Licence | LegalDocumentShort) -
evidence(Evidence) -
inputs(Inputs) -
outputs(Outputs) -
parameters(Parameters) -
cost(CostModel) -
runs_at(list[RunPlace])
Validators:
-
_provenance_written_before_it_existed -
runs_on_the_platform→runs_at -
the_declaration_covers_the_licence_class -
validated_regime_is_yousleeps_own_claim
cost
pydantic-field
¶
Declarative pricing facts (work scaling + parameter surcharges). Defaults = flat per-signal-hour pricing; the quote endpoints always report the final figure.
evidence
pydantic-field
¶
What the analysis cites. An analysis with nothing to cite yet omits it.
identification
pydantic-field
¶
The identification object of the analysis configuration
licence
pydantic-field
¶
The licence of the analysis.
parameters
pydantic-field
¶
Parameters the analysis accepts. Omitted when it takes none.
provenance
pydantic-field
¶
Who developed the analysis, and what youSleep claims about it.
purpose
pydantic-field
¶
The purpose of the analysis.
runs_at
pydantic-field
¶
Where the analysis may run: on the platform, or on the platform and at an organisation's site. Its owner sets it, and a change applies to submissions made after it. Left out when it is the platform only. An organisation may run a platform-only analysis at its site only under an exception a platform administrator records.
runs_on_the_platform(runs_at)
pydantic-validator
¶
Require the platform among the places, and keep them in one order.
Every analysis runs on the platform; a site is the only addition. The order is fixed so two configurations that say the same thing hash the same.
the_declaration_covers_the_licence_class()
pydantic-validator
¶
Refuse a commercial licence class on a declaration that ticked non-commercial use.
The declaration is what the developer said the analysis may be offered for; the licence class is what the platform offers it for. The second cannot exceed the first.
validated_regime_is_yousleeps_own_claim()
pydantic-validator
¶
Refuse a validated regime on an analysis youSleep did not develop.
The regime says which values of a parameter the analysis was characterised
at, and the platform says it in its own voice: every other value is then
presented to the user as a research setting. That is a claim to make about
one's own work. A developer's published operating point for their own
analysis belongs under evidence, where a reader can see whose claim it
is, rather than being restated here as the platform's.
AnalysisConfigOut
pydantic-model
¶
Bases: AnalysisConfigBase
What the catalogue serves: the readable configuration and the platform's facts about it.
Fields:
-
identification(Identification) -
purpose(Purpose) -
provenance(Provenance) -
licence(Licence | LegalDocumentShort) -
evidence(Evidence) -
inputs(Inputs) -
outputs(Outputs) -
parameters(Parameters) -
cost(CostModel) -
runs_at(list[RunPlace]) -
available(bool) -
visibility(AnalysisVisibility) -
credits_per_signal_hour(float) -
site_allowance(SiteAllowance | None)
Validators:
-
_provenance_written_before_it_existed -
runs_on_the_platform→runs_at -
the_declaration_covers_the_licence_class -
validated_regime_is_yousleeps_own_claim
available = False
pydantic-field
¶
Whether the analysis's image is present in the registry, as the platform last checked.
credit
property
¶
Return the credit this analysis's results carry, wherever they are shown.
credits_per_signal_hour = 0
pydantic-field
¶
What the analysis costs per hour of recorded signal, before channel and parameter adjustments, as the platform charges it.
site_allowance = None
pydantic-field
¶
Where the caller's organisation may run the analysis, for a signed-in caller. Null for an anonymous caller, and from a server that predates it.
spend_class
property
¶
Return the spend class the analysis's licence gives it.
visibility = AnalysisVisibility.PUBLIC
pydantic-field
¶
Where the analysis is offered. A caller sees a private analysis only when it belongs to the caller's organization.
CostModel
pydantic-model
¶
Bases: BaseModel
Declarative, INPUT-side pricing facts for one analysis config.
Pricing responds to what the user submits (hours, channels, chosen options) — never to how the analysis is implemented internally, so a predictor/algorithm change can never silently change prices. The api-server's single cost function computes::
rate = per_signal_hour or the global billing rate
multiplier = 1 + per_channel_slope * (n_channels - 1)
billed_h = signal_hours * multiplier * prod(surcharge multipliers)
cost = ceil(billed_h * rate) + global minimum
+ sum(surcharge credits)
The base duration cost is meant to dominate: keep per_channel_slope
well below 1 (default 0 = channel count does not affect price). All
defaults yield exactly the flat global per-signal-hour pricing.
Config:
frozen:True
Fields:
-
per_signal_hour(float | None) -
per_channel_slope(float) -
parameter_surcharges(list[ParameterSurcharge])
parameter_surcharges
pydantic-field
¶
Extra costs for specific user-chosen parameter values.
per_channel_slope = 0.0
pydantic-field
¶
Dampened premium per resolved channel beyond the first: multiplier = 1 + slope * (n_channels - 1). 0 (default) = channel count does not affect price; keep well below 1 so the duration cost dominates. The per-type channel caps bound the maximum.
per_signal_hour = None
pydantic-field
¶
Config-specific credit rate per billed hour; null uses the global billing.credit_cost.per_signal_hour. THE knob for pricing an expensive-to-run analysis (e.g. one that internally runs many inference passes).
ParameterSurcharge
pydantic-model
¶
Bases: BaseModel
Extra cost when a parameter takes a specific (normalized) value.
Prices user-selected OPTIONS — e.g. a high-frequency-output mode that multiplies compute — without new server code. Matched against the submission's normalized parameter values (defaults filled in), so a default-valued surcharge applies even when the user omits the parameter.
Config:
frozen:True
Fields:
-
parameter(str) -
equals(str | int | float | bool) -
hours_multiplier(float) -
extra_credits(int)
equals
pydantic-field
¶
The value that triggers the surcharge (exact match on the normalized value).
extra_credits = 0
pydantic-field
¶
Flat credits added to the analysis cost when triggered.
hours_multiplier = 1.0
pydantic-field
¶
Multiplies the billed hours when triggered.
parameter
pydantic-field
¶
The parameter's api_name (must exist in parameters.custom).
SiteAllowance
pydantic-model
¶
Bases: BaseModel
Where the caller's organisation may run an analysis.
The platform runs every analysis. An organisation's own site runs one whose configuration allows a site, or one that an exception in force covers for the organisation. The quote and the submission apply the same rule; this says what it gives before either is asked.
Config:
frozen:True
Fields:
-
place(RunPlace) -
runs_there(bool) -
allowed_at_site(bool) -
by_exception(bool)
allowed_at_site
pydantic-field
¶
Whether the organisation may run the analysis at its own site: its configuration allows a site, or an exception in force covers it for the organisation.
by_exception
pydantic-field
¶
Whether only an exception in force allows it at the site: the configuration itself keeps the analysis on the platform.
place
pydantic-field
¶
Where the organisation's analyses run now: on the platform, or at its own site.
runs_there
pydantic-field
¶
Whether the analysis may run there. On the platform it always may; at the site, when allowed_at_site is true. Where it may not, the quote and the submission refuse it.