Да, вы можете использовать MlffowClient APIs
, чтобы получить эксперимент и запустить информацию. Он возвращает структуры данных MLflow в виде словарей, и вы перебираете его, чтобы извлечь то, что вам нужно в вашем listcomp. Вот пример:
def print_experiment_details(experiment_id, run_id):
"""
Method to print experiment run info and a specific run details
:param experiment_id: MLflow experiment ID
:param run_id: MLflow run ID within an experiment
:return: none
"""
print("Finished MLflow Run with run_id {} and experiment_id {}".format(run_id, experiment_id))
# Use MlflowClient API to list experiments and run info
client = MlflowClient()
print("=" * 80)
# Get a list of all experiments
print("List of all Experiments")
print("=" * 80)
[print(pprint.pprint(dict(exp), indent=4))
for exp in client.list_experiments()]
print("=" * 80)
print(f"List Run info for run_id={run_id}")
print(pprint.pprint(dict(mlflow.get_run(run_id))))
Это выводит:
Running local model registry=sqlite:///mlruns.db
Finished MLflow Run with run_id 3f3b827dd6814649a2f84ebae09b26c6 and experiment_id 0
================================================================================
List of all Experiments
================================================================================
{ 'artifact_location': './mlruns/0',
'experiment_id': '0',
'lifecycle_stage': 'active',
'name': 'ODSC_TUTORIALS',
'tags': { 'mlflow.note.content': 'This is experiment for getting started '
'with MLflow ...'}}
None
================================================================================
List Run info for run_id=3f3b827dd6814649a2f84ebae09b26c6
{'data': <RunData: metrics={'metric_1': 0.9236238251076615,
'metric_2': 1.6732389715754346,
'metric_3': 2.249979396736294}, params={'n_estimators': '3', 'random_state': '42'}, tags={'mlflow.log-model.history': '[{"run_id": "3f3b827dd6814649a2f84ebae09b26c6", '
'"artifact_path": "sklearn-model", '
'"utc_time_created": "2020-03-18 '
'22:25:33.083332", "flavors": {"python_function": '
'{"loader_module": "mlflow.sklearn", '
'"python_version": "3.7.5", "data": "model.pkl", '
'"env": "conda.yaml"}, "sklearn": '
'{"pickled_model": "model.pkl", '
'"sklearn_version": "0.22.2.post1", '
'"serialization_format": "cloudpickle"}}}]',
'mlflow.note.content': 'This Run is for getting started with MLflow ...',
'mlflow.runName': 'LOCAL_REGISTRY',
'mlflow.source.git.commit': '0a3c6a3739deab77631318eca7fb9690b6dbad66',
'mlflow.source.name': '/Users/julesdamji/gits/tutorials/mlflow/labs/00_get_started.py',
'mlflow.source.type': 'LOCAL',
'mlflow.user': 'julesdamji'}>,
'info': <RunInfo: artifact_uri='./mlruns/0/3f3b827dd6814649a2f84ebae09b26c6/artifacts', end_time=1584570333841, experiment_id='0', lifecycle_stage='active', run_id='3f3b827dd6814649a2f84ebae09b26c6', run_uuid='3f3b827dd6814649a2f84ebae09b26c6', start_time=1584570332914, status='FINISHED', user_id='julesdamji'>}
Вы можете получить полный код здесь
Надеюсь, что это поможет.