Skip to main content

Trial

See also: Builders.

Trial​

Domain object wrapping a trial ProjectItemMetadata,with action methods.

Returned by TrialsService.create() or TrialsService.as_trial().

Usage::

trial.run()
status = trial.status()
trial.stop()

The underlying ProjectItemMetadata,is available as trial.item for access to metadata (sid, core_id, snapshot_id, name, …).

Returned by: JinkoClient.create_trial, JinkoClient.create_trial_from_json, JinkoClient.get_trial, JinkoClient.iter_trials, JinkoClient.list_trials, Model.create_trial, SubsamplingDesign.source_trial, Trial.edit_solving_options, Trial.set_solving_times, TrialVisualization.source_trial

Also has every member of ProjectItem.

MemberKindDescription
modelpropertyReturn the computational model bound to this trial, if any.
data_tablespropertyReturn the data tables bound to this trial.
vpoppropertyReturn the virtual population bound to this trial, if any.
protocol_designpropertyReturn the protocol design bound to this trial, if any.
simple_output_setpropertyReturn the simple output set bound to this trial, if any.
advanced_output_setpropertyReturn the advanced output set bound to this trial, if any.
runmethodStart the trial.
stopmethodStop a running trial.
statusmethodReturn the current status of this trial snapshot.
sanitymethodReturn the pre-launch sanity report for this trial snapshot as a raw dict.
get_solving_timesmethodReturn base and additional output sampling periods.
get_solving_optionsmethodReturn trial solving options as a raw dictionary.
edit_solving_optionsmethodUpdate trial solving options with a complete object or partial dictionary.
set_solving_timesmethodUpdate output sampling periods.
wait_until_completedmethodPoll status until the trial reaches a terminal state or timeout.
run_and_wait_until_completedmethodStart the trial and wait until it reaches a terminal state.
output_idsmethodReturn output ids exposed by the trial manager output-ids endpoint.
create_subsampling_designmethodCreate a subsampling design from this trial.
create_empty_trial_visualizationmethodCreate an empty trial visualization bound to this trial.
create_trial_visualization_from_jsonmethodCreate a trial visualization from JSON and bind it to this trial.
descriptorspropertyAccess typed trial result descriptors derived from results.summary().
resultspropertyAccess trial result helper methods.

model​

Type: Model | None

Return the computational model bound to this trial, if any.

data_tables​

Type: list['DataTable']

Return the data tables bound to this trial.

vpop​

Type: Vpop | None

Return the virtual population bound to this trial, if any.

protocol_design​

Type: ProtocolDesign | None

Return the protocol design bound to this trial, if any.

simple_output_set​

Type: SimpleOutputSet | None

Return the simple output set bound to this trial, if any.

advanced_output_set​

Type: AdvancedOutputSet | None

Return the advanced output set bound to this trial, if any.

run​

run() -> None

Start the trial.

stop​

stop() -> Any

Stop a running trial.

status​

status() -> Any

Return the current status of this trial snapshot.

sanity​

sanity() -> Any

Return the pre-launch sanity report for this trial snapshot as a raw dict.

This is the same trial-context validation the Jinkō UI runs before launch, broken down per component (model, protocol, vpop, outputSet for the simple output set, scorings for the advanced output set, dataTables, solvingTimes). Each component exposes sanity.errors/sanity.warnings (an error dict has a code such as ADVANCED_OUTPUTS_ERRORS) and sanity.componentsSanity for per-output diagnostics.

Passing validate_scoring_formula()/standalone advanced-output diagnostics is not sufficient to conclude an advanced output set is compatible with this trial — call sanity() to check that.

Examples:

>>> report = trial.sanity()
>>> report["scorings"]["sanity"]["errors"]
>>> report["scorings"]["sanity"]["componentsSanity"]

get_solving_times​

get_solving_times(
*,
revision: int | None = None,
duration_format: Literal["iso8601", "timedelta"] = "iso8601"
) -> tuple[dict[str, timedelta | str], list[dict[str, timedelta | str]]]

Return base and additional output sampling periods.

The returned dictionaries have t_min, t_max, and t_step keys. Values are ISO 8601 strings by default, preserving expressions such as P1W. Set duration_format="timedelta" to convert them using Jinko's fixed year (365.25 days), month (one twelfth of a year), and week (7 day) lengths. Use jinko.iso8601 for these same conversions in custom code.

get_solving_options​

get_solving_options(
*,
revision: int | None = None,
duration_format: Literal["iso8601", "timedelta"] = "iso8601"
) -> dict[str, Any]

Return trial solving options as a raw dictionary.

Solving-time durations are ISO 8601 strings by default. Set duration_format="timedelta" to convert them.

edit_solving_options​

edit_solving_options(
solving_options: dict[str, Any], *, version: str | dict | None = None
) -> Trial

