Skip to content
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

tag nested runs with parent run ID #4197

Merged
merged 1 commit into from Oct 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion mlflow/R/mlflow/R/tracking-runs.R
Expand Up @@ -599,6 +599,12 @@ mlflow_get_run_context.default <- function(client, experiment_id, ...) {
tags[[MLFLOW_TAGS$MLFLOW_SOURCE_NAME]] <- get_source_name()
tags[[MLFLOW_TAGS$MLFLOW_SOURCE_VERSION]] <- get_source_version()
tags[[MLFLOW_TAGS$MLFLOW_SOURCE_TYPE]] <- MLFLOW_SOURCE_TYPE$LOCAL
parent_run_id <- mlflow_get_active_run_id()
if (!is.null(parent_run_id)) {
# create a tag containing the parent run ID so that MLflow UI can display
# nested runs properly
tags[[MLFLOW_TAGS$MLFLOW_PARENT_RUN_ID]] <- parent_run_id
}
list(
client = client,
tags = tags,
Expand Down Expand Up @@ -649,5 +655,6 @@ MLFLOW_TAGS <- list(
MLFLOW_USER = "mlflow.user",
MLFLOW_SOURCE_NAME = "mlflow.source.name",
MLFLOW_SOURCE_VERSION = "mlflow.source.version",
MLFLOW_SOURCE_TYPE = "mlflow.source.type"
MLFLOW_SOURCE_TYPE = "mlflow.source.type",
MLFLOW_PARENT_RUN_ID = "mlflow.parentRunId"
)
7 changes: 7 additions & 0 deletions mlflow/R/mlflow/tests/testthat/test-tracking-runs.R
Expand Up @@ -77,6 +77,13 @@ test_that("mlflow_start_run()/mlflow_end_run() works properly with nested runs",
expect_equal(mlflow:::mlflow_get_active_run_id(), runs[[i]]$run_uuid)
run <- mlflow_end_run(client = client, run_id = runs[[i]]$run_uuid)
expect_identical(run$run_uuid, runs[[i]]$run_uuid)
if (i > 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you also test that parentRunId doesn't exist for the first (non-nested) run?

tags <- run$tags[[1]]
expect_equal(
tags[tags$key == "mlflow.parentRunId",]$value,
runs[[i - 1]]$run_uuid
)
}
}
expect_null(mlflow:::mlflow_get_active_run_id())
})
Expand Down