Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mlflow-cleanup
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dasharatha.vamshi
mlflow-cleanup
Commits
51465ead
Commit
51465ead
authored
Mar 22, 2023
by
dasharatha.vamshi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
final
parent
5f5eb49e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
19 deletions
+16
-19
config.env
config.env
+2
-2
scripts/core/mlflow_util.py
scripts/core/mlflow_util.py
+14
-17
No files found.
config.env
View file @
51465ead
...
@@ -5,5 +5,5 @@ AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=azrml
...
@@ -5,5 +5,5 @@ AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;AccountName=azrml
AZURE_STORAGE_ACCESS_KEY=tDGOKfiZ2svfoMvVmS0Fbpf0FTHfTq4wKYuDX7cAxlhve/3991QuzdvJHm9vWc+lo6mtC+x9yPSghWNR4+gacg==
AZURE_STORAGE_ACCESS_KEY=tDGOKfiZ2svfoMvVmS0Fbpf0FTHfTq4wKYuDX7cAxlhve/3991QuzdvJHm9vWc+lo6mtC+x9yPSghWNR4+gacg==
EXPERIMENT_NAME=Golden Batch Models Test
EXPERIMENT_NAME=Golden Batch Models Test
RUN_NAME=r5-golden-batch-test
RUN_NAME=r5-golden-batch-test
MODEL_NAME=r5_model
MODEL_NAME=r5_model/model.pkl
TOTAL_MODELS_NEEDED=2
TOTAL_MODELS_NEEDED=1
\ No newline at end of file
\ No newline at end of file
scripts/core/mlflow_util.py
View file @
51465ead
...
@@ -20,14 +20,23 @@ mlflow.set_registry_uri(mlflow_tracking_uri)
...
@@ -20,14 +20,23 @@ mlflow.set_registry_uri(mlflow_tracking_uri)
client
=
mlflow
.
tracking
.
MlflowClient
()
client
=
mlflow
.
tracking
.
MlflowClient
()
class
MlFlowUtil
:
class
MlflowCleanUp
:
def
__init__
(
self
,
experiment_name
,
parent_run_name
,
model_save_name
):
self
.
experiment_name
=
experiment_name
self
.
parent_run_name
=
parent_run_name
self
.
model_save_name
=
model_save_name
self
.
total_models_needed
=
int
(
MlflowMetaData
.
TOTAL_MODELS_NEEDED
)
self
.
model_name
=
MODEL_NAME
self
.
model_history_key
=
'tags.mlflow.log-model.history'
self
.
model_parent_run_id_key
=
'tags.mlflow.parentRunId'
@
staticmethod
@
staticmethod
def
delete_artifact
(
run_id
,
parent_run_name
,
artifact_uri
,
file_path
,
model_name
):
def
delete_artifact
(
run_id
,
parent_run_name
,
artifact_uri
,
file_path
):
logger
.
info
(
f
"Deleting artifact for {run_id} under {parent_run_name}"
)
logger
.
info
(
f
"Deleting artifact for {run_id} under {parent_run_name}"
)
container_name
=
artifact_uri
.
split
(
"//"
)[
-
1
]
.
split
(
'@'
)[
0
]
container_name
=
artifact_uri
.
split
(
"//"
)[
-
1
]
.
split
(
'@'
)[
0
]
mlflow_name
=
artifact_uri
.
split
(
"//"
)[
-
1
]
.
split
(
'@'
)[
-
1
]
.
split
(
'/'
)[
1
]
mlflow_name
=
artifact_uri
.
split
(
"//"
)[
-
1
]
.
split
(
'@'
)[
-
1
]
.
split
(
'/'
)[
1
]
mlflow_id
=
artifact_uri
.
split
(
"//"
)[
-
1
]
.
split
(
'@'
)[
-
1
]
.
split
(
'/'
)[
2
]
mlflow_id
=
artifact_uri
.
split
(
"//"
)[
-
1
]
.
split
(
'@'
)[
-
1
]
.
split
(
'/'
)[
2
]
path
=
f
'{mlflow_name}/{mlflow_id}/{run_id}/artifacts/{file_path}
/{model_name}
'
path
=
f
'{mlflow_name}/{mlflow_id}/{run_id}/artifacts/{file_path}'
logger
.
info
(
f
'Deleting artifact from path: {path}'
)
logger
.
info
(
f
'Deleting artifact from path: {path}'
)
blob_service_client
=
BlobServiceClient
.
from_connection_string
(
MlflowMetaData
.
AZURE_STORAGE_CONNECTION_STRING
)
blob_service_client
=
BlobServiceClient
.
from_connection_string
(
MlflowMetaData
.
AZURE_STORAGE_CONNECTION_STRING
)
container_client
=
blob_service_client
.
get_container_client
(
container_name
)
container_client
=
blob_service_client
.
get_container_client
(
container_name
)
...
@@ -39,18 +48,6 @@ class MlFlowUtil:
...
@@ -39,18 +48,6 @@ class MlFlowUtil:
else
:
else
:
logger
.
info
(
f
"The blob {path} does not exist, which means its already deleted"
)
logger
.
info
(
f
"The blob {path} does not exist, which means its already deleted"
)
class
MlflowCleanUp
:
def
__init__
(
self
,
experiment_name
,
parent_run_name
,
model_save_name
):
self
.
experiment_name
=
experiment_name
self
.
parent_run_name
=
parent_run_name
self
.
model_save_name
=
model_save_name
self
.
_mfu_
=
MlFlowUtil
()
self
.
total_models_needed
=
int
(
MlflowMetaData
.
TOTAL_MODELS_NEEDED
)
self
.
model_name
=
MODEL_NAME
self
.
model_history_key
=
'tags.mlflow.log-model.history'
self
.
model_parent_run_id_key
=
'tags.mlflow.parentRunId'
def
check_experiment
(
self
):
def
check_experiment
(
self
):
experiment_info
=
mlflow
.
get_experiment_by_name
(
self
.
experiment_name
)
experiment_info
=
mlflow
.
get_experiment_by_name
(
self
.
experiment_name
)
if
experiment_info
is
None
:
if
experiment_info
is
None
:
...
@@ -92,8 +89,8 @@ class MlflowCleanUp:
...
@@ -92,8 +89,8 @@ class MlflowCleanUp:
for
record
in
all_records
:
for
record
in
all_records
:
run_id
=
record
[
'run_id'
]
run_id
=
record
[
'run_id'
]
artifact_uri
=
record
[
'artifact_uri'
]
artifact_uri
=
record
[
'artifact_uri'
]
self
.
_mfu_
.
delete_artifact
(
run_id
,
run_name_mapping
[
parent_run_id
],
artifact_uri
,
self
.
delete_artifact
(
run_id
,
run_name_mapping
[
parent_run_id
],
artifact_uri
,
self
.
model_save_name
,
self
.
model
_name
)
self
.
model_save
_name
)
else
:
else
:
logger
.
info
(
f
'No records to cleanup for Run {run_name_mapping[parent_run_id]}'
)
logger
.
info
(
f
'No records to cleanup for Run {run_name_mapping[parent_run_id]}'
)
else
:
else
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment