genesis-flow 1.0.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- genesis_flow-1.0.0.dist-info/METADATA +822 -0
- genesis_flow-1.0.0.dist-info/RECORD +645 -0
- genesis_flow-1.0.0.dist-info/WHEEL +5 -0
- genesis_flow-1.0.0.dist-info/entry_points.txt +19 -0
- genesis_flow-1.0.0.dist-info/licenses/LICENSE.txt +202 -0
- genesis_flow-1.0.0.dist-info/top_level.txt +1 -0
- mlflow/__init__.py +367 -0
- mlflow/__main__.py +3 -0
- mlflow/ag2/__init__.py +56 -0
- mlflow/ag2/ag2_logger.py +294 -0
- mlflow/anthropic/__init__.py +40 -0
- mlflow/anthropic/autolog.py +129 -0
- mlflow/anthropic/chat.py +144 -0
- mlflow/artifacts/__init__.py +268 -0
- mlflow/autogen/__init__.py +144 -0
- mlflow/autogen/chat.py +142 -0
- mlflow/azure/__init__.py +26 -0
- mlflow/azure/auth_handler.py +257 -0
- mlflow/azure/client.py +319 -0
- mlflow/azure/config.py +120 -0
- mlflow/azure/connection_factory.py +340 -0
- mlflow/azure/exceptions.py +27 -0
- mlflow/azure/stores.py +327 -0
- mlflow/azure/utils.py +183 -0
- mlflow/bedrock/__init__.py +45 -0
- mlflow/bedrock/_autolog.py +202 -0
- mlflow/bedrock/chat.py +122 -0
- mlflow/bedrock/stream.py +160 -0
- mlflow/bedrock/utils.py +43 -0
- mlflow/cli.py +707 -0
- mlflow/client.py +12 -0
- mlflow/config/__init__.py +56 -0
- mlflow/crewai/__init__.py +79 -0
- mlflow/crewai/autolog.py +253 -0
- mlflow/crewai/chat.py +29 -0
- mlflow/data/__init__.py +75 -0
- mlflow/data/artifact_dataset_sources.py +170 -0
- mlflow/data/code_dataset_source.py +40 -0
- mlflow/data/dataset.py +123 -0
- mlflow/data/dataset_registry.py +168 -0
- mlflow/data/dataset_source.py +110 -0
- mlflow/data/dataset_source_registry.py +219 -0
- mlflow/data/delta_dataset_source.py +167 -0
- mlflow/data/digest_utils.py +108 -0
- mlflow/data/evaluation_dataset.py +562 -0
- mlflow/data/filesystem_dataset_source.py +81 -0
- mlflow/data/http_dataset_source.py +145 -0
- mlflow/data/huggingface_dataset.py +258 -0
- mlflow/data/huggingface_dataset_source.py +118 -0
- mlflow/data/meta_dataset.py +104 -0
- mlflow/data/numpy_dataset.py +223 -0
- mlflow/data/pandas_dataset.py +231 -0
- mlflow/data/polars_dataset.py +352 -0
- mlflow/data/pyfunc_dataset_mixin.py +31 -0
- mlflow/data/schema.py +76 -0
- mlflow/data/sources.py +1 -0
- mlflow/data/spark_dataset.py +406 -0
- mlflow/data/spark_dataset_source.py +74 -0
- mlflow/data/spark_delta_utils.py +118 -0
- mlflow/data/tensorflow_dataset.py +350 -0
- mlflow/data/uc_volume_dataset_source.py +81 -0
- mlflow/db.py +27 -0
- mlflow/dspy/__init__.py +17 -0
- mlflow/dspy/autolog.py +197 -0
- mlflow/dspy/callback.py +398 -0
- mlflow/dspy/constant.py +1 -0
- mlflow/dspy/load.py +93 -0
- mlflow/dspy/save.py +393 -0
- mlflow/dspy/util.py +109 -0
- mlflow/dspy/wrapper.py +226 -0
- mlflow/entities/__init__.py +104 -0
- mlflow/entities/_mlflow_object.py +52 -0
- mlflow/entities/assessment.py +545 -0
- mlflow/entities/assessment_error.py +80 -0
- mlflow/entities/assessment_source.py +141 -0
- mlflow/entities/dataset.py +92 -0
- mlflow/entities/dataset_input.py +51 -0
- mlflow/entities/dataset_summary.py +62 -0
- mlflow/entities/document.py +48 -0
- mlflow/entities/experiment.py +109 -0
- mlflow/entities/experiment_tag.py +35 -0
- mlflow/entities/file_info.py +45 -0
- mlflow/entities/input_tag.py +35 -0
- mlflow/entities/lifecycle_stage.py +35 -0
- mlflow/entities/logged_model.py +228 -0
- mlflow/entities/logged_model_input.py +26 -0
- mlflow/entities/logged_model_output.py +32 -0
- mlflow/entities/logged_model_parameter.py +46 -0
- mlflow/entities/logged_model_status.py +74 -0
- mlflow/entities/logged_model_tag.py +33 -0
- mlflow/entities/metric.py +200 -0
- mlflow/entities/model_registry/__init__.py +29 -0
- mlflow/entities/model_registry/_model_registry_entity.py +13 -0
- mlflow/entities/model_registry/model_version.py +243 -0
- mlflow/entities/model_registry/model_version_deployment_job_run_state.py +44 -0
- mlflow/entities/model_registry/model_version_deployment_job_state.py +70 -0
- mlflow/entities/model_registry/model_version_search.py +25 -0
- mlflow/entities/model_registry/model_version_stages.py +25 -0
- mlflow/entities/model_registry/model_version_status.py +35 -0
- mlflow/entities/model_registry/model_version_tag.py +35 -0
- mlflow/entities/model_registry/prompt.py +73 -0
- mlflow/entities/model_registry/prompt_version.py +244 -0
- mlflow/entities/model_registry/registered_model.py +175 -0
- mlflow/entities/model_registry/registered_model_alias.py +35 -0
- mlflow/entities/model_registry/registered_model_deployment_job_state.py +39 -0
- mlflow/entities/model_registry/registered_model_search.py +25 -0
- mlflow/entities/model_registry/registered_model_tag.py +35 -0
- mlflow/entities/multipart_upload.py +74 -0
- mlflow/entities/param.py +49 -0
- mlflow/entities/run.py +97 -0
- mlflow/entities/run_data.py +84 -0
- mlflow/entities/run_info.py +188 -0
- mlflow/entities/run_inputs.py +59 -0
- mlflow/entities/run_outputs.py +43 -0
- mlflow/entities/run_status.py +41 -0
- mlflow/entities/run_tag.py +36 -0
- mlflow/entities/source_type.py +31 -0
- mlflow/entities/span.py +774 -0
- mlflow/entities/span_event.py +96 -0
- mlflow/entities/span_status.py +102 -0
- mlflow/entities/trace.py +317 -0
- mlflow/entities/trace_data.py +71 -0
- mlflow/entities/trace_info.py +220 -0
- mlflow/entities/trace_info_v2.py +162 -0
- mlflow/entities/trace_location.py +173 -0
- mlflow/entities/trace_state.py +39 -0
- mlflow/entities/trace_status.py +68 -0
- mlflow/entities/view_type.py +51 -0
- mlflow/environment_variables.py +866 -0
- mlflow/evaluation/__init__.py +16 -0
- mlflow/evaluation/assessment.py +369 -0
- mlflow/evaluation/evaluation.py +411 -0
- mlflow/evaluation/evaluation_tag.py +61 -0
- mlflow/evaluation/fluent.py +48 -0
- mlflow/evaluation/utils.py +201 -0
- mlflow/exceptions.py +213 -0
- mlflow/experiments.py +140 -0
- mlflow/gemini/__init__.py +81 -0
- mlflow/gemini/autolog.py +186 -0
- mlflow/gemini/chat.py +261 -0
- mlflow/genai/__init__.py +71 -0
- mlflow/genai/datasets/__init__.py +67 -0
- mlflow/genai/datasets/evaluation_dataset.py +131 -0
- mlflow/genai/evaluation/__init__.py +3 -0
- mlflow/genai/evaluation/base.py +411 -0
- mlflow/genai/evaluation/constant.py +23 -0
- mlflow/genai/evaluation/utils.py +244 -0
- mlflow/genai/judges/__init__.py +21 -0
- mlflow/genai/judges/databricks.py +404 -0
- mlflow/genai/label_schemas/__init__.py +153 -0
- mlflow/genai/label_schemas/label_schemas.py +209 -0
- mlflow/genai/labeling/__init__.py +159 -0
- mlflow/genai/labeling/labeling.py +250 -0
- mlflow/genai/optimize/__init__.py +13 -0
- mlflow/genai/optimize/base.py +198 -0
- mlflow/genai/optimize/optimizers/__init__.py +4 -0
- mlflow/genai/optimize/optimizers/base_optimizer.py +38 -0
- mlflow/genai/optimize/optimizers/dspy_mipro_optimizer.py +221 -0
- mlflow/genai/optimize/optimizers/dspy_optimizer.py +91 -0
- mlflow/genai/optimize/optimizers/utils/dspy_mipro_callback.py +76 -0
- mlflow/genai/optimize/optimizers/utils/dspy_mipro_utils.py +18 -0
- mlflow/genai/optimize/types.py +75 -0
- mlflow/genai/optimize/util.py +30 -0
- mlflow/genai/prompts/__init__.py +206 -0
- mlflow/genai/scheduled_scorers.py +431 -0
- mlflow/genai/scorers/__init__.py +26 -0
- mlflow/genai/scorers/base.py +492 -0
- mlflow/genai/scorers/builtin_scorers.py +765 -0
- mlflow/genai/scorers/scorer_utils.py +138 -0
- mlflow/genai/scorers/validation.py +165 -0
- mlflow/genai/utils/data_validation.py +146 -0
- mlflow/genai/utils/enum_utils.py +23 -0
- mlflow/genai/utils/trace_utils.py +211 -0
- mlflow/groq/__init__.py +42 -0
- mlflow/groq/_groq_autolog.py +74 -0
- mlflow/johnsnowlabs/__init__.py +888 -0
- mlflow/langchain/__init__.py +24 -0
- mlflow/langchain/api_request_parallel_processor.py +330 -0
- mlflow/langchain/autolog.py +147 -0
- mlflow/langchain/chat_agent_langgraph.py +340 -0
- mlflow/langchain/constant.py +1 -0
- mlflow/langchain/constants.py +1 -0
- mlflow/langchain/databricks_dependencies.py +444 -0
- mlflow/langchain/langchain_tracer.py +597 -0
- mlflow/langchain/model.py +919 -0
- mlflow/langchain/output_parsers.py +142 -0
- mlflow/langchain/retriever_chain.py +153 -0
- mlflow/langchain/runnables.py +527 -0
- mlflow/langchain/utils/chat.py +402 -0
- mlflow/langchain/utils/logging.py +671 -0
- mlflow/langchain/utils/serialization.py +36 -0
- mlflow/legacy_databricks_cli/__init__.py +0 -0
- mlflow/legacy_databricks_cli/configure/__init__.py +0 -0
- mlflow/legacy_databricks_cli/configure/provider.py +482 -0
- mlflow/litellm/__init__.py +175 -0
- mlflow/llama_index/__init__.py +22 -0
- mlflow/llama_index/autolog.py +55 -0
- mlflow/llama_index/chat.py +43 -0
- mlflow/llama_index/constant.py +1 -0
- mlflow/llama_index/model.py +577 -0
- mlflow/llama_index/pyfunc_wrapper.py +332 -0
- mlflow/llama_index/serialize_objects.py +188 -0
- mlflow/llama_index/tracer.py +561 -0
- mlflow/metrics/__init__.py +479 -0
- mlflow/metrics/base.py +39 -0
- mlflow/metrics/genai/__init__.py +25 -0
- mlflow/metrics/genai/base.py +101 -0
- mlflow/metrics/genai/genai_metric.py +771 -0
- mlflow/metrics/genai/metric_definitions.py +450 -0
- mlflow/metrics/genai/model_utils.py +371 -0
- mlflow/metrics/genai/prompt_template.py +68 -0
- mlflow/metrics/genai/prompts/__init__.py +0 -0
- mlflow/metrics/genai/prompts/v1.py +422 -0
- mlflow/metrics/genai/utils.py +6 -0
- mlflow/metrics/metric_definitions.py +619 -0
- mlflow/mismatch.py +34 -0
- mlflow/mistral/__init__.py +34 -0
- mlflow/mistral/autolog.py +71 -0
- mlflow/mistral/chat.py +135 -0
- mlflow/ml_package_versions.py +452 -0
- mlflow/models/__init__.py +97 -0
- mlflow/models/auth_policy.py +83 -0
- mlflow/models/cli.py +354 -0
- mlflow/models/container/__init__.py +294 -0
- mlflow/models/container/scoring_server/__init__.py +0 -0
- mlflow/models/container/scoring_server/nginx.conf +39 -0
- mlflow/models/dependencies_schemas.py +287 -0
- mlflow/models/display_utils.py +158 -0
- mlflow/models/docker_utils.py +211 -0
- mlflow/models/evaluation/__init__.py +23 -0
- mlflow/models/evaluation/_shap_patch.py +64 -0
- mlflow/models/evaluation/artifacts.py +194 -0
- mlflow/models/evaluation/base.py +1811 -0
- mlflow/models/evaluation/calibration_curve.py +109 -0
- mlflow/models/evaluation/default_evaluator.py +996 -0
- mlflow/models/evaluation/deprecated.py +23 -0
- mlflow/models/evaluation/evaluator_registry.py +80 -0
- mlflow/models/evaluation/evaluators/classifier.py +704 -0
- mlflow/models/evaluation/evaluators/default.py +233 -0
- mlflow/models/evaluation/evaluators/regressor.py +96 -0
- mlflow/models/evaluation/evaluators/shap.py +296 -0
- mlflow/models/evaluation/lift_curve.py +178 -0
- mlflow/models/evaluation/utils/metric.py +123 -0
- mlflow/models/evaluation/utils/trace.py +179 -0
- mlflow/models/evaluation/validation.py +434 -0
- mlflow/models/flavor_backend.py +93 -0
- mlflow/models/flavor_backend_registry.py +53 -0
- mlflow/models/model.py +1639 -0
- mlflow/models/model_config.py +150 -0
- mlflow/models/notebook_resources/agent_evaluation_template.html +235 -0
- mlflow/models/notebook_resources/eval_with_dataset_example.py +22 -0
- mlflow/models/notebook_resources/eval_with_synthetic_example.py +22 -0
- mlflow/models/python_api.py +369 -0
- mlflow/models/rag_signatures.py +128 -0
- mlflow/models/resources.py +321 -0
- mlflow/models/signature.py +662 -0
- mlflow/models/utils.py +2054 -0
- mlflow/models/wheeled_model.py +280 -0
- mlflow/openai/__init__.py +57 -0
- mlflow/openai/_agent_tracer.py +364 -0
- mlflow/openai/api_request_parallel_processor.py +131 -0
- mlflow/openai/autolog.py +509 -0
- mlflow/openai/constant.py +1 -0
- mlflow/openai/model.py +824 -0
- mlflow/openai/utils/chat_schema.py +367 -0
- mlflow/optuna/__init__.py +3 -0
- mlflow/optuna/storage.py +646 -0
- mlflow/plugins/__init__.py +72 -0
- mlflow/plugins/base.py +358 -0
- mlflow/plugins/builtin/__init__.py +24 -0
- mlflow/plugins/builtin/pytorch_plugin.py +150 -0
- mlflow/plugins/builtin/sklearn_plugin.py +158 -0
- mlflow/plugins/builtin/transformers_plugin.py +187 -0
- mlflow/plugins/cli.py +321 -0
- mlflow/plugins/discovery.py +340 -0
- mlflow/plugins/manager.py +465 -0
- mlflow/plugins/registry.py +316 -0
- mlflow/plugins/templates/framework_plugin_template.py +329 -0
- mlflow/prompt/constants.py +20 -0
- mlflow/prompt/promptlab_model.py +197 -0
- mlflow/prompt/registry_utils.py +248 -0
- mlflow/promptflow/__init__.py +495 -0
- mlflow/protos/__init__.py +0 -0
- mlflow/protos/assessments_pb2.py +174 -0
- mlflow/protos/databricks_artifacts_pb2.py +489 -0
- mlflow/protos/databricks_filesystem_service_pb2.py +196 -0
- mlflow/protos/databricks_managed_catalog_messages_pb2.py +95 -0
- mlflow/protos/databricks_managed_catalog_service_pb2.py +86 -0
- mlflow/protos/databricks_pb2.py +267 -0
- mlflow/protos/databricks_trace_server_pb2.py +374 -0
- mlflow/protos/databricks_uc_registry_messages_pb2.py +1249 -0
- mlflow/protos/databricks_uc_registry_service_pb2.py +170 -0
- mlflow/protos/facet_feature_statistics_pb2.py +296 -0
- mlflow/protos/internal_pb2.py +77 -0
- mlflow/protos/mlflow_artifacts_pb2.py +336 -0
- mlflow/protos/model_registry_pb2.py +1073 -0
- mlflow/protos/scalapb/__init__.py +0 -0
- mlflow/protos/scalapb/scalapb_pb2.py +104 -0
- mlflow/protos/service_pb2.py +2600 -0
- mlflow/protos/unity_catalog_oss_messages_pb2.py +457 -0
- mlflow/protos/unity_catalog_oss_service_pb2.py +130 -0
- mlflow/protos/unity_catalog_prompt_messages_pb2.py +447 -0
- mlflow/protos/unity_catalog_prompt_messages_pb2_grpc.py +24 -0
- mlflow/protos/unity_catalog_prompt_service_pb2.py +164 -0
- mlflow/protos/unity_catalog_prompt_service_pb2_grpc.py +785 -0
- mlflow/py.typed +0 -0
- mlflow/pydantic_ai/__init__.py +57 -0
- mlflow/pydantic_ai/autolog.py +173 -0
- mlflow/pyfunc/__init__.py +3844 -0
- mlflow/pyfunc/_mlflow_pyfunc_backend_predict.py +61 -0
- mlflow/pyfunc/backend.py +523 -0
- mlflow/pyfunc/context.py +78 -0
- mlflow/pyfunc/dbconnect_artifact_cache.py +144 -0
- mlflow/pyfunc/loaders/__init__.py +7 -0
- mlflow/pyfunc/loaders/chat_agent.py +117 -0
- mlflow/pyfunc/loaders/chat_model.py +125 -0
- mlflow/pyfunc/loaders/code_model.py +31 -0
- mlflow/pyfunc/loaders/responses_agent.py +112 -0
- mlflow/pyfunc/mlserver.py +46 -0
- mlflow/pyfunc/model.py +1473 -0
- mlflow/pyfunc/scoring_server/__init__.py +604 -0
- mlflow/pyfunc/scoring_server/app.py +7 -0
- mlflow/pyfunc/scoring_server/client.py +146 -0
- mlflow/pyfunc/spark_model_cache.py +48 -0
- mlflow/pyfunc/stdin_server.py +44 -0
- mlflow/pyfunc/utils/__init__.py +3 -0
- mlflow/pyfunc/utils/data_validation.py +224 -0
- mlflow/pyfunc/utils/environment.py +22 -0
- mlflow/pyfunc/utils/input_converter.py +47 -0
- mlflow/pyfunc/utils/serving_data_parser.py +11 -0
- mlflow/pytorch/__init__.py +1171 -0
- mlflow/pytorch/_lightning_autolog.py +580 -0
- mlflow/pytorch/_pytorch_autolog.py +50 -0
- mlflow/pytorch/pickle_module.py +35 -0
- mlflow/rfunc/__init__.py +42 -0
- mlflow/rfunc/backend.py +134 -0
- mlflow/runs.py +89 -0
- mlflow/server/__init__.py +302 -0
- mlflow/server/auth/__init__.py +1224 -0
- mlflow/server/auth/__main__.py +4 -0
- mlflow/server/auth/basic_auth.ini +6 -0
- mlflow/server/auth/cli.py +11 -0
- mlflow/server/auth/client.py +537 -0
- mlflow/server/auth/config.py +34 -0
- mlflow/server/auth/db/__init__.py +0 -0
- mlflow/server/auth/db/cli.py +18 -0
- mlflow/server/auth/db/migrations/__init__.py +0 -0
- mlflow/server/auth/db/migrations/alembic.ini +110 -0
- mlflow/server/auth/db/migrations/env.py +76 -0
- mlflow/server/auth/db/migrations/versions/8606fa83a998_initial_migration.py +51 -0
- mlflow/server/auth/db/migrations/versions/__init__.py +0 -0
- mlflow/server/auth/db/models.py +67 -0
- mlflow/server/auth/db/utils.py +37 -0
- mlflow/server/auth/entities.py +165 -0
- mlflow/server/auth/logo.py +14 -0
- mlflow/server/auth/permissions.py +65 -0
- mlflow/server/auth/routes.py +18 -0
- mlflow/server/auth/sqlalchemy_store.py +263 -0
- mlflow/server/graphql/__init__.py +0 -0
- mlflow/server/graphql/autogenerated_graphql_schema.py +353 -0
- mlflow/server/graphql/graphql_custom_scalars.py +24 -0
- mlflow/server/graphql/graphql_errors.py +15 -0
- mlflow/server/graphql/graphql_no_batching.py +89 -0
- mlflow/server/graphql/graphql_schema_extensions.py +74 -0
- mlflow/server/handlers.py +3217 -0
- mlflow/server/prometheus_exporter.py +17 -0
- mlflow/server/validation.py +30 -0
- mlflow/shap/__init__.py +691 -0
- mlflow/sklearn/__init__.py +1994 -0
- mlflow/sklearn/utils.py +1041 -0
- mlflow/smolagents/__init__.py +66 -0
- mlflow/smolagents/autolog.py +139 -0
- mlflow/smolagents/chat.py +29 -0
- mlflow/store/__init__.py +10 -0
- mlflow/store/_unity_catalog/__init__.py +1 -0
- mlflow/store/_unity_catalog/lineage/__init__.py +1 -0
- mlflow/store/_unity_catalog/lineage/constants.py +2 -0
- mlflow/store/_unity_catalog/registry/__init__.py +6 -0
- mlflow/store/_unity_catalog/registry/prompt_info.py +75 -0
- mlflow/store/_unity_catalog/registry/rest_store.py +1740 -0
- mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py +507 -0
- mlflow/store/_unity_catalog/registry/utils.py +121 -0
- mlflow/store/artifact/__init__.py +0 -0
- mlflow/store/artifact/artifact_repo.py +472 -0
- mlflow/store/artifact/artifact_repository_registry.py +154 -0
- mlflow/store/artifact/azure_blob_artifact_repo.py +275 -0
- mlflow/store/artifact/azure_data_lake_artifact_repo.py +295 -0
- mlflow/store/artifact/cli.py +141 -0
- mlflow/store/artifact/cloud_artifact_repo.py +332 -0
- mlflow/store/artifact/databricks_artifact_repo.py +729 -0
- mlflow/store/artifact/databricks_artifact_repo_resources.py +301 -0
- mlflow/store/artifact/databricks_logged_model_artifact_repo.py +93 -0
- mlflow/store/artifact/databricks_models_artifact_repo.py +216 -0
- mlflow/store/artifact/databricks_sdk_artifact_repo.py +134 -0
- mlflow/store/artifact/databricks_sdk_models_artifact_repo.py +97 -0
- mlflow/store/artifact/dbfs_artifact_repo.py +240 -0
- mlflow/store/artifact/ftp_artifact_repo.py +132 -0
- mlflow/store/artifact/gcs_artifact_repo.py +296 -0
- mlflow/store/artifact/hdfs_artifact_repo.py +209 -0
- mlflow/store/artifact/http_artifact_repo.py +218 -0
- mlflow/store/artifact/local_artifact_repo.py +142 -0
- mlflow/store/artifact/mlflow_artifacts_repo.py +94 -0
- mlflow/store/artifact/models_artifact_repo.py +259 -0
- mlflow/store/artifact/optimized_s3_artifact_repo.py +356 -0
- mlflow/store/artifact/presigned_url_artifact_repo.py +173 -0
- mlflow/store/artifact/r2_artifact_repo.py +70 -0
- mlflow/store/artifact/runs_artifact_repo.py +265 -0
- mlflow/store/artifact/s3_artifact_repo.py +330 -0
- mlflow/store/artifact/sftp_artifact_repo.py +141 -0
- mlflow/store/artifact/uc_volume_artifact_repo.py +76 -0
- mlflow/store/artifact/unity_catalog_models_artifact_repo.py +168 -0
- mlflow/store/artifact/unity_catalog_oss_models_artifact_repo.py +168 -0
- mlflow/store/artifact/utils/__init__.py +0 -0
- mlflow/store/artifact/utils/models.py +148 -0
- mlflow/store/db/__init__.py +0 -0
- mlflow/store/db/base_sql_model.py +3 -0
- mlflow/store/db/db_types.py +10 -0
- mlflow/store/db/utils.py +314 -0
- mlflow/store/db_migrations/__init__.py +0 -0
- mlflow/store/db_migrations/alembic.ini +74 -0
- mlflow/store/db_migrations/env.py +84 -0
- mlflow/store/db_migrations/versions/0584bdc529eb_add_cascading_deletion_to_datasets_from_experiments.py +88 -0
- mlflow/store/db_migrations/versions/0a8213491aaa_drop_duplicate_killed_constraint.py +49 -0
- mlflow/store/db_migrations/versions/0c779009ac13_add_deleted_time_field_to_runs_table.py +24 -0
- mlflow/store/db_migrations/versions/181f10493468_allow_nulls_for_metric_values.py +35 -0
- mlflow/store/db_migrations/versions/27a6a02d2cf1_add_model_version_tags_table.py +38 -0
- mlflow/store/db_migrations/versions/2b4d017a5e9b_add_model_registry_tables_to_db.py +77 -0
- mlflow/store/db_migrations/versions/2d6e25af4d3e_increase_max_param_val_length.py +33 -0
- mlflow/store/db_migrations/versions/3500859a5d39_add_model_aliases_table.py +50 -0
- mlflow/store/db_migrations/versions/39d1c3be5f05_add_is_nan_constraint_for_metrics_tables_if_necessary.py +41 -0
- mlflow/store/db_migrations/versions/400f98739977_add_logged_model_tables.py +123 -0
- mlflow/store/db_migrations/versions/4465047574b1_increase_max_dataset_schema_size.py +38 -0
- mlflow/store/db_migrations/versions/451aebb31d03_add_metric_step.py +35 -0
- mlflow/store/db_migrations/versions/5b0e9adcef9c_add_cascade_deletion_to_trace_tables_fk.py +40 -0
- mlflow/store/db_migrations/versions/6953534de441_add_step_to_inputs_table.py +25 -0
- mlflow/store/db_migrations/versions/728d730b5ebd_add_registered_model_tags_table.py +38 -0
- mlflow/store/db_migrations/versions/7ac759974ad8_update_run_tags_with_larger_limit.py +36 -0
- mlflow/store/db_migrations/versions/7f2a7d5fae7d_add_datasets_inputs_input_tags_tables.py +82 -0
- mlflow/store/db_migrations/versions/84291f40a231_add_run_link_to_model_version.py +26 -0
- mlflow/store/db_migrations/versions/867495a8f9d4_add_trace_tables.py +90 -0
- mlflow/store/db_migrations/versions/89d4b8295536_create_latest_metrics_table.py +169 -0
- mlflow/store/db_migrations/versions/90e64c465722_migrate_user_column_to_tags.py +64 -0
- mlflow/store/db_migrations/versions/97727af70f4d_creation_time_last_update_time_experiments.py +25 -0
- mlflow/store/db_migrations/versions/__init__.py +0 -0
- mlflow/store/db_migrations/versions/a8c4a736bde6_allow_nulls_for_run_id.py +27 -0
- mlflow/store/db_migrations/versions/acf3f17fdcc7_add_storage_location_field_to_model_.py +29 -0
- mlflow/store/db_migrations/versions/bd07f7e963c5_create_index_on_run_uuid.py +26 -0
- mlflow/store/db_migrations/versions/bda7b8c39065_increase_model_version_tag_value_limit.py +38 -0
- mlflow/store/db_migrations/versions/c48cb773bb87_reset_default_value_for_is_nan_in_metrics_table_for_mysql.py +41 -0
- mlflow/store/db_migrations/versions/cbc13b556ace_add_v3_trace_schema_columns.py +31 -0
- mlflow/store/db_migrations/versions/cc1f77228345_change_param_value_length_to_500.py +34 -0
- mlflow/store/db_migrations/versions/cfd24bdc0731_update_run_status_constraint_with_killed.py +78 -0
- mlflow/store/db_migrations/versions/df50e92ffc5e_add_experiment_tags_table.py +38 -0
- mlflow/store/db_migrations/versions/f5a4f2784254_increase_run_tag_value_limit.py +36 -0
- mlflow/store/entities/__init__.py +3 -0
- mlflow/store/entities/paged_list.py +18 -0
- mlflow/store/model_registry/__init__.py +10 -0
- mlflow/store/model_registry/abstract_store.py +1081 -0
- mlflow/store/model_registry/base_rest_store.py +44 -0
- mlflow/store/model_registry/databricks_workspace_model_registry_rest_store.py +37 -0
- mlflow/store/model_registry/dbmodels/__init__.py +0 -0
- mlflow/store/model_registry/dbmodels/models.py +206 -0
- mlflow/store/model_registry/file_store.py +1091 -0
- mlflow/store/model_registry/rest_store.py +481 -0
- mlflow/store/model_registry/sqlalchemy_store.py +1286 -0
- mlflow/store/tracking/__init__.py +23 -0
- mlflow/store/tracking/abstract_store.py +816 -0
- mlflow/store/tracking/dbmodels/__init__.py +0 -0
- mlflow/store/tracking/dbmodels/initial_models.py +243 -0
- mlflow/store/tracking/dbmodels/models.py +1073 -0
- mlflow/store/tracking/file_store.py +2438 -0
- mlflow/store/tracking/postgres_managed_identity.py +146 -0
- mlflow/store/tracking/rest_store.py +1131 -0
- mlflow/store/tracking/sqlalchemy_store.py +2785 -0
- mlflow/system_metrics/__init__.py +61 -0
- mlflow/system_metrics/metrics/__init__.py +0 -0
- mlflow/system_metrics/metrics/base_metrics_monitor.py +32 -0
- mlflow/system_metrics/metrics/cpu_monitor.py +23 -0
- mlflow/system_metrics/metrics/disk_monitor.py +21 -0
- mlflow/system_metrics/metrics/gpu_monitor.py +71 -0
- mlflow/system_metrics/metrics/network_monitor.py +34 -0
- mlflow/system_metrics/metrics/rocm_monitor.py +123 -0
- mlflow/system_metrics/system_metrics_monitor.py +198 -0
- mlflow/tracing/__init__.py +16 -0
- mlflow/tracing/assessment.py +356 -0
- mlflow/tracing/client.py +531 -0
- mlflow/tracing/config.py +125 -0
- mlflow/tracing/constant.py +105 -0
- mlflow/tracing/destination.py +81 -0
- mlflow/tracing/display/__init__.py +40 -0
- mlflow/tracing/display/display_handler.py +196 -0
- mlflow/tracing/export/async_export_queue.py +186 -0
- mlflow/tracing/export/inference_table.py +138 -0
- mlflow/tracing/export/mlflow_v3.py +137 -0
- mlflow/tracing/export/utils.py +70 -0
- mlflow/tracing/fluent.py +1417 -0
- mlflow/tracing/processor/base_mlflow.py +199 -0
- mlflow/tracing/processor/inference_table.py +175 -0
- mlflow/tracing/processor/mlflow_v3.py +47 -0
- mlflow/tracing/processor/otel.py +73 -0
- mlflow/tracing/provider.py +487 -0
- mlflow/tracing/trace_manager.py +200 -0
- mlflow/tracing/utils/__init__.py +616 -0
- mlflow/tracing/utils/artifact_utils.py +28 -0
- mlflow/tracing/utils/copy.py +55 -0
- mlflow/tracing/utils/environment.py +55 -0
- mlflow/tracing/utils/exception.py +21 -0
- mlflow/tracing/utils/once.py +35 -0
- mlflow/tracing/utils/otlp.py +63 -0
- mlflow/tracing/utils/processor.py +54 -0
- mlflow/tracing/utils/search.py +292 -0
- mlflow/tracing/utils/timeout.py +250 -0
- mlflow/tracing/utils/token.py +19 -0
- mlflow/tracing/utils/truncation.py +124 -0
- mlflow/tracing/utils/warning.py +76 -0
- mlflow/tracking/__init__.py +39 -0
- mlflow/tracking/_model_registry/__init__.py +1 -0
- mlflow/tracking/_model_registry/client.py +764 -0
- mlflow/tracking/_model_registry/fluent.py +853 -0
- mlflow/tracking/_model_registry/registry.py +67 -0
- mlflow/tracking/_model_registry/utils.py +251 -0
- mlflow/tracking/_tracking_service/__init__.py +0 -0
- mlflow/tracking/_tracking_service/client.py +883 -0
- mlflow/tracking/_tracking_service/registry.py +56 -0
- mlflow/tracking/_tracking_service/utils.py +275 -0
- mlflow/tracking/artifact_utils.py +179 -0
- mlflow/tracking/client.py +5900 -0
- mlflow/tracking/context/__init__.py +0 -0
- mlflow/tracking/context/abstract_context.py +35 -0
- mlflow/tracking/context/databricks_cluster_context.py +15 -0
- mlflow/tracking/context/databricks_command_context.py +15 -0
- mlflow/tracking/context/databricks_job_context.py +49 -0
- mlflow/tracking/context/databricks_notebook_context.py +41 -0
- mlflow/tracking/context/databricks_repo_context.py +43 -0
- mlflow/tracking/context/default_context.py +51 -0
- mlflow/tracking/context/git_context.py +32 -0
- mlflow/tracking/context/registry.py +98 -0
- mlflow/tracking/context/system_environment_context.py +15 -0
- mlflow/tracking/default_experiment/__init__.py +1 -0
- mlflow/tracking/default_experiment/abstract_context.py +43 -0
- mlflow/tracking/default_experiment/databricks_notebook_experiment_provider.py +44 -0
- mlflow/tracking/default_experiment/registry.py +75 -0
- mlflow/tracking/fluent.py +3595 -0
- mlflow/tracking/metric_value_conversion_utils.py +93 -0
- mlflow/tracking/multimedia.py +206 -0
- mlflow/tracking/registry.py +86 -0
- mlflow/tracking/request_auth/__init__.py +0 -0
- mlflow/tracking/request_auth/abstract_request_auth_provider.py +34 -0
- mlflow/tracking/request_auth/registry.py +60 -0
- mlflow/tracking/request_header/__init__.py +0 -0
- mlflow/tracking/request_header/abstract_request_header_provider.py +36 -0
- mlflow/tracking/request_header/databricks_request_header_provider.py +38 -0
- mlflow/tracking/request_header/default_request_header_provider.py +17 -0
- mlflow/tracking/request_header/registry.py +79 -0
- mlflow/transformers/__init__.py +2982 -0
- mlflow/transformers/flavor_config.py +258 -0
- mlflow/transformers/hub_utils.py +83 -0
- mlflow/transformers/llm_inference_utils.py +468 -0
- mlflow/transformers/model_io.py +301 -0
- mlflow/transformers/peft.py +51 -0
- mlflow/transformers/signature.py +183 -0
- mlflow/transformers/torch_utils.py +55 -0
- mlflow/types/__init__.py +21 -0
- mlflow/types/agent.py +270 -0
- mlflow/types/chat.py +240 -0
- mlflow/types/llm.py +935 -0
- mlflow/types/responses.py +139 -0
- mlflow/types/responses_helpers.py +416 -0
- mlflow/types/schema.py +1505 -0
- mlflow/types/type_hints.py +647 -0
- mlflow/types/utils.py +753 -0
- mlflow/utils/__init__.py +283 -0
- mlflow/utils/_capture_modules.py +256 -0
- mlflow/utils/_capture_transformers_modules.py +75 -0
- mlflow/utils/_spark_utils.py +201 -0
- mlflow/utils/_unity_catalog_oss_utils.py +97 -0
- mlflow/utils/_unity_catalog_utils.py +479 -0
- mlflow/utils/annotations.py +218 -0
- mlflow/utils/arguments_utils.py +16 -0
- mlflow/utils/async_logging/__init__.py +1 -0
- mlflow/utils/async_logging/async_artifacts_logging_queue.py +258 -0
- mlflow/utils/async_logging/async_logging_queue.py +366 -0
- mlflow/utils/async_logging/run_artifact.py +38 -0
- mlflow/utils/async_logging/run_batch.py +58 -0
- mlflow/utils/async_logging/run_operations.py +49 -0
- mlflow/utils/autologging_utils/__init__.py +737 -0
- mlflow/utils/autologging_utils/client.py +432 -0
- mlflow/utils/autologging_utils/config.py +33 -0
- mlflow/utils/autologging_utils/events.py +294 -0
- mlflow/utils/autologging_utils/logging_and_warnings.py +328 -0
- mlflow/utils/autologging_utils/metrics_queue.py +71 -0
- mlflow/utils/autologging_utils/safety.py +1104 -0
- mlflow/utils/autologging_utils/versioning.py +95 -0
- mlflow/utils/checkpoint_utils.py +206 -0
- mlflow/utils/class_utils.py +6 -0
- mlflow/utils/cli_args.py +257 -0
- mlflow/utils/conda.py +354 -0
- mlflow/utils/credentials.py +231 -0
- mlflow/utils/data_utils.py +17 -0
- mlflow/utils/databricks_utils.py +1436 -0
- mlflow/utils/docstring_utils.py +477 -0
- mlflow/utils/doctor.py +133 -0
- mlflow/utils/download_cloud_file_chunk.py +43 -0
- mlflow/utils/env_manager.py +16 -0
- mlflow/utils/env_pack.py +131 -0
- mlflow/utils/environment.py +1009 -0
- mlflow/utils/exception_utils.py +14 -0
- mlflow/utils/file_utils.py +978 -0
- mlflow/utils/git_utils.py +77 -0
- mlflow/utils/gorilla.py +797 -0
- mlflow/utils/import_hooks/__init__.py +363 -0
- mlflow/utils/lazy_load.py +51 -0
- mlflow/utils/logging_utils.py +168 -0
- mlflow/utils/mime_type_utils.py +58 -0
- mlflow/utils/mlflow_tags.py +103 -0
- mlflow/utils/model_utils.py +486 -0
- mlflow/utils/name_utils.py +346 -0
- mlflow/utils/nfs_on_spark.py +62 -0
- mlflow/utils/openai_utils.py +164 -0
- mlflow/utils/os.py +12 -0
- mlflow/utils/oss_registry_utils.py +29 -0
- mlflow/utils/plugins.py +17 -0
- mlflow/utils/process.py +182 -0
- mlflow/utils/promptlab_utils.py +146 -0
- mlflow/utils/proto_json_utils.py +743 -0
- mlflow/utils/pydantic_utils.py +54 -0
- mlflow/utils/request_utils.py +279 -0
- mlflow/utils/requirements_utils.py +704 -0
- mlflow/utils/rest_utils.py +673 -0
- mlflow/utils/search_logged_model_utils.py +127 -0
- mlflow/utils/search_utils.py +2111 -0
- mlflow/utils/secure_loading.py +221 -0
- mlflow/utils/security_validation.py +384 -0
- mlflow/utils/server_cli_utils.py +61 -0
- mlflow/utils/spark_utils.py +15 -0
- mlflow/utils/string_utils.py +138 -0
- mlflow/utils/thread_utils.py +63 -0
- mlflow/utils/time.py +54 -0
- mlflow/utils/timeout.py +42 -0
- mlflow/utils/uri.py +572 -0
- mlflow/utils/validation.py +662 -0
- mlflow/utils/virtualenv.py +458 -0
- mlflow/utils/warnings_utils.py +25 -0
- mlflow/utils/yaml_utils.py +179 -0
- mlflow/version.py +24 -0
@@ -0,0 +1,883 @@
|
|
1
|
+
"""
|
2
|
+
Internal package providing a Python CRUD interface to MLflow experiments and runs.
|
3
|
+
This is a lower level API than the :py:mod:`mlflow.tracking.fluent` module, and is
|
4
|
+
exposed in the :py:mod:`mlflow.tracking` module.
|
5
|
+
"""
|
6
|
+
|
7
|
+
import logging
|
8
|
+
import os
|
9
|
+
import sys
|
10
|
+
from itertools import zip_longest
|
11
|
+
from typing import Any, Literal, Optional
|
12
|
+
|
13
|
+
from mlflow.entities import (
|
14
|
+
ExperimentTag,
|
15
|
+
FileInfo,
|
16
|
+
LoggedModel,
|
17
|
+
LoggedModelInput,
|
18
|
+
LoggedModelOutput,
|
19
|
+
LoggedModelParameter,
|
20
|
+
LoggedModelStatus,
|
21
|
+
LoggedModelTag,
|
22
|
+
Metric,
|
23
|
+
Param,
|
24
|
+
RunStatus,
|
25
|
+
RunTag,
|
26
|
+
ViewType,
|
27
|
+
)
|
28
|
+
from mlflow.entities.dataset_input import DatasetInput
|
29
|
+
from mlflow.environment_variables import MLFLOW_SUPPRESS_PRINTING_URL_TO_STDOUT
|
30
|
+
from mlflow.exceptions import MlflowException
|
31
|
+
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE, ErrorCode
|
32
|
+
from mlflow.store.artifact.artifact_repo import ArtifactRepository
|
33
|
+
from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository
|
34
|
+
from mlflow.store.tracking import (
|
35
|
+
GET_METRIC_HISTORY_MAX_RESULTS,
|
36
|
+
SEARCH_MAX_RESULTS_DEFAULT,
|
37
|
+
)
|
38
|
+
from mlflow.store.tracking.rest_store import RestStore
|
39
|
+
from mlflow.tracking._tracking_service import utils
|
40
|
+
from mlflow.tracking.metric_value_conversion_utils import convert_metric_value_to_float_if_possible
|
41
|
+
from mlflow.utils import chunk_list
|
42
|
+
from mlflow.utils.async_logging.run_operations import RunOperations, get_combined_run_operations
|
43
|
+
from mlflow.utils.databricks_utils import get_workspace_url, is_in_databricks_notebook
|
44
|
+
from mlflow.utils.mlflow_tags import MLFLOW_USER
|
45
|
+
from mlflow.utils.string_utils import is_string_type
|
46
|
+
from mlflow.utils.time import get_current_time_millis
|
47
|
+
from mlflow.utils.uri import add_databricks_profile_info_to_artifact_uri, is_databricks_uri
|
48
|
+
from mlflow.utils.validation import (
|
49
|
+
MAX_ENTITIES_PER_BATCH,
|
50
|
+
MAX_METRICS_PER_BATCH,
|
51
|
+
MAX_PARAMS_TAGS_PER_BATCH,
|
52
|
+
PARAM_VALIDATION_MSG,
|
53
|
+
_validate_experiment_artifact_location,
|
54
|
+
_validate_run_id,
|
55
|
+
)
|
56
|
+
|
57
|
+
_logger = logging.getLogger(__name__)
|
58
|
+
|
59
|
+
|
60
|
+
class TrackingServiceClient:
|
61
|
+
"""
|
62
|
+
Client of an MLflow Tracking Server that creates and manages experiments and runs.
|
63
|
+
"""
|
64
|
+
|
65
|
+
def __init__(self, tracking_uri):
|
66
|
+
"""
|
67
|
+
Args:
|
68
|
+
tracking_uri: Address of local or remote tracking server.
|
69
|
+
"""
|
70
|
+
self.tracking_uri = tracking_uri
|
71
|
+
# NB: Fetch the tracking store (`self.store`) upon client initialization to ensure that
|
72
|
+
# the tracking URI is valid and the store can be properly resolved. We define `store` as a
|
73
|
+
# property method to ensure that the client is serializable, even if the store is not
|
74
|
+
# self.store
|
75
|
+
self.store
|
76
|
+
|
77
|
+
@property
|
78
|
+
def store(self):
|
79
|
+
return utils._get_store(self.tracking_uri)
|
80
|
+
|
81
|
+
def get_run(self, run_id):
|
82
|
+
"""Fetch the run from backend store. The resulting :py:class:`Run <mlflow.entities.Run>`
|
83
|
+
contains a collection of run metadata -- :py:class:`RunInfo <mlflow.entities.RunInfo>`,
|
84
|
+
as well as a collection of run parameters, tags, and metrics --
|
85
|
+
:py:class:`RunData <mlflow.entities.RunData>`. In the case where multiple metrics with the
|
86
|
+
same key are logged for the run, the :py:class:`RunData <mlflow.entities.RunData>` contains
|
87
|
+
the most recently logged value at the largest step for each metric.
|
88
|
+
|
89
|
+
Args:
|
90
|
+
run_id: Unique identifier for the run.
|
91
|
+
|
92
|
+
Returns:
|
93
|
+
A single :py:class:`mlflow.entities.Run` object, if the run exists. Otherwise,
|
94
|
+
raises an exception.
|
95
|
+
|
96
|
+
"""
|
97
|
+
_validate_run_id(run_id)
|
98
|
+
return self.store.get_run(run_id)
|
99
|
+
|
100
|
+
def get_metric_history(self, run_id, key):
|
101
|
+
"""Return a list of metric objects corresponding to all values logged for a given metric.
|
102
|
+
|
103
|
+
Args:
|
104
|
+
run_id: Unique identifier for run.
|
105
|
+
key: Metric name within the run.
|
106
|
+
|
107
|
+
Returns:
|
108
|
+
A list of :py:class:`mlflow.entities.Metric` entities if logged, else empty list.
|
109
|
+
"""
|
110
|
+
|
111
|
+
# NB: Paginated query support is currently only available for the RestStore backend.
|
112
|
+
# FileStore and SQLAlchemy store do not provide support for paginated queries and will
|
113
|
+
# raise an MlflowException if the `page_token` argument is not None when calling this
|
114
|
+
# API for a continuation query.
|
115
|
+
history = self.store.get_metric_history(
|
116
|
+
run_id=run_id,
|
117
|
+
metric_key=key,
|
118
|
+
max_results=GET_METRIC_HISTORY_MAX_RESULTS,
|
119
|
+
page_token=None,
|
120
|
+
)
|
121
|
+
token = history.token
|
122
|
+
# Continue issuing queries to the backend store to retrieve all pages of
|
123
|
+
# metric history.
|
124
|
+
while token is not None:
|
125
|
+
paged_history = self.store.get_metric_history(
|
126
|
+
run_id=run_id,
|
127
|
+
metric_key=key,
|
128
|
+
max_results=GET_METRIC_HISTORY_MAX_RESULTS,
|
129
|
+
page_token=token,
|
130
|
+
)
|
131
|
+
history.extend(paged_history)
|
132
|
+
token = paged_history.token
|
133
|
+
return history
|
134
|
+
|
135
|
+
def create_run(self, experiment_id, start_time=None, tags=None, run_name=None):
|
136
|
+
"""Create a :py:class:`mlflow.entities.Run` object that can be associated with
|
137
|
+
metrics, parameters, artifacts, etc.
|
138
|
+
Unlike :py:func:`mlflow.projects.run`, creates objects but does not run code.
|
139
|
+
Unlike :py:func:`mlflow.start_run`, does not change the "active run" used by
|
140
|
+
:py:func:`mlflow.log_param`.
|
141
|
+
|
142
|
+
Args:
|
143
|
+
experiment_id: The ID of the experiment to create a run in.
|
144
|
+
start_time: If not provided, use the current timestamp.
|
145
|
+
tags: A dictionary of key-value pairs that are converted into
|
146
|
+
:py:class:`mlflow.entities.RunTag` objects.
|
147
|
+
run_name: The name of this run.
|
148
|
+
|
149
|
+
Returns:
|
150
|
+
:py:class:`mlflow.entities.Run` that was created.
|
151
|
+
|
152
|
+
"""
|
153
|
+
|
154
|
+
tags = tags if tags else {}
|
155
|
+
|
156
|
+
# Extract user from tags
|
157
|
+
# This logic is temporary; the user_id attribute of runs is deprecated and will be removed
|
158
|
+
# in a later release.
|
159
|
+
user_id = tags.get(MLFLOW_USER, "unknown")
|
160
|
+
|
161
|
+
return self.store.create_run(
|
162
|
+
experiment_id=experiment_id,
|
163
|
+
user_id=user_id,
|
164
|
+
start_time=start_time or get_current_time_millis(),
|
165
|
+
tags=[RunTag(key, value) for (key, value) in tags.items()],
|
166
|
+
run_name=run_name,
|
167
|
+
)
|
168
|
+
|
169
|
+
def search_experiments(
|
170
|
+
self,
|
171
|
+
view_type=ViewType.ACTIVE_ONLY,
|
172
|
+
max_results=SEARCH_MAX_RESULTS_DEFAULT,
|
173
|
+
filter_string=None,
|
174
|
+
order_by=None,
|
175
|
+
page_token=None,
|
176
|
+
):
|
177
|
+
"""Search for experiments that match the specified search query.
|
178
|
+
|
179
|
+
Args:
|
180
|
+
view_type: One of enum values ``ACTIVE_ONLY``, ``DELETED_ONLY``, or ``ALL``
|
181
|
+
defined in :py:class:`mlflow.entities.ViewType`.
|
182
|
+
max_results: Maximum number of experiments desired. Certain server backend may apply
|
183
|
+
its own limit.
|
184
|
+
filter_string: Filter query string (e.g., ``"name = 'my_experiment'"``), defaults to
|
185
|
+
searching for all experiments. The following identifiers, comparators, and logical
|
186
|
+
operators are supported.
|
187
|
+
|
188
|
+
Identifiers
|
189
|
+
- ``name``: Experiment name
|
190
|
+
- ``creation_time``: Experiment creation time
|
191
|
+
- ``last_update_time``: Experiment last update time
|
192
|
+
- ``tags.<tag_key>``: Experiment tag. If ``tag_key`` contains
|
193
|
+
spaces, it must be wrapped with backticks (e.g., ``"tags.`extra key`"``).
|
194
|
+
|
195
|
+
Comparators for string attributes and tags
|
196
|
+
- ``=``: Equal to
|
197
|
+
- ``!=``: Not equal to
|
198
|
+
- ``LIKE``: Case-sensitive pattern match
|
199
|
+
- ``ILIKE``: Case-insensitive pattern match
|
200
|
+
|
201
|
+
Comparators for numeric attributes
|
202
|
+
- ``=``: Equal to
|
203
|
+
- ``!=``: Not equal to
|
204
|
+
- ``<``: Less than
|
205
|
+
- ``<=``: Less than or equal to
|
206
|
+
- ``>``: Greater than
|
207
|
+
- ``>=``: Greater than or equal to
|
208
|
+
|
209
|
+
Logical operators
|
210
|
+
- ``AND``: Combines two sub-queries and returns True if both of them are True.
|
211
|
+
|
212
|
+
order_by: List of columns to order by. The ``order_by`` column can contain an optional
|
213
|
+
``DESC`` or ``ASC`` value (e.g., ``"name DESC"``). The default ordering is ``ASC``,
|
214
|
+
so ``"name"`` is equivalent to ``"name ASC"``. If unspecified, defaults to
|
215
|
+
``["last_update_time DESC"]``, which lists experiments updated most recently first.
|
216
|
+
The following fields are supported:
|
217
|
+
|
218
|
+
- ``experiment_id``: Experiment ID
|
219
|
+
- ``name``: Experiment name
|
220
|
+
- ``creation_time``: Experiment creation time
|
221
|
+
- ``last_update_time``: Experiment last update time
|
222
|
+
|
223
|
+
page_token: Token specifying the next page of results. It should be obtained from
|
224
|
+
a ``search_experiments`` call.
|
225
|
+
|
226
|
+
Returns:
|
227
|
+
A :py:class:`PagedList <mlflow.store.entities.PagedList>` of
|
228
|
+
:py:class:`Experiment <mlflow.entities.Experiment>` objects. The pagination token
|
229
|
+
for the next page can be obtained via the ``token`` attribute of the object.
|
230
|
+
|
231
|
+
"""
|
232
|
+
return self.store.search_experiments(
|
233
|
+
view_type=view_type,
|
234
|
+
max_results=max_results,
|
235
|
+
filter_string=filter_string,
|
236
|
+
order_by=order_by,
|
237
|
+
page_token=page_token,
|
238
|
+
)
|
239
|
+
|
240
|
+
def get_experiment(self, experiment_id):
|
241
|
+
"""
|
242
|
+
Args:
|
243
|
+
experiment_id: The experiment ID returned from ``create_experiment``.
|
244
|
+
|
245
|
+
Returns:
|
246
|
+
:py:class:`mlflow.entities.Experiment`
|
247
|
+
"""
|
248
|
+
return self.store.get_experiment(experiment_id)
|
249
|
+
|
250
|
+
def get_experiment_by_name(self, name):
|
251
|
+
"""
|
252
|
+
Args:
|
253
|
+
name: The experiment name.
|
254
|
+
|
255
|
+
Returns:
|
256
|
+
:py:class:`mlflow.entities.Experiment`
|
257
|
+
"""
|
258
|
+
return self.store.get_experiment_by_name(name)
|
259
|
+
|
260
|
+
def create_experiment(self, name, artifact_location=None, tags=None):
|
261
|
+
"""Create an experiment.
|
262
|
+
|
263
|
+
Args:
|
264
|
+
name: The experiment name. Must be unique.
|
265
|
+
artifact_location: The location to store run artifacts. If not provided, the server
|
266
|
+
picks an appropriate default.
|
267
|
+
tags: A dictionary of key-value pairs that are converted into
|
268
|
+
:py:class:`mlflow.entities.ExperimentTag` objects.
|
269
|
+
|
270
|
+
Returns:
|
271
|
+
Integer ID of the created experiment.
|
272
|
+
|
273
|
+
"""
|
274
|
+
_validate_experiment_artifact_location(artifact_location)
|
275
|
+
return self.store.create_experiment(
|
276
|
+
name=name,
|
277
|
+
artifact_location=artifact_location,
|
278
|
+
tags=[ExperimentTag(key, value) for (key, value) in tags.items()] if tags else [],
|
279
|
+
)
|
280
|
+
|
281
|
+
def delete_experiment(self, experiment_id):
|
282
|
+
"""Delete an experiment from the backend store.
|
283
|
+
|
284
|
+
Args:
|
285
|
+
experiment_id: The experiment ID returned from ``create_experiment``.
|
286
|
+
|
287
|
+
"""
|
288
|
+
self.store.delete_experiment(experiment_id)
|
289
|
+
|
290
|
+
def restore_experiment(self, experiment_id):
|
291
|
+
"""Restore a deleted experiment unless permanently deleted.
|
292
|
+
|
293
|
+
Args:
|
294
|
+
experiment_id: The experiment ID returned from ``create_experiment``.
|
295
|
+
|
296
|
+
"""
|
297
|
+
self.store.restore_experiment(experiment_id)
|
298
|
+
|
299
|
+
def rename_experiment(self, experiment_id, new_name):
|
300
|
+
"""Update an experiment's name. The new name must be unique.
|
301
|
+
|
302
|
+
Args:
|
303
|
+
experiment_id: The experiment ID returned from ``create_experiment``.
|
304
|
+
new_name: New name for the experiment.
|
305
|
+
|
306
|
+
"""
|
307
|
+
self.store.rename_experiment(experiment_id, new_name)
|
308
|
+
|
309
|
+
def log_metric(
|
310
|
+
self,
|
311
|
+
run_id,
|
312
|
+
key,
|
313
|
+
value,
|
314
|
+
timestamp=None,
|
315
|
+
step=None,
|
316
|
+
synchronous=True,
|
317
|
+
dataset_name: Optional[str] = None,
|
318
|
+
dataset_digest: Optional[str] = None,
|
319
|
+
model_id: Optional[str] = None,
|
320
|
+
) -> Optional[RunOperations]:
|
321
|
+
"""Log a metric against the run ID.
|
322
|
+
|
323
|
+
Args:
|
324
|
+
run_id: The run id to which the metric should be logged.
|
325
|
+
key: Metric name. This string may only contain alphanumerics, underscores (_),
|
326
|
+
dashes (-), periods (.), spaces ( ), and slashes (/). All backend stores will
|
327
|
+
support keys up to length 250, but some may support larger keys.
|
328
|
+
value: Metric value or single-item ndarray / tensor. Note that some special values such
|
329
|
+
as +/- Infinity may be replaced by other values depending on the store. For example,
|
330
|
+
the SQLAlchemy store replaces +/- Inf with max / min float values. All backend
|
331
|
+
stores will support values up to length 5000, but some may support larger values.
|
332
|
+
timestamp: Time when this metric was calculated. Defaults to the current system time.
|
333
|
+
step: Training step (iteration) at which was the metric calculated. Defaults to 0.
|
334
|
+
synchronous: *Experimental* If True, blocks until the metric is logged successfully. If
|
335
|
+
False, logs the metric asynchronously and returns a future representing the logging
|
336
|
+
operation.
|
337
|
+
dataset_name: The name of the dataset associated with the metric. If specified,
|
338
|
+
``dataset_digest`` must also be provided.
|
339
|
+
dataset_digest: The digest of the dataset associated with the metric. If specified,
|
340
|
+
``dataset_name`` must also be provided.
|
341
|
+
model_id: The ID of the model associated with the metric.
|
342
|
+
|
343
|
+
Returns:
|
344
|
+
When synchronous=True, returns None. When synchronous=False, returns
|
345
|
+
:py:class:`mlflow.RunOperations` that represents future for logging operation.
|
346
|
+
|
347
|
+
"""
|
348
|
+
timestamp = timestamp if timestamp is not None else get_current_time_millis()
|
349
|
+
step = step if step is not None else 0
|
350
|
+
metric_value = convert_metric_value_to_float_if_possible(value)
|
351
|
+
metric = Metric(
|
352
|
+
key,
|
353
|
+
metric_value,
|
354
|
+
timestamp,
|
355
|
+
step,
|
356
|
+
model_id=model_id,
|
357
|
+
dataset_name=dataset_name,
|
358
|
+
dataset_digest=dataset_digest,
|
359
|
+
)
|
360
|
+
if synchronous:
|
361
|
+
self.store.log_metric(run_id, metric)
|
362
|
+
else:
|
363
|
+
return self.store.log_metric_async(run_id, metric)
|
364
|
+
|
365
|
+
def log_param(self, run_id, key, value, synchronous=True):
|
366
|
+
"""Log a parameter (e.g. model hyperparameter) against the run ID. Value is converted to
|
367
|
+
a string.
|
368
|
+
|
369
|
+
Args:
|
370
|
+
run_id: ID of the run to log the parameter against.
|
371
|
+
key: Name of the parameter.
|
372
|
+
value: Value of the parameter.
|
373
|
+
synchronous: *Experimental* If True, blocks until the parameters are logged
|
374
|
+
successfully. If False, logs the parameters asynchronously and
|
375
|
+
returns a future representing the logging operation.
|
376
|
+
|
377
|
+
Returns:
|
378
|
+
When synchronous=True, returns parameter value.
|
379
|
+
When synchronous=False, returns :py:class:`mlflow.RunOperations` that
|
380
|
+
represents future for logging operation.
|
381
|
+
|
382
|
+
"""
|
383
|
+
param = Param(key, str(value))
|
384
|
+
try:
|
385
|
+
if synchronous:
|
386
|
+
self.store.log_param(run_id, param)
|
387
|
+
return value
|
388
|
+
else:
|
389
|
+
return self.store.log_param_async(run_id, param)
|
390
|
+
except MlflowException as e:
|
391
|
+
if e.error_code == ErrorCode.Name(INVALID_PARAMETER_VALUE):
|
392
|
+
msg = f"{e.message}{PARAM_VALIDATION_MSG}"
|
393
|
+
raise MlflowException(msg, INVALID_PARAMETER_VALUE)
|
394
|
+
else:
|
395
|
+
raise e
|
396
|
+
|
397
|
+
def set_experiment_tag(self, experiment_id, key, value):
|
398
|
+
"""Set a tag on the experiment with the specified ID. Value is converted to a string.
|
399
|
+
|
400
|
+
Args:
|
401
|
+
experiment_id: String ID of the experiment.
|
402
|
+
key: Name of the tag.
|
403
|
+
value: Tag value (converted to a string).
|
404
|
+
"""
|
405
|
+
tag = ExperimentTag(key, str(value))
|
406
|
+
self.store.set_experiment_tag(experiment_id, tag)
|
407
|
+
|
408
|
+
def set_tag(self, run_id, key, value, synchronous=True) -> Optional[RunOperations]:
|
409
|
+
"""Set a tag on the run with the specified ID. Value is converted to a string.
|
410
|
+
|
411
|
+
Args:
|
412
|
+
run_id: String ID of the run.
|
413
|
+
key: Tag name. This string may only contain alphanumerics, underscores
|
414
|
+
(_), dashes (-), periods (.), spaces ( ), and slashes (/).
|
415
|
+
All backend stores will support keys up to length 250, but some may
|
416
|
+
support larger keys.
|
417
|
+
value: Tag value, but will be string-ified if not.
|
418
|
+
All backend stores will support values up to length 5000, but some
|
419
|
+
may support larger values.
|
420
|
+
synchronous: *Experimental* If True, blocks until the tag is logged
|
421
|
+
successfully. If False, logs the tag asynchronously and
|
422
|
+
returns a future representing the logging operation.
|
423
|
+
|
424
|
+
Returns:
|
425
|
+
When synchronous=True, returns None.
|
426
|
+
When synchronous=False, returns :py:class:`mlflow.RunOperations` object
|
427
|
+
that represents future for logging operation.
|
428
|
+
|
429
|
+
"""
|
430
|
+
tag = RunTag(key, str(value))
|
431
|
+
if synchronous:
|
432
|
+
self.store.set_tag(run_id, tag)
|
433
|
+
else:
|
434
|
+
return self.store.set_tag_async(run_id, tag)
|
435
|
+
|
436
|
+
def delete_tag(self, run_id, key):
|
437
|
+
"""Delete a tag from a run. This is irreversible.
|
438
|
+
|
439
|
+
Args:
|
440
|
+
run_id: String ID of the run
|
441
|
+
key: Name of the tag
|
442
|
+
|
443
|
+
"""
|
444
|
+
self.store.delete_tag(run_id, key)
|
445
|
+
|
446
|
+
def update_run(self, run_id, status=None, name=None):
|
447
|
+
"""Update a run with the specified ID to a new status or name.
|
448
|
+
|
449
|
+
Args:
|
450
|
+
run_id: The ID of the Run to update.
|
451
|
+
status: The new status of the run to set, if specified. At least one of ``status`` or
|
452
|
+
``name`` should be specified.
|
453
|
+
name: The new name of the run to set, if specified. At least one of ``name`` or
|
454
|
+
``status`` should be specified.
|
455
|
+
|
456
|
+
"""
|
457
|
+
# Exit early
|
458
|
+
if status is None and name is None:
|
459
|
+
return
|
460
|
+
|
461
|
+
run = self.get_run(run_id)
|
462
|
+
status = status or run.info.status
|
463
|
+
self.store.update_run_info(
|
464
|
+
run_id=run_id,
|
465
|
+
run_status=RunStatus.from_string(status),
|
466
|
+
end_time=run.info.end_time,
|
467
|
+
run_name=name,
|
468
|
+
)
|
469
|
+
|
470
|
+
def log_batch(
|
471
|
+
self, run_id, metrics=(), params=(), tags=(), synchronous=True
|
472
|
+
) -> Optional[RunOperations]:
|
473
|
+
"""Log multiple metrics, params, and/or tags.
|
474
|
+
|
475
|
+
Args:
|
476
|
+
run_id: String ID of the run.
|
477
|
+
metrics: If provided, List of Metric(key, value, timestamp) instances.
|
478
|
+
params: If provided, List of Param(key, value) instances.
|
479
|
+
tags: If provided, List of RunTag(key, value) instances.
|
480
|
+
synchronous: *Experimental* If True, blocks until the metrics/tags/params are logged
|
481
|
+
successfully. If False, logs the metrics/tags/params asynchronously
|
482
|
+
and returns a future representing the logging operation.
|
483
|
+
|
484
|
+
Raises:
|
485
|
+
MlflowException: If any errors occur.
|
486
|
+
|
487
|
+
Returns:
|
488
|
+
When synchronous=True, returns None.
|
489
|
+
When synchronous=False, returns :py:class:`mlflow.RunOperations` that
|
490
|
+
represents future for logging operation.
|
491
|
+
|
492
|
+
"""
|
493
|
+
from mlflow.tracking.fluent import get_active_model_id
|
494
|
+
|
495
|
+
if len(metrics) == 0 and len(params) == 0 and len(tags) == 0:
|
496
|
+
return
|
497
|
+
|
498
|
+
metrics = [
|
499
|
+
Metric(
|
500
|
+
key=metric.key,
|
501
|
+
value=convert_metric_value_to_float_if_possible(metric.value),
|
502
|
+
timestamp=metric.timestamp,
|
503
|
+
step=metric.step,
|
504
|
+
dataset_name=metric.dataset_name,
|
505
|
+
dataset_digest=metric.dataset_digest,
|
506
|
+
model_id=metric.model_id or get_active_model_id(),
|
507
|
+
run_id=metric.run_id,
|
508
|
+
)
|
509
|
+
for metric in metrics
|
510
|
+
]
|
511
|
+
|
512
|
+
param_batches = chunk_list(params, MAX_PARAMS_TAGS_PER_BATCH)
|
513
|
+
tag_batches = chunk_list(tags, MAX_PARAMS_TAGS_PER_BATCH)
|
514
|
+
|
515
|
+
# When given data is split into one or more batches, we need to wait for all the batches.
|
516
|
+
# Each batch logged returns run_operations which we append to this list
|
517
|
+
# At the end we merge all the run_operations into a single run_operations object and return.
|
518
|
+
# Applicable only when synchronous is False
|
519
|
+
run_operations_list = []
|
520
|
+
|
521
|
+
for params_batch, tags_batch in zip_longest(param_batches, tag_batches, fillvalue=[]):
|
522
|
+
metrics_batch_size = min(
|
523
|
+
MAX_ENTITIES_PER_BATCH - len(params_batch) - len(tags_batch),
|
524
|
+
MAX_METRICS_PER_BATCH,
|
525
|
+
)
|
526
|
+
metrics_batch_size = max(metrics_batch_size, 0)
|
527
|
+
metrics_batch = metrics[:metrics_batch_size]
|
528
|
+
metrics = metrics[metrics_batch_size:]
|
529
|
+
|
530
|
+
if synchronous:
|
531
|
+
self.store.log_batch(
|
532
|
+
run_id=run_id, metrics=metrics_batch, params=params_batch, tags=tags_batch
|
533
|
+
)
|
534
|
+
else:
|
535
|
+
run_operations_list.append(
|
536
|
+
self.store.log_batch_async(
|
537
|
+
run_id=run_id,
|
538
|
+
metrics=metrics_batch,
|
539
|
+
params=params_batch,
|
540
|
+
tags=tags_batch,
|
541
|
+
)
|
542
|
+
)
|
543
|
+
|
544
|
+
for metrics_batch in chunk_list(metrics, chunk_size=MAX_METRICS_PER_BATCH):
|
545
|
+
if synchronous:
|
546
|
+
self.store.log_batch(run_id=run_id, metrics=metrics_batch, params=[], tags=[])
|
547
|
+
else:
|
548
|
+
run_operations_list.append(
|
549
|
+
self.store.log_batch_async(
|
550
|
+
run_id=run_id, metrics=metrics_batch, params=[], tags=[]
|
551
|
+
)
|
552
|
+
)
|
553
|
+
|
554
|
+
if not synchronous:
|
555
|
+
# Merge all the run operations into a single run operations object
|
556
|
+
return get_combined_run_operations(run_operations_list)
|
557
|
+
|
558
|
+
def log_inputs(
|
559
|
+
self,
|
560
|
+
run_id: str,
|
561
|
+
datasets: Optional[list[DatasetInput]] = None,
|
562
|
+
models: Optional[list[LoggedModelInput]] = None,
|
563
|
+
):
|
564
|
+
"""Log one or more dataset inputs to a run.
|
565
|
+
|
566
|
+
Args:
|
567
|
+
run_id: String ID of the run.
|
568
|
+
datasets: List of :py:class:`mlflow.entities.DatasetInput` instances to log.
|
569
|
+
models: List of :py:class:`mlflow.entities.LoggedModelInput` instances to log.
|
570
|
+
|
571
|
+
Raises:
|
572
|
+
MlflowException: If any errors occur.
|
573
|
+
|
574
|
+
Returns:
|
575
|
+
None
|
576
|
+
"""
|
577
|
+
self.store.log_inputs(run_id=run_id, datasets=datasets, models=models)
|
578
|
+
|
579
|
+
def log_outputs(self, run_id: str, models: list[LoggedModelOutput]):
|
580
|
+
self.store.log_outputs(run_id=run_id, models=models)
|
581
|
+
|
582
|
+
def _record_logged_model(self, run_id, mlflow_model):
|
583
|
+
from mlflow.models import Model
|
584
|
+
|
585
|
+
if not isinstance(mlflow_model, Model):
|
586
|
+
raise TypeError(
|
587
|
+
"Argument 'mlflow_model' should be of type mlflow.models.Model but was "
|
588
|
+
f"{type(mlflow_model)}"
|
589
|
+
)
|
590
|
+
self.store.record_logged_model(run_id, mlflow_model)
|
591
|
+
|
592
|
+
def _get_artifact_repo(
|
593
|
+
self,
|
594
|
+
resource_id: str,
|
595
|
+
*,
|
596
|
+
resource: Literal["run", "logged_model"] = "run",
|
597
|
+
) -> ArtifactRepository:
|
598
|
+
# Attempt to fetch the artifact repo from a local cache
|
599
|
+
if cached_repo := utils._artifact_repos_cache.get(resource_id):
|
600
|
+
return cached_repo
|
601
|
+
else:
|
602
|
+
if resource == "run":
|
603
|
+
run = self.get_run(resource_id)
|
604
|
+
artifact_location = run.info.artifact_uri
|
605
|
+
elif resource == "logged_model":
|
606
|
+
logged_model = self.get_logged_model(resource_id)
|
607
|
+
artifact_location = logged_model.artifact_location
|
608
|
+
else:
|
609
|
+
raise ValueError(f"Unexpected resource type {resource!r}.")
|
610
|
+
|
611
|
+
artifact_uri = add_databricks_profile_info_to_artifact_uri(
|
612
|
+
artifact_location, self.tracking_uri
|
613
|
+
)
|
614
|
+
artifact_repo = get_artifact_repository(artifact_uri)
|
615
|
+
# Cache the artifact repo to avoid a future network call, removing the oldest
|
616
|
+
# entry in the cache if there are too many elements
|
617
|
+
if len(utils._artifact_repos_cache) > 1024:
|
618
|
+
utils._artifact_repos_cache.popitem(last=False)
|
619
|
+
utils._artifact_repos_cache[resource_id] = artifact_repo
|
620
|
+
return artifact_repo
|
621
|
+
|
622
|
+
def log_artifact(self, run_id, local_path, artifact_path=None):
|
623
|
+
"""
|
624
|
+
Write a local file or directory to the remote ``artifact_uri``.
|
625
|
+
|
626
|
+
Args:
|
627
|
+
run_id: String ID of the run.
|
628
|
+
local_path: Path to the file or directory to write.
|
629
|
+
artifact_path: If provided, the directory in ``artifact_uri`` to write to.
|
630
|
+
"""
|
631
|
+
artifact_repo = self._get_artifact_repo(run_id)
|
632
|
+
if os.path.isdir(local_path):
|
633
|
+
dir_name = os.path.basename(os.path.normpath(local_path))
|
634
|
+
path_name = (
|
635
|
+
os.path.join(artifact_path, dir_name) if artifact_path is not None else dir_name
|
636
|
+
)
|
637
|
+
artifact_repo.log_artifacts(local_path, path_name)
|
638
|
+
else:
|
639
|
+
artifact_repo.log_artifact(local_path, artifact_path)
|
640
|
+
|
641
|
+
def _log_artifact_async(self, run_id, filename, artifact_path=None, artifact=None):
|
642
|
+
"""
|
643
|
+
Write an artifact to the remote ``artifact_uri`` asynchronously.
|
644
|
+
|
645
|
+
Args:
|
646
|
+
run_id: String ID of the run.
|
647
|
+
filename: Filename of the artifact to be logged.
|
648
|
+
artifact_path: If provided, the directory in ``artifact_uri`` to write to.
|
649
|
+
artifact: The artifact to be logged.
|
650
|
+
"""
|
651
|
+
artifact_repo = self._get_artifact_repo(run_id)
|
652
|
+
artifact_repo._log_artifact_async(filename, artifact_path, artifact)
|
653
|
+
|
654
|
+
def log_artifacts(self, run_id, local_dir, artifact_path=None):
|
655
|
+
"""Write a directory of files to the remote ``artifact_uri``.
|
656
|
+
|
657
|
+
Args:
|
658
|
+
run_id: String ID of the run.
|
659
|
+
local_dir: Path to the directory of files to write.
|
660
|
+
artifact_path: If provided, the directory in ``artifact_uri`` to write to.
|
661
|
+
|
662
|
+
"""
|
663
|
+
self._get_artifact_repo(run_id).log_artifacts(local_dir, artifact_path)
|
664
|
+
|
665
|
+
def list_artifacts(self, run_id, path=None):
|
666
|
+
"""List the artifacts for a run.
|
667
|
+
|
668
|
+
Args:
|
669
|
+
run_id: The run to list artifacts from.
|
670
|
+
path: The run's relative artifact path to list from. By default it is set to None
|
671
|
+
or the root artifact path.
|
672
|
+
|
673
|
+
Returns:
|
674
|
+
List of :py:class:`mlflow.entities.FileInfo`
|
675
|
+
|
676
|
+
"""
|
677
|
+
from mlflow.artifacts import list_artifacts
|
678
|
+
|
679
|
+
return list_artifacts(run_id=run_id, artifact_path=path, tracking_uri=self.tracking_uri)
|
680
|
+
|
681
|
+
def list_logged_model_artifacts(
|
682
|
+
self, model_id: str, path: Optional[str] = None
|
683
|
+
) -> list[FileInfo]:
|
684
|
+
"""List the artifacts for a logged model.
|
685
|
+
|
686
|
+
Args:
|
687
|
+
model_id: The model to list artifacts from.
|
688
|
+
path: The model's relative artifact path to list from. By default it is set to None
|
689
|
+
or the root artifact path.
|
690
|
+
|
691
|
+
Returns:
|
692
|
+
List of :py:class:`mlflow.entities.FileInfo`
|
693
|
+
"""
|
694
|
+
return self._get_artifact_repo(model_id, resource="logged_model").list_artifacts(path)
|
695
|
+
|
696
|
+
def download_artifacts(self, run_id: str, path: str, dst_path: Optional[str] = None):
|
697
|
+
"""Download an artifact file or directory from a run to a local directory if applicable,
|
698
|
+
and return a local path for it.
|
699
|
+
|
700
|
+
Args:
|
701
|
+
run_id: The run to download artifacts from.
|
702
|
+
path: Relative source path to the desired artifact.
|
703
|
+
dst_path: Absolute path of the local filesystem destination directory to which to
|
704
|
+
download the specified artifacts. This directory must already exist.
|
705
|
+
If unspecified, the artifacts will either be downloaded to a new
|
706
|
+
uniquely-named directory on the local filesystem or will be returned
|
707
|
+
directly in the case of the LocalArtifactRepository.
|
708
|
+
|
709
|
+
Returns:
|
710
|
+
Local path of desired artifact.
|
711
|
+
|
712
|
+
"""
|
713
|
+
from mlflow.artifacts import download_artifacts
|
714
|
+
|
715
|
+
return download_artifacts(
|
716
|
+
run_id=run_id, artifact_path=path, dst_path=dst_path, tracking_uri=self.tracking_uri
|
717
|
+
)
|
718
|
+
|
719
|
+
def _log_url(self, run_id):
|
720
|
+
if not isinstance(self.store, RestStore):
|
721
|
+
return
|
722
|
+
if is_in_databricks_notebook() or MLFLOW_SUPPRESS_PRINTING_URL_TO_STDOUT.get():
|
723
|
+
# In Databricks notebooks, MLflow experiment and run links are displayed automatically.
|
724
|
+
return
|
725
|
+
host_url = get_workspace_url()
|
726
|
+
if host_url is None:
|
727
|
+
host_url = self.store.get_host_creds().host.rstrip("/")
|
728
|
+
run_info = self.store.get_run(run_id).info
|
729
|
+
experiment_id = run_info.experiment_id
|
730
|
+
run_name = run_info.run_name
|
731
|
+
if is_databricks_uri(self.tracking_uri):
|
732
|
+
experiment_url = f"{host_url}/ml/experiments/{experiment_id}"
|
733
|
+
else:
|
734
|
+
experiment_url = f"{host_url}/#/experiments/{experiment_id}"
|
735
|
+
run_url = f"{experiment_url}/runs/{run_id}"
|
736
|
+
|
737
|
+
sys.stdout.write(f"🏃 View run {run_name} at: {run_url}\n")
|
738
|
+
sys.stdout.write(f"🧪 View experiment at: {experiment_url}\n")
|
739
|
+
|
740
|
+
def set_terminated(self, run_id, status=None, end_time=None):
|
741
|
+
"""Set a run's status to terminated.
|
742
|
+
|
743
|
+
Args:
|
744
|
+
run_id: String ID of the run.
|
745
|
+
status: A string value of :py:class:`mlflow.entities.RunStatus`. Defaults to "FINISHED".
|
746
|
+
end_time: If not provided, defaults to the current time.
|
747
|
+
"""
|
748
|
+
end_time = end_time if end_time else get_current_time_millis()
|
749
|
+
status = status if status else RunStatus.to_string(RunStatus.FINISHED)
|
750
|
+
# Tell the store to stop async logging: stop accepting new data and log already enqueued
|
751
|
+
# data in the background. This call is making sure every async logging data has been
|
752
|
+
# submitted for logging, but not necessarily finished logging.
|
753
|
+
self.store.shut_down_async_logging()
|
754
|
+
self._log_url(run_id)
|
755
|
+
self.store.update_run_info(
|
756
|
+
run_id,
|
757
|
+
run_status=RunStatus.from_string(status),
|
758
|
+
end_time=end_time,
|
759
|
+
run_name=None,
|
760
|
+
)
|
761
|
+
|
762
|
+
def delete_run(self, run_id):
|
763
|
+
"""
|
764
|
+
Deletes a run with the given ID.
|
765
|
+
"""
|
766
|
+
self.store.delete_run(run_id)
|
767
|
+
|
768
|
+
def restore_run(self, run_id):
|
769
|
+
"""
|
770
|
+
Restores a deleted run with the given ID.
|
771
|
+
"""
|
772
|
+
self.store.restore_run(run_id)
|
773
|
+
|
774
|
+
def search_runs(
|
775
|
+
self,
|
776
|
+
experiment_ids,
|
777
|
+
filter_string="",
|
778
|
+
run_view_type=ViewType.ACTIVE_ONLY,
|
779
|
+
max_results=SEARCH_MAX_RESULTS_DEFAULT,
|
780
|
+
order_by=None,
|
781
|
+
page_token=None,
|
782
|
+
):
|
783
|
+
"""Search experiments that fit the search criteria.
|
784
|
+
|
785
|
+
Args:
|
786
|
+
experiment_ids: List of experiment IDs, or a single int or string id.
|
787
|
+
filter_string: Filter query string, defaults to searching all runs.
|
788
|
+
run_view_type: One of enum values ACTIVE_ONLY, DELETED_ONLY, or ALL runs
|
789
|
+
defined in :py:class:`mlflow.entities.ViewType`.
|
790
|
+
max_results: Maximum number of runs desired.
|
791
|
+
order_by: List of columns to order by (e.g., "metrics.rmse"). The ``order_by`` column
|
792
|
+
can contain an optional ``DESC`` or ``ASC`` value. The default is ``ASC``.
|
793
|
+
The default ordering is to sort by ``start_time DESC``, then ``run_id``.
|
794
|
+
page_token: Token specifying the next page of results. It should be obtained from
|
795
|
+
a ``search_runs`` call.
|
796
|
+
|
797
|
+
Returns:
|
798
|
+
A :py:class:`PagedList <mlflow.store.entities.PagedList>` of
|
799
|
+
:py:class:`Run <mlflow.entities.Run>` objects that satisfy the search expressions.
|
800
|
+
If the underlying tracking store supports pagination, the token for the next page may
|
801
|
+
be obtained via the ``token`` attribute of the returned object.
|
802
|
+
|
803
|
+
"""
|
804
|
+
if isinstance(experiment_ids, int) or is_string_type(experiment_ids):
|
805
|
+
experiment_ids = [experiment_ids]
|
806
|
+
return self.store.search_runs(
|
807
|
+
experiment_ids=experiment_ids,
|
808
|
+
filter_string=filter_string,
|
809
|
+
run_view_type=run_view_type,
|
810
|
+
max_results=max_results,
|
811
|
+
order_by=order_by,
|
812
|
+
page_token=page_token,
|
813
|
+
)
|
814
|
+
|
815
|
+
def create_logged_model(
|
816
|
+
self,
|
817
|
+
experiment_id: str,
|
818
|
+
name: Optional[str] = None,
|
819
|
+
source_run_id: Optional[str] = None,
|
820
|
+
tags: Optional[dict[str, str]] = None,
|
821
|
+
params: Optional[dict[str, str]] = None,
|
822
|
+
model_type: Optional[str] = None,
|
823
|
+
) -> LoggedModel:
|
824
|
+
return self.store.create_logged_model(
|
825
|
+
experiment_id=experiment_id,
|
826
|
+
name=name,
|
827
|
+
source_run_id=source_run_id,
|
828
|
+
tags=[LoggedModelTag(str(key), str(value)) for key, value in tags.items()]
|
829
|
+
if tags is not None
|
830
|
+
else tags,
|
831
|
+
params=[LoggedModelParameter(str(key), str(value)) for key, value in params.items()]
|
832
|
+
if params is not None
|
833
|
+
else params,
|
834
|
+
model_type=model_type,
|
835
|
+
)
|
836
|
+
|
837
|
+
def log_model_params(self, model_id: str, params: dict[str, str]) -> None:
|
838
|
+
return self.store.log_logged_model_params(
|
839
|
+
model_id=model_id,
|
840
|
+
params=[LoggedModelParameter(str(key), str(value)) for key, value in params.items()],
|
841
|
+
)
|
842
|
+
|
843
|
+
def finalize_logged_model(self, model_id: str, status: LoggedModelStatus) -> LoggedModel:
|
844
|
+
return self.store.finalize_logged_model(model_id, status)
|
845
|
+
|
846
|
+
def get_logged_model(self, model_id: str) -> LoggedModel:
|
847
|
+
return self.store.get_logged_model(model_id)
|
848
|
+
|
849
|
+
def delete_logged_model(self, model_id: str) -> None:
|
850
|
+
return self.store.delete_logged_model(model_id)
|
851
|
+
|
852
|
+
def set_logged_model_tags(self, model_id: str, tags: dict[str, Any]) -> None:
|
853
|
+
self.store.set_logged_model_tags(
|
854
|
+
model_id, [LoggedModelTag(str(key), str(value)) for key, value in tags.items()]
|
855
|
+
)
|
856
|
+
|
857
|
+
def delete_logged_model_tag(self, model_id: str, key: str) -> None:
|
858
|
+
return self.store.delete_logged_model_tag(model_id, key)
|
859
|
+
|
860
|
+
def log_model_artifact(self, model_id: str, local_path: str) -> None:
|
861
|
+
self._get_artifact_repo(model_id, resource="logged_model").log_artifact(local_path)
|
862
|
+
|
863
|
+
def log_model_artifacts(self, model_id: str, local_dir: str) -> None:
|
864
|
+
self._get_artifact_repo(model_id, resource="logged_model").log_artifacts(local_dir)
|
865
|
+
|
866
|
+
def search_logged_models(
|
867
|
+
self,
|
868
|
+
experiment_ids: list[str],
|
869
|
+
filter_string: Optional[str] = None,
|
870
|
+
datasets: Optional[list[dict[str, Any]]] = None,
|
871
|
+
max_results: Optional[int] = None,
|
872
|
+
order_by: Optional[list[dict[str, Any]]] = None,
|
873
|
+
page_token: Optional[str] = None,
|
874
|
+
):
|
875
|
+
if not isinstance(experiment_ids, list) or not all(
|
876
|
+
isinstance(eid, str) for eid in experiment_ids
|
877
|
+
):
|
878
|
+
raise MlflowException.invalid_parameter_value(
|
879
|
+
f"experiment_ids must be a list of strings, got {type(experiment_ids)}",
|
880
|
+
)
|
881
|
+
return self.store.search_logged_models(
|
882
|
+
experiment_ids, filter_string, datasets, max_results, order_by, page_token
|
883
|
+
)
|