in src/smexperiments/trial_component.py [0:0]
def delete(self, force_disassociate=None):
"""Delete this TrialComponent from SageMaker.
Args:
force_disassociate (boolean): Indicates whether to force disassociate the trial component with the trials
before deletion. If set to true, force disassociate the trial component with associated trials first, then
delete the trial component. If it's not set or set to false, it will delete the trial component directory
without disassociation.
Returns:
dict: Delete trial component response.
"""
if force_disassociate:
next_token = None
while True:
if next_token:
list_trials_response = self.sagemaker_boto_client.list_trials(
TrialComponentName=self.trial_component_name, NextToken=next_token
)
else:
list_trials_response = self.sagemaker_boto_client.list_trials(
TrialComponentName=self.trial_component_name
)
# Disassociate the trials and trial components
for per_trial in list_trials_response["TrialSummaries"]:
# to prevent DisassociateTrialComponent throttling
time.sleep(1.2)
self.sagemaker_boto_client.disassociate_trial_component(
TrialName=per_trial["TrialName"], TrialComponentName=self.trial_component_name
)
if "NextToken" in list_trials_response:
next_token = list_trials_response["NextToken"]
else:
break
return self._invoke_api(self._boto_delete_method, self._boto_delete_members)