Trial

class smexperiments.trial.Trial(sagemaker_boto_client, **kwargs)

Bases: smexperiments._base_types.Record

An execution of a data-science workflow with an experiment.

Consists of a list of trial component objects, which document individual activities within the workflow.

trial_name

The name of the trial.

Type:str
experiment_name

The name of the trial’s experiment.

Type:str
trial_name = None
experiment_name = None
save()

Save the state of this Trial to SageMaker.

Returns:Update trial response.
Return type:dict
delete()

Delete this Trial from SageMaker.

Requires that this Trial contains no TrialComponents. Individual TrialComponents can be removed by calling remove_trial_component().

Returns:
dict: Delete trial response.
classmethod load(trial_name, sagemaker_boto_client=None)

Load an existing trial and return a Trial object.

Parameters:
  • trial_name – (str): Name of the Trial.
  • sagemaker_boto_client (SageMaker.Client, optional) – Boto3 client for SageMaker. If not supplied, a default boto3 client will be created and used.
Returns:

A SageMaker Trial object

Return type:

smexperiments.trial.Trial

classmethod create(experiment_name, trial_name=None, sagemaker_boto_client=None, trial_components=None)

Create a new trial and return a Trial object.

Parameters:
  • experiment_name – (str): Name of the experiment to create this trial in.
  • trial_name – (str, optional): Name of the Trial. If not specified, an auto-generated name will be used.
  • sagemaker_boto_client (SageMaker.Client, optional) – Boto3 client for SageMaker. If not supplied, a default boto3 client will be created and used.
  • trial_components (list) – A list of trial component names, trial components, or trial component trackers
Returns:

A SageMaker Trial object

Return type:

smexperiments.trial.Trial

classmethod list(experiment_name=None, created_before=None, created_after=None, sort_by=None, sort_order=None, sagemaker_boto_client=None)

List all trials matching the specified criteria.

Parameters:
  • experiment_name (str, optional) – Name of the experiment. If specified, only trials in the experiment will be returned.
  • created_before (datetime.datetime, optional) – Return trials created before this instant.
  • created_after (datetime.datetime, optional) – Return trials created after this instant.
  • sort_by (str, optional) – Which property to sort results by. One of ‘Name’, ‘CreationTime’.
  • sort_order (str, optional) – One of ‘Ascending’, or ‘Descending’.
  • sagemaker_boto_client (SageMaker.Client, optional) – Boto3 client for SageMaker. If not supplied, a default boto3 client will be created and used.
Returns:

An iterator over trials

matching the specified criteria.

Return type:

collections.Iterator[smexperiments.trial.TrialSummary]

add_trial_component(tc)

Add the specified trial component to this Trial.

A trial component may belong to many trials and a trial may have many trial components.

Parameters:
  • tc – (tracker.Tracker|trial_component.TrialComponent|str) The trial component to add. Can be
  • of a Tracker instance, a TrialComponent instance, or a string containing the name of (one) –
  • trial component to add. (the) –
remove_trial_component(tc)

Remove the specified trial component from this trial.

Parameters:
  • tc – (tracker.Tracker|trial_component.TrialComponent|str) The trial component to remove. Can be
  • of a Tracker instance, a TrialComponent instance, or a string containing the name of (one) –
  • trial component to remove. (the) –
list_trial_components(created_before=None, created_after=None, sort_by=None, sort_order=None, max_results=None, next_token=None)

List trial components in this trial matching the specified criteria.

Parameters:
  • created_before (datetime.datetime, optional) – Return trials created before this instant.
  • created_after (datetime.datetime, optional) – Return trials created after this instant.
  • sort_by (str, optional) – Which property to sort results by. One of ‘Name’, ‘CreationTime’.
  • sort_order (str, optional) – One of ‘Ascending’, or ‘Descending’.
  • max_results (int, optional) – maximum number of trial components to retrieve
  • next_token (str, optional) – token for next page of results
Returns:

An iterator over

trials matching the criteria.

Return type:

collections.Iterator[smexperiments.api_types.TrialComponentSummary]