Skip to content

Commit 58443a3

Browse files
authored
set studio default kernel and add script to clean up resources at the end (#1050)
1 parent 2281f2e commit 58443a3

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

aws_sagemaker_studio/getting_started/xgboost_customer_churn.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ def parse_args():
2525
parser.add_argument("--num_round", type=int, default=50)
2626
parser.add_argument("--smdebug_path", type=str, default=None)
2727
parser.add_argument("--smdebug_frequency", type=int, default=1)
28-
parser.add_argument("--smdebug_collections", type=str, default=None)
28+
parser.add_argument("--smdebug_collections", type=str, default='metrics')
2929
parser.add_argument("--output_uri", type=str, default="/opt/ml/output/tensors",
3030
help="S3 URI of the bucket where tensor data will be stored.")
3131

aws_sagemaker_studio/getting_started/xgboost_customer_churn_studio.ipynb

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,9 @@
843843
"source": [
844844
"### (Optional) Clean-up\n",
845845
"\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."
847849
]
848850
},
849851
{
@@ -853,16 +855,33 @@
853855
"outputs": [],
854856
"source": [
855857
"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)"
857876
]
858877
}
859878
],
860879
"metadata": {
861880
"celltoolbar": "Tags",
862881
"kernelspec": {
863-
"display_name": "Python 3",
882+
"display_name": "Python 3 (Data Science)",
864883
"language": "python",
865-
"name": "python3"
884+
"name": "python3__SAGEMAKER_INTERNAL__arn:aws:sagemaker:us-east-2:429704687514:environment/datascience"
866885
},
867886
"language_info": {
868887
"codemirror_mode": {
@@ -874,7 +893,7 @@
874893
"name": "python",
875894
"nbconvert_exporter": "python",
876895
"pygments_lexer": "ipython3",
877-
"version": "3.7.3"
896+
"version": "3.7.6"
878897
},
879898
"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."
880899
},

0 commit comments

Comments
 (0)