Update trial solving options with a complete object or partial dictionary.

solvingTimes accepts timedelta values or ISO 8601 strings. Strings are validated and sent unchanged; timedeltas use fixed day and sub-day units.

set_solving_times​

set_solving_times(
*,
t_max: timedelta | str,
t_step: timedelta | str,
t_min: timedelta | str = timedelta(0),
additional_periods: Sequence[dict[str, timedelta | str]] = (),
version: str | dict | None = None
) -> Trial

Update output sampling periods.

t_min, t_max and t_step are the parameters of the mandatory simulation-wide period. Each accepts a timedelta or ISO 8601 string. Timedeltas are emitted with fixed day and sub-day units, so a seven-day timedelta is sent as P7D. ISO 8601 strings are validated and sent unchanged, preserving expressions such as P1W and P1M. Use jinko.iso8601 for these same conversions in custom code.

It must contain every additional period: its t_min must be no greater and its t_max no less than each additional period.

additional_periods optionally add shorter sampling windows and may be in any order. Each period needs a positive t_step and t_min <= t_max. Example: [{"t_min": timedelta(0), "t_max": "P28D", "t_step": "P1D"}]. t_min defaults to timedelta(0), for both the base and additional periods.

wait_until_completed​

wait_until_completed(
*,
timeout: float | None = None,
poll_interval: float = 2.0,
show_progress: bool | None = None
) -> Any

Poll status until the trial reaches a terminal state or timeout.

Progress rendering adapts to the current environment: notebooks use Rich live rendering on stdout, interactive terminals use Rich live rendering on stderr, and non-interactive streams fall back to plain text snapshots when progress output is explicitly enabled.

run_and_wait_until_completed​

run_and_wait_until_completed(
*,
timeout: float | None = None,
poll_interval: float = 2.0,
show_progress: bool | None = None
) -> Any

Start the trial and wait until it reaches a terminal state.

output_ids​

output_ids() -> Any

Return output ids exposed by the trial manager output-ids endpoint.

create_subsampling_design​

create_subsampling_design(
*,
numeric_filters: Sequence[object] = (),
categorical_filters: Sequence[object] = (),
marginals: Sequence[object] = (),
categoricals: Sequence[object] = (),
correlations: Sequence[object] = (),
survivals: Sequence[object] = (),
summary_statistics: Sequence[object] = (),
observables: Sequence[object] = (),
folder: Folder | str | None = None,
name: str | None = None,
description: str | None = None,
version: str | dict | None = None
) -> SubsamplingDesign

Create a subsampling design from this trial.

Most users build filters and targets from trial.descriptors and pass them here.

Examples:

>>> descriptors = trial.descriptors
>>> age = descriptors.scalars.get("age", arm="treated")
>>> sex = descriptors.categoricals.get("sex", arm="treated")
>>> auc = descriptors.scalars.get("tumorRadius.auc", arm="treated")
>>> trial.create_subsampling_design(
... name="adult female responders",
... numeric_filters=[age.gte(18)],
... categorical_filters=[sex.in_levels(["female"])],
... marginals=[auc.normal(mean=12.0, standard_deviation=2.5)],
... )

Parameters:

NameTypeDescriptionDefault
numeric_filtersSequence[object]Numeric conditions such as age.gte(18).()
categorical_filtersSequence[object]Categorical conditions such as sex.in_levels(["female"]).()
marginalsSequence[object]Target distributions for scalar outputs.()
categoricalsSequence[object]Target distributions for categorical outputs.()
correlationsSequence[object]Target relationships between scalar outputs.()
survivalsSequence[object]Target survival curves.()
summary_statisticsSequence[object]Target means and related summary values.()
observablesSequence[object]Extra scalar outputs to keep track of.()
folderFolder | str | NoneDestination folder.None
namestr | NoneOptional display name.None
descriptionstr | NoneOptional description.None
versionstr | dict | NoneOptional version label.None

These arguments also accept raw dict inputs when you need to bypass the ergonomic builders. observables also accepts bare string ids.

create_empty_trial_visualization​

create_empty_trial_visualization(
*,
folder: Folder | str | None = None,
name: str | None = None,
description: str | None = None,
version: str | dict | None = None
) -> TrialVisualization

Create an empty trial visualization bound to this trial.

create_trial_visualization_from_json​

create_trial_visualization_from_json(
data: dict[str, Any] | str | Path,
*,
folder: Folder | str | None = None,
name: str | None = None,
description: str | None = None,
version: str | dict | None = None
) -> TrialVisualization

Create a trial visualization from JSON and bind it to this trial.

If you're not starting from an existing visualization exported to json, we recommend using create_empty_trial_visualization and using the project item's methods to craft your visualization step-by-step.

descriptors​

Type: TrialDescriptors

