Skip to content

feat: MLflow Apps for experiment tracking#102

Closed
Christian-kam wants to merge 3 commits intoaws-samples:mainfrom
Christian-kam:main
Closed

feat: MLflow Apps for experiment tracking#102
Christian-kam wants to merge 3 commits intoaws-samples:mainfrom
Christian-kam:main

Conversation

@Christian-kam
Copy link
Copy Markdown
Contributor

Issue #, if available:

Description of changes:
Adding MLflow Apps for experiment tracking and updated the README

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@Christian-kam
Copy link
Copy Markdown
Contributor Author

@ravees

import subprocess
import sys
subprocess.check_call(
[sys.executable, "-m", "pip", "install", "mlflow", "sagemaker-mlflow==0.2.0", "-q"]
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to install MLflow packages when its already present in the requirements.txt

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because I was using TrainingStep from sdk v3 and there is a bug with sagemaker.core.workflow.utilities.get_training_code_hash expects dependencies to be a list, but SourceCode.requirements is passed as a str see PR on the SDK v3

return
try:
import mlflow
mlflow.end_run()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you start the mlflow run with a python loop it automatically terminates the mlflow run.
Thats a standard way to use MLflow and this code design is deviating from MLflow best-practices

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack


# MLflow child run for evaluation
from mlflow_helper import setup_mlflow, end_mlflow
mlflow_enabled = setup_mlflow("EvaluateAbaloneModel")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping in line with MLflow best practices: You need to set the experiment and for parent and child run chaining, pass the parent run when calling the child run.
See a similar example here which can be adopted for new version.

    mlflow.set_tracking_uri(tracking_server_arn)
    mlflow.set_experiment(experiment_name)
    with mlflow.start_run(run_name=run_name) as run:
        run_id = run.info.run_id
        with mlflow.start_run(run_name="DataPreprocessing", nested=True):

Copy link
Copy Markdown
Contributor Author

@Christian-kam Christian-kam Feb 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ack. The approach that you are referring to, works best with @step decorator way of creating pipeline since Data flows between steps can be directly return as values (not S3 properties). I have rewritten the example to use the @step decorator approach and submitted a new PR feat: MLflow Apps steps for experiment tracking

@Christian-kam
Copy link
Copy Markdown
Contributor Author

Closing current PR to work from #103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants