-
Notifications
You must be signed in to change notification settings - Fork 739
1014-mlflow-handler-tutorial #1019
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1014-mlflow-handler-tutorial #1019
Conversation
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
Thanks @binliunls for creating the PR! We received the request to simplify usage of experiment management to a few lines of code. Just for brainstorming, is it possible to hide the details as much as possible in the bundle config files, so that the tutorial can be something like: # we provide a user_config_file.json bundle config in this folder
parser = ConfigParser()
parser.read_config("user_config_file.json")
trainer = parser.get_parsed_content("train#trainer")
MLFlowHandler(...).attach(trainer)
trainer.run() |
View / edit / reply to this conversation on ReviewNB Nic-Ma commented on 2022-10-31T11:24:27Z Line #1. def render(image, label, prediction, show=False, out_file=None, colormap="spring"): I didn't see where you use this function?
Thanks.
|
Hi @binliunls @mingxin-zheng , I feel lost in this tutorial, it doesn't clearly show how easy to use the
What do you think? Thanks in advance. |
Thanks @Nic-Ma for the suggestions. As you mention in the last point, the handlers should be added into the bundle config too. |
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
for more information, see https://pre-commit.ci
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick update, put some comments inline.
-
Your current file names are not clear to me, I would suggest to change the 2 file names to:
bundle_integrate_mlflow.md
workflow_integrate_mlflow.ipynb
-
And put a README.md file in this folder to describe all the files in it.
-
And please remove the training log in the notebook.
-
I would suggest to change the first part description of the notebook to:
This tutorial shows how to easily enable the
MLFlowbased experiment management in the MONAI workflow. Currently, we provide the
MLFlowHandlerto add the experiment management in a MONAI workflow training program with just 1 or 2 lines of code, by adding mlflow handler to the handler list: ...
-
And no need to say the
default_experiment
things, instead, I would suggest to:
It supports rich parameters to control the experiment tracking logic, ...
Thanks.
I tried to run the tutorial and the code executed smoothly. But I am not finding the experiment log on localhost:5000. Did you see similar issue @binliunls ? I have tried both docker and a local linux machine with Conda. Update: my issue seems fixed after the ui process is killed manually as described here |
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
…liunls/tutorials into 1014-mlflow-handler-tutorial
for more information, see https://pre-commit.ci
I did some quick experiment with the current status of MLFlowHandler. The usage with bundle can be simplified and demonstrated in the following lines. The main idea is to tell users that they can override the mlflow handler we're working on in CLI and Pythonic way. P.S. By using this code, we will drop the handlers defined in the original import os
from monai.apps import download_and_extract
from monai.bundle import run
root_dir = os.environ.get("MONAI_DATA_DIRECTORY")
resource = "https://msd-for-monai.s3-us-west-2.amazonaws.com/Task09_Spleen.tar"
md5 = "410d4a301da4e5b2f6f86ec3ddba524e"
compressed_file = os.path.join(root_dir, "Task09_Spleen.tar")
data_dir = os.path.join(root_dir, "Task09_Spleen")
if not os.path.exists(data_dir):
download_and_extract(resource, compressed_file, root_dir, md5)
print(data_dir)
# To enable experiment management, one can override the existing trainer handler in the pythonic way:
handler_override = {
"train#handlers":
{
"_target_": "MLFlowHandler",
"experiment_name": "spleen_seg_ignite",
"output_transform": "$monai.handlers.from_engine(['loss'], first=True)"
}
}
run(
runner_id="training",
config_file="./bundle/spleen_segmentation/configs/train.json",
bundle_root=".",
dataset_dir=data_dir,
**handler_override
)
"""
Alternatively, you can also use the command line to override the existing handler, by appending
--train#trainer#train_handlers '$@train#handlers + [{"_target_": "MLFlowHandler","experiment_name":"spleen_seg_ignite","output_transform": "$monai.handlers.from_engine([\"loss\"],first=True)"}]'
So the entire command looks like:
python -m monai.bundle run training \
--config_file ./bundle/spleen_segmentation/configs/train.json \
--bundle_root . \
--dataset_dir /workspace/data/Task09_Spleen \
--train#trainer#train_handlers '$@train#handlers + [{"_target_": "MLFlowHandler","experiment_name":"spleen_seg_ignite","output_transform": "$monai.handlers.from_engine([\"loss\"],first=True)"}]'
""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the previous comments said: (1) Please remove the training log, (2) Please also add the MLFlowHandler
to track the metrics during training.
Thanks.
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
for more information, see https://pre-commit.ci
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
…liunls/tutorials into 1014-mlflow-handler-tutorial
Signed-off-by: binliu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the quick update.
Looks good to me now.
@wyli Do you have any other comments?
Thanks.
View / edit / reply to this conversation on ReviewNB wyli commented on 2022-12-12T10:47:18Z "only run 5 epochs" it seems the commands set max_epochs to 10? |
View / edit / reply to this conversation on ReviewNB wyli commented on 2022-12-12T10:47:19Z the installation command is not consistent with the description |
View / edit / reply to this conversation on ReviewNB wyli commented on 2022-12-12T10:47:20Z perhaps provide a list of attributes that are tracked? it's unclear what the |
Signed-off-by: binliu <[email protected]>
Signed-off-by: binliu <[email protected]>
Hi @wyli , Thanks, |
Fixes Project-MONAI#1014 . ### Description A tutorial about how to use mlflow handler in monai engine based training process by adding one line in code. ### Checks <!--- Put an `x` in all the boxes that apply, and remove the not applicable items --> - [ ] Notebook runs automatically `./runner [-p <regex_pattern>]` Signed-off-by: binliu <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fixes #1014 .
Description
A tutorial about how to use mlflow handler in monai engine based training process by adding one line in code.
Checks
./runner [-p <regex_pattern>]