Access typed trial result descriptors derived from results.summary().

results​

Type: TrialResults

Access trial result helper methods.

TabularDownload​

Represents tabular result content returned by result_manager endpoints.

MemberKindDescription
raw_bytespropertyReturn the raw downloaded payload bytes.
to_dataframemethodParse the payload as CSV (or zipped CSV) into a pandas DataFrame.

raw_bytes​

Type: bytes

Return the raw downloaded payload bytes.

to_dataframe​

to_dataframe()

Parse the payload as CSV (or zipped CSV) into a pandas DataFrame.

TrialDescriptors​

Returned by: Trial.descriptors, TrialDescriptors.refresh

MemberKindDescription
scalarsattribute
scalars_cross_armattribute
categoricalsattribute
categoricals_cross_armattribute
armspropertyReturn the protocol arms exposed by the trial results summary.
refreshmethodDrop the cached results summary and reload on next access.

scalars​

scalars_cross_arm​

categoricals​

categoricals_cross_arm​

arms​

Type: tuple[str, ...]

Return the protocol arms exposed by the trial results summary.

refresh​

refresh() -> TrialDescriptors

Drop the cached results summary and reload on next access.

ScalarTrialDescriptor​

MemberKindDescription
idattribute
typeattribute
labelsattribute
groupattribute
armattribute
available_armsattribute
descriptionattribute
display_nameattribute
unitattribute
eqmethodBuild a numeric equality filter for this scalar descriptor.
neqmethodBuild a numeric inequality filter for this scalar descriptor.
ltmethodBuild a strict upper-bound filter for this scalar descriptor.
ltemethodBuild an upper-bound filter for this scalar descriptor.
gtmethodBuild a strict lower-bound filter for this scalar descriptor.
gtemethodBuild a lower-bound filter for this scalar descriptor.
group_by_valuesmethodGroup results by the distinct values of this descriptor.
group_by_bin_widthmethodGroup results into fixed-width bins of width starting at offset.
group_by_binsmethodGroup results into count equal-width bins.
group_by_quantilesmethodGroup results into count quantile groups.
group_by_breaksmethodGroup results at explicit, strictly increasing cut points.
uniformmethodBuild a uniform target distribution for this scalar descriptor.
normalmethodBuild a normal target distribution for this scalar descriptor.
normal_truncatedmethodBuild a truncated normal target distribution for this descriptor.
log_normalmethodBuild a log-normal target distribution for this scalar descriptor.
weibullmethodBuild a Weibull target distribution for this scalar descriptor.
mixturemethodBuild a mixture target distribution for this scalar descriptor.
observablemethodTrack this scalar descriptor as an extra observable.
summary_statisticmethodBuild a summary-statistic target for this scalar descriptor.
survivalmethodBuild a survival target for this scalar descriptor.
correlate_withmethodBuild a correlation target between this descriptor and another scalar.

id​

Type: str

type​

Type: str

labels​

Type: tuple[str, ...]

group​

Type: TrialDescriptorGroupName

arm​

Type: str | None

available_arms​

Type: tuple[str, ...]

description​

Type: str | None

display_name​

Type: str | None

unit​

Type: object | None

eq​

eq(value: float, *, is_active: bool = True) -> NumericFilterBuilder

Build a numeric equality filter for this scalar descriptor.

neq​

neq(value: float, *, is_active: bool = True) -> NumericFilterBuilder

Build a numeric inequality filter for this scalar descriptor.

lt​

lt(value: float, *, is_active: bool = True) -> NumericFilterBuilder

Build a strict upper-bound filter for this scalar descriptor.

lte​

lte(value: float, *, is_active: bool = True) -> NumericFilterBuilder

Build an upper-bound filter for this scalar descriptor.

gt​

gt(value: float, *, is_active: bool = True) -> NumericFilterBuilder

Build a strict lower-bound filter for this scalar descriptor.

gte​

gte(value: float, *, is_active: bool = True) -> NumericFilterBuilder

Build a lower-bound filter for this scalar descriptor.

group_by_values​

group_by_values(
*, reference_arm: ReferenceArmRef | None = None
) -> dict[str, Any]

Group results by the distinct values of this descriptor.

Examples:

>>> trial.results.aggregate_scalars([auc], group_by=[dose.group_by_values()])

group_by_bin_width​

group_by_bin_width(
*, offset: float, width: float, reference_arm: ReferenceArmRef | None = None
) -> dict[str, Any]

Group results into fixed-width bins of width starting at offset.

group_by_bins​

group_by_bins(
count: int, *, reference_arm: ReferenceArmRef | None = None
) -> dict[str, Any]

Group results into count equal-width bins.

group_by_quantiles​

group_by_quantiles(
count: int, *, reference_arm: ReferenceArmRef | None = None
) -> dict[str, Any]

