|
843 | 843 | "source": [
|
844 | 844 | "### (Optional) Clean-up\n",
|
845 | 845 | "\n",
|
846 |
| - "If you're ready to be done with this notebook, please run the cell below. This will remove the hosted endpoint you created and avoid any charges from a stray instance being left on." |
| 846 | + "If you're ready to be done with this notebook, please run the cell below. This will remove the hosted endpoint you created and avoid any charges from a stray instance being left on. It will also clean up all artifacts related to the experiments. \n", |
| 847 | + "\n", |
| 848 | + "You may also want to delete artifacts stored in the associated s3 bucket used in this notebook by going to the S3 console and finding the bucket `sagemaker-studio-<region-name>-<account-name>` and deleting the files associated with this notebook." |
847 | 849 | ]
|
848 | 850 | },
|
849 | 851 | {
|
|
853 | 855 | "outputs": [],
|
854 | 856 | "source": [
|
855 | 857 | "sess.delete_monitoring_schedule(mon_schedule_name)\n",
|
856 |
| - "sess.delete_endpoint(xgb_predictor.endpoint)" |
| 858 | + "sess.delete_endpoint(xgb_predictor.endpoint)\n", |
| 859 | + "def cleanup(experiment):\n", |
| 860 | + " '''Clean up everything in the given experiment object'''\n", |
| 861 | + " for trial_summary in experiment.list_trials():\n", |
| 862 | + " trial = Trial.load(trial_name=trial_summary.trial_name)\n", |
| 863 | + " \n", |
| 864 | + " for trial_comp_summary in trial.list_trial_components():\n", |
| 865 | + " trial_step=TrialComponent.load(trial_component_name=trial_comp_summary.trial_component_name)\n", |
| 866 | + " print('Starting to delete TrialComponent..' + trial_step.trial_component_name)\n", |
| 867 | + " sm.disassociate_trial_component(TrialComponentName=trial_step.trial_component_name, TrialName=trial.trial_name)\n", |
| 868 | + " trial_step.delete()\n", |
| 869 | + " time.sleep(1)\n", |
| 870 | + " \n", |
| 871 | + " trial.delete()\n", |
| 872 | + " \n", |
| 873 | + " experiment.delete()\n", |
| 874 | + "\n", |
| 875 | + "cleanup(customer_churn_experiment)" |
857 | 876 | ]
|
858 | 877 | }
|
859 | 878 | ],
|
860 | 879 | "metadata": {
|
861 | 880 | "celltoolbar": "Tags",
|
862 | 881 | "kernelspec": {
|
863 |
| - "display_name": "Python 3", |
| 882 | + "display_name": "Python 3 (Data Science)", |
864 | 883 | "language": "python",
|
865 |
| - "name": "python3" |
| 884 | + "name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-2:429704687514:environment/datascience" |
866 | 885 | },
|
867 | 886 | "language_info": {
|
868 | 887 | "codemirror_mode": {
|
|
874 | 893 | "name": "python",
|
875 | 894 | "nbconvert_exporter": "python",
|
876 | 895 | "pygments_lexer": "ipython3",
|
877 |
| - "version": "3.7.3" |
| 896 | + "version": "3.7.6" |
878 | 897 | },
|
879 | 898 | "notice": "Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. Licensed under the Apache License, Version 2.0 (the \"License\"). You may not use this file except in compliance with the License. A copy of the License is located at http://aws.amazon.com/apache2.0/ or in the \"license\" file accompanying this file. This file is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License."
|
880 | 899 | },
|
|
0 commit comments