def test_from_dict_to_dict_idempotent(mocker, kedro_project_with_mlflow_conf): mocker.patch("mlflow.tracking.MlflowClient", return_value=None) mocker.patch( "kedro_mlflow.framework.context.config.KedroMlflowConfig._get_or_create_experiment", return_value=None, ) config = KedroMlflowConfig(project_path=kedro_project_with_mlflow_conf) original_config_dict = config.to_dict() # modify config config.from_dict(original_config_dict) assert config.to_dict() == original_config_dict
def test_kedro_mlflow_config_init(tmp_path): # create a ".kedro.yml" file to identify "tmp_path" as the root of a kedro project (tmp_path / ".kedro.yml").write_text( yaml.dump(dict(context_path="fake/path"))) config = KedroMlflowConfig(project_path=tmp_path) assert config.to_dict() == dict( mlflow_tracking_uri=(tmp_path / "mlruns").as_uri(), experiments=KedroMlflowConfig.EXPERIMENT_OPTS, run=KedroMlflowConfig.RUN_OPTS, ui=KedroMlflowConfig.UI_OPTS, hooks=dict(node=KedroMlflowConfig.NODE_HOOK_OPTS), )
def test_kedro_mlflow_config_init(kedro_project_with_mlflow_conf): # kedro_project_with_mlflow_conf is a global fixture in conftest config = KedroMlflowConfig(project_path=kedro_project_with_mlflow_conf) assert config.to_dict() == dict( mlflow_tracking_uri=(kedro_project_with_mlflow_conf / "mlruns").as_uri(), credentials=None, disable_tracking=KedroMlflowConfig.DISABLE_TRACKING_OPTS, experiments=KedroMlflowConfig.EXPERIMENT_OPTS, run=KedroMlflowConfig.RUN_OPTS, ui=KedroMlflowConfig.UI_OPTS, hooks=dict(node=KedroMlflowConfig.NODE_HOOK_OPTS), )