Skip to content

Commit

Permalink
refactor(egen): modified code to delete locally created file, code to…
Browse files Browse the repository at this point in the history
… delete custom job
  • Loading branch information
sumanvita-springml committed Jul 4, 2024
1 parent 39d2d6c commit 09c5007
Showing 1 changed file with 14 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
},
"outputs": [],
"source": [
"# Copyright 2022 Google LLC\n",
"# Copyright 2024 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
Expand Down Expand Up @@ -874,23 +874,30 @@
},
"outputs": [],
"source": [
"delete_tensorboard = True\n",
"delete_bucket = False\n",
"\n",
"# Delete Files & Folders generated\n",
"os.rmdir(PYTHON_PACKAGE_APPLICATION_DIR)\n",
"\n",
"# Delete docker repository.\n",
"! gcloud artifacts repositories delete $DOCKER_REPOSITORY --project {PROJECT_ID} --location {LOCATION} --quiet\n",
"\n",
"# delete training job\n",
"try:\n",
" job.delete()\n",
"except Exception as e:\n",
" print(e)\n",
"\n",
"# delete tensorboard instance\n",
"delete_tensorboard = True\n",
"if delete_tensorboard:\n",
" tensorboard.delete()\n",
"\n",
"# delete custom job\n",
"custom_job = f\"{JOB_NAME}-custom-job\"\n",
"custom_job_to_delete = aiplatform.CustomJob.list(filter=f\"display_name={custom_job}\")[0]\n",
"custom_job_to_delete.delete()\n",
"\n",
"# Delete locally generated files and folders\n",
"! rm -rf {PYTHON_PACKAGE_APPLICATION_DIR} Dockerfile\n",
"\n",
"# delete cloud storage bucket\n",
"delete_bucket = False # set True for deletion\n",
"if delete_bucket:\n",
" ! gsutil -m rm -r $BUCKET_URI"
]
Expand Down

0 comments on commit 09c5007

Please sign in to comment.