From 254a52d37a49bf8ed53bf28a0eab02f14119f706 Mon Sep 17 00:00:00 2001 From: Eric Alt Date: Fri, 9 Jan 2026 16:34:23 -0800 Subject: [PATCH 01/31] Create resolve mlflow config --- simplexity/structured_configs/mlflow.py | 36 +++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/simplexity/structured_configs/mlflow.py b/simplexity/structured_configs/mlflow.py index f3b88403..e478cabf 100644 --- a/simplexity/structured_configs/mlflow.py +++ b/simplexity/structured_configs/mlflow.py @@ -11,10 +11,12 @@ from dataclasses import dataclass +from mlflow import MlflowClient from omegaconf import DictConfig from simplexity.structured_configs.validation import validate_bool, validate_nonempty_str, validate_uri from simplexity.utils.config_utils import dynamic_resolve +from simplexity.utils.mlflow_utils import get_experiment, get_run, resolve_registry_uri @dataclass @@ -53,6 +55,40 @@ def validate_mlflow_config(cfg: DictConfig) -> None: validate_uri(registry_uri, "MLFlowConfig.registry_uri", is_none_allowed=True) +@dynamic_resolve +def resolve_mlflow_config(cfg: DictConfig) -> None: + """Resolve a MLFlowConfig.""" + # Resolve registry uri + tracking_uri: str | None = cfg.get("tracking_uri") + registry_uri: str | None = cfg.get("registry_uri") + downgrade_unity_catalog: bool = cfg.get("downgrade_unity_catalog", True) + cfg.registry_uri = resolve_registry_uri( + registry_uri=registry_uri, + tracking_uri=tracking_uri, + downgrade_unity_catalog=downgrade_unity_catalog, + ) + + client = MlflowClient(tracking_uri=tracking_uri, registry_uri=cfg.registry_uri) + + # Resolve experiment id and name + experiment_id: str | None = cfg.get("experiment_id") + experiment_name: str | None = cfg.get("experiment_name") + experiment = get_experiment(experiment_id=experiment_id, experiment_name=experiment_name, client=client) + if experiment is None: + raise ValueError(f"Experiment not found for id: {experiment_id} and name: {experiment_name}") + cfg.experiment_id = experiment.experiment_id + cfg.experiment_name = experiment.name + + # Resolve run id and name + run_id: str | None = cfg.get("run_id") + run_name: str | None = cfg.get("run_name") + run = get_run(run_id=run_id, run_name=run_name, experiment_id=cfg.experiment_id, client=client) + if run is None: + raise ValueError(f"Run not found for id: {run_id} and name: {run_name}") + cfg.run_id = run.info.run_id + cfg.run_name = run.info.run_name + + @dynamic_resolve def update_mlflow_config(cfg: DictConfig, updated_cfg: DictConfig) -> None: """Update a MLFlowConfig with the updated configuration.""" From c082130abcd40e1ca5bf92517b0ed4f9fcaa18d5 Mon Sep 17 00:00:00 2001 From: Eric Alt Date: Fri, 9 Jan 2026 16:34:48 -0800 Subject: [PATCH 02/31] Create mlflow defaults --- simplexity/run_management/run_management.py | 2 + .../structured_configs/mlflow_defaults.py | 182 ++++++ tests/run_management/test_mlflow_defaults.py | 516 ++++++++++++++++++ 3 files changed, 700 insertions(+) create mode 100644 simplexity/structured_configs/mlflow_defaults.py create mode 100644 tests/run_management/test_mlflow_defaults.py diff --git a/simplexity/run_management/run_management.py b/simplexity/run_management/run_management.py index ed75a730..6f1c7764 100644 --- a/simplexity/run_management/run_management.py +++ b/simplexity/run_management/run_management.py @@ -64,6 +64,7 @@ validate_metric_tracker_config, ) from simplexity.structured_configs.mlflow import update_mlflow_config +from simplexity.structured_configs.mlflow_defaults import load_mlflow_defaults from simplexity.structured_configs.optimizer import ( is_optimizer_target, is_pytorch_optimizer_config, @@ -633,6 +634,7 @@ def decorator(fn: Callable[..., Any]) -> Callable[..., Any]: def wrapper(*args: Any, **kwargs: Any) -> Any: try: cfg = get_config(args, kwargs) + cfg = load_mlflow_defaults(cfg) validate_base_config(cfg) resolve_base_config(cfg, strict=strict) with _setup_device(cfg), _setup_mlflow(cfg): diff --git a/simplexity/structured_configs/mlflow_defaults.py b/simplexity/structured_configs/mlflow_defaults.py new file mode 100644 index 00000000..9b04ab78 --- /dev/null +++ b/simplexity/structured_configs/mlflow_defaults.py @@ -0,0 +1,182 @@ +"""Config utilities.""" + +# pylint: disable=all +# Temporarily disable all pylint checkers during AST traversal to prevent crash. +# The imports checker crashes when resolving simplexity package imports due to a bug +# in pylint/astroid: https://github.com/pylint-dev/pylint/issues/10185 +# pylint: enable=all +# Re-enable all pylint checkers for the checking phase. This allows other checks +# (code quality, style, undefined names, etc.) to run normally while bypassing +# the problematic imports checker that would crash during AST traversal. + +import re +import tempfile +from typing import Any, NamedTuple, cast + +from mlflow import MlflowClient +from omegaconf import DictConfig, ListConfig, OmegaConf + +from simplexity.exceptions import ConfigValidationError +from simplexity.logger import SIMPLEXITY_LOGGER +from simplexity.structured_configs.mlflow import resolve_mlflow_config, validate_mlflow_config +from simplexity.utils.config_utils import dynamic_resolve + +# TARGET(@PACKAGE)? +# [optional|override]? TARGET(@PACKAGE)? : OPTION +FLAGS_STR = r"(?P(?:(?:optional|override)\s+)*)" +MLFLOW_CONFIG_ENTRY_STR = r"(?P[\w\.]+)(?:@(?P[\w\.]+))?" +OPTION_STR = r"(?P