Group results into count quantile groups.

Examples:

>>> auc = trial.descriptors.scalars.get('Tumor.Drug.auc', arm='treated')
>>> trial.results.aggregate_scalars([auc], group_by=[auc.group_by_quantiles(4)])

group_by_breaks​

group_by_breaks(
breaks: Sequence[float], *, reference_arm: ReferenceArmRef | None = None
) -> dict[str, Any]

Group results at explicit, strictly increasing cut points.

uniform​

uniform(
*,
low_bound: float,
high_bound: float,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
weight: float | None = None,
reference: str | None = None
) -> MarginalBuilder

Build a uniform target distribution for this scalar descriptor.

normal​

normal(
*,
mean: float,
standard_deviation: float,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
weight: float | None = None,
reference: str | None = None
) -> MarginalBuilder

Build a normal target distribution for this scalar descriptor.

normal_truncated​

normal_truncated(
*,
mean: float,
standard_deviation: float,
low_bound: float,
high_bound: float,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
weight: float | None = None,
reference: str | None = None
) -> MarginalBuilder

Build a truncated normal target distribution for this descriptor.

log_normal​

log_normal(
*,
mean: float,
standard_deviation: float,
base: float,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
weight: float | None = None,
reference: str | None = None
) -> MarginalBuilder

Build a log-normal target distribution for this scalar descriptor.

weibull​

weibull(
*,
lambda_: float,
k: float,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
weight: float | None = None,
reference: str | None = None
) -> MarginalBuilder

Build a Weibull target distribution for this scalar descriptor.

mixture​

mixture(
components: List[dict[str, object]],
*,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
reference: str | None = None
) -> MarginalBuilder

Build a mixture target distribution for this scalar descriptor.

Each component must define a weight and either:

  • distribution set to another marginal builder for the same descriptor
  • or distribution as a distribution name plus params

observable​

observable() -> ObservableBuilder

Track this scalar descriptor as an extra observable.

summary_statistic​

summary_statistic(
*,
mean: float,
subject_to: Iterable[SubjectToBuilder] = (),
weight: float = 1.0,
is_active: bool = True,
standard_deviation: float | None = None,
mean_wide_range_low_bound: float | None = None,
mean_wide_range_high_bound: float | None = None,
std_wide_range_low_bound: float | None = None,
std_wide_range_high_bound: float | None = None,
reference: str | None = None
) -> SummaryStatisticBuilder

Build a summary-statistic target for this scalar descriptor.

survival​

survival(
*,
time_vals: List[float] | tuple[float, ...] | None = None,
survival_rates: List[float] | tuple[float, ...] | None = None,
points: dict[float, float] | Iterable[tuple[float, float]] | None = None,
subject_to: Iterable[SubjectToBuilder] = (),
weight: float = 1.0,
is_active: bool = True,
time_unit: object | None = None,
reference: str | None = None
) -> SurvivalBuilder

Build a survival target for this scalar descriptor.

Provide either points or both time_vals and survival_rates.

correlate_with​

correlate_with(
other: TrialDescriptor,
*,
correlation_coefficient: float,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
weight: float | None = None,
reference: str | None = None
) -> CorrelationBuilder

Build a correlation target between this descriptor and another scalar.

CategoricalTrialDescriptor​

MemberKindDescription
idattribute
typeattribute
labelsattribute
groupattribute
armattribute
available_armsattribute
descriptionattribute
display_nameattribute
levelsattribute
in_levelsmethodBuild a categorical filter for the selected levels.
group_by_levelsmethodGroup results by the levels of this categorical descriptor.
categoricalmethodBuild a target categorical distribution for this descriptor.

id​

Type: str

type​

Type: str

labels​

Type: tuple[str, ...]

group​

Type: TrialDescriptorGroupName

arm​

Type: str | None

available_arms​

Type: tuple[str, ...]

description​

Type: str | None

display_name​

Type: str | None

levels​

Type: tuple[str, ...]

in_levels​

in_levels(
levels: List[str] | tuple[str, ...], *, is_active: bool = True
) -> CategoricalFilterBuilder

Build a categorical filter for the selected levels.

group_by_levels​

group_by_levels(
*, reference_arm: ReferenceArmRef | None = None
) -> dict[str, Any]

Group results by the levels of this categorical descriptor.

Examples:

>>> sex = trial.descriptors.categoricals.get('sex', arm='identity')
>>> trial.results.aggregate_scalars([auc], group_by=[sex.group_by_levels()])

categorical​

categorical(
category_weights: dict[str, float],
*,
subject_to: Iterable[SubjectToBuilder] = (),
is_active: bool = True,
weight: float | None = None,
reference: str | None = None
) -> CategoricalTargetBuilder

Build a target categorical distribution for this descriptor.