-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Integrate mlflow in niceml (#79)
## 📥 Pull Request Description Integrated mlflow in the train and eval job. ## 👀 Affected Areas Affects code and tests. ## 📝 Checklist Please make sure you've completed the following tasks before submitting this pull request: - [x] Pre-commit hooks were executed - [X] Changes have been reviewed by at least one other developer - [ ] Tests have been added or updated to cover the changes (only necessary if the changes affect the executable code) - [x] All tests ran successfully - [X] All merge conflicts are resolved - [ ] Documentation has been updated to reflect the changes - [ ] Any necessary migrations have been run --------- Co-authored-by: Nils <[email protected]>
- Loading branch information
1 parent
de9605e
commit 23aa7dc
Showing
24 changed files
with
814 additions
and
293 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,3 +296,4 @@ exp_cache | |
cache | ||
image_cache | ||
/tmp/ | ||
/mlflow-logs/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ defaults: | |
- ops/[email protected]: exptests_default.yaml | ||
# experiment locations | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ defaults: | |
- ops/[email protected]: exptests_default.yaml | ||
# experiment locations | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ defaults: | |
- /ops/[email protected]: exptests_default.yaml | ||
# experiment locations | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ defaults: | |
- /ops/[email protected]: exptests_default.yaml | ||
# experiment locations | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ defaults: | |
- /ops/[email protected]: exptests_default.yaml | ||
# experiment locations | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,8 @@ defaults: | |
# experiment tests | ||
- /ops/[email protected]: exptests_default.yaml | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ defaults: | |
- /ops/[email protected]: exptests_default.yaml | ||
# experiment locations | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,8 @@ defaults: | |
- /ops/[email protected]: exptests_default.yaml | ||
# experiment locations | ||
- shared/locations@globals: exp_locations.yaml | ||
# ressources | ||
- resources/[email protected]: res_mlflow_base.yaml | ||
- _self_ | ||
|
||
hydra: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
mlflow_tracking_uri: ${oc.env:MLFLOW_TRACKING_URI,mlflow-logs} | ||
experiment_name: ${globals.exp_name} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
"""Contains the default keys to remove from the config file when saving.""" | ||
|
||
DEFAULT_REMOVE_CONFIG_KEYS = ["credentials"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,36 @@ | ||
"""module for writing config files""" | ||
from os.path import join | ||
from typing import List | ||
|
||
import mlflow | ||
|
||
from niceml.experiments.experimentcontext import ExperimentContext | ||
from niceml.experiments.expfilenames import ExperimentFilenames | ||
|
||
|
||
def write_op_config(op_conf: dict, exp_context: ExperimentContext, op_name: str): | ||
def write_op_config( | ||
op_conf: dict, | ||
exp_context: ExperimentContext, | ||
op_name: str, | ||
remove_key_list: List[str], | ||
): | ||
"""Writes a dict as yamls. With one file per key""" | ||
for key, values in op_conf.items(): | ||
removed_values = remove_key_recursive(values, remove_key_list) | ||
outfile = join(ExperimentFilenames.CONFIGS_FOLDER, op_name, f"{key}.yaml") | ||
exp_context.write_yaml(values, outfile) | ||
mlflow.log_dict(removed_values, outfile) | ||
exp_context.write_yaml(removed_values, outfile) | ||
|
||
|
||
def remove_key_recursive(data, key_list: List[str]): | ||
"""Removes keys from a dict recursively. This is used for credentials.""" | ||
if isinstance(data, list): # handle lists | ||
return [remove_key_recursive(item, key_list) for item in data] | ||
elif isinstance(data, dict): # handle dictionaries | ||
return { | ||
k: remove_key_recursive(v, key_list) | ||
for k, v in data.items() | ||
if k not in key_list | ||
} | ||
else: | ||
return data |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.