def delete_all()

in src/smexperiments/experiment.py [0:0]


    def delete_all(self, action):
        """
        Force to delete the experiment and associated trials, trial components under the experiment.

        Args:
            action (str): pass in string '--force' to confirm recursively delete all the experiments, trials,
            and trial components.
        """
        if action != "--force":
            raise ValueError(
                "Must confirm with string '--force' in order to delete the experiment and "
                "associated trials, trial components."
            )

        delete_attempt_count = 0
        last_exception = None
        while True:
            if delete_attempt_count == self.MAX_DELETE_ALL_ATTEMPTS:
                raise Exception("Failed to delete, please try again.") from last_exception
            try:
                for trial_summary in self.list_trials():
                    t = trial.Trial.load(
                        sagemaker_boto_client=self.sagemaker_boto_client, trial_name=trial_summary.trial_name
                    )
                    for trial_component_summary in t.list_trial_components():
                        tc = trial_component.TrialComponent.load(
                            sagemaker_boto_client=self.sagemaker_boto_client,
                            trial_component_name=trial_component_summary.trial_component_name,
                        )
                        tc.delete(force_disassociate=True)
                        # to prevent throttling
                        time.sleep(1.2)
                    t.delete()
                    # to prevent throttling
                    time.sleep(1.2)
                self.delete()
                break
            except Exception as ex:
                last_exception = ex
            finally:
                delete_attempt_count = delete_attempt_count + 1