repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
mlflow
tests/store/model_registry/test_databricks_workspace_model_registry_store.py
.py
from unittest import mock import pytest from mlflow.entities.model_registry import ModelVersion, ModelVersionTag from mlflow.exceptions import MlflowException from mlflow.store.model_registry.databricks_workspace_model_registry_rest_store import ( DatabricksWorkspaceModelRegistryRestStore, _extract_workspace_...
395
15,014
mlflow
tests/store/analytics/test_trace_correlation.py
.py
import math import pytest from mlflow.store.analytics.trace_correlation import ( calculate_npmi_from_counts, calculate_smoothed_npmi, ) @pytest.mark.parametrize( ( "joint_count", "filter1_count", "filter2_count", "total_count", "expected_npmi", "expected_s...
149
4,596
mlflow
tests/store/lineage/test_downstream_lineage.py
.py
import base64 from unittest import mock import pytest import mlflow from mlflow.protos.databricks_uc_registry_messages_pb2 import ( EmitModelVersionLineageRequest, Entity, Job, LineageHeaderInfo, ModelVersionLineageDirection, ModelVersionLineageInfo, Notebook, ) from mlflow.store._unity_ca...
168
6,042
mlflow
tests/store/db/test_utils.py
.py
from pathlib import Path from unittest import mock import pytest from sqlalchemy.pool import NullPool from sqlalchemy.pool.impl import QueuePool from mlflow.exceptions import MlflowException from mlflow.store.db import utils def test_create_sqlalchemy_engine_inject_pool_options(monkeypatch): monkeypatch.setenv(...
193
7,671
mlflow
tests/groq/test_groq_autolog.py
.py
import json from unittest.mock import patch import groq import pytest from groq.types.audio.transcription import Transcription from groq.types.audio.translation import Translation from groq.types.chat import ChatCompletionMessageToolCall from groq.types.chat.chat_completion import ( ChatCompletion, ChatComplet...
372
11,527
mlflow
tests/litellm/test_litellm_autolog.py
.py
import asyncio import litellm import pytest import mlflow from mlflow.entities.span import SpanType from tests.tracing.helper import get_traces def _assert_usage( attributes, expected_prompt_tokens=None, expected_completion_tokens=None, expected_total_tokens=None, ): if "mlflow.chat.tokenUsage"...
228
7,477
mlflow
tests/litellm/conftest.py
.py
import importlib import openai import pytest from tests.helper_functions import start_mock_openai_server @pytest.fixture(autouse=True) def set_envs(monkeypatch, mock_openai): monkeypatch.setenv("OPENAI_API_KEY", "test") monkeypatch.setenv("OPENAI_API_BASE", mock_openai) importlib.reload(openai) @pytes...
20
451
mlflow
tests/tensorflow/test_tensorflow2_metric_value_conversion_utils.py
.py
import pytest import tensorflow as tf import mlflow from mlflow import tracking from mlflow.exceptions import INVALID_PARAMETER_VALUE, ErrorCode, MlflowException from mlflow.tracking.fluent import start_run from mlflow.tracking.metric_value_conversion_utils import convert_metric_value_to_float_if_possible def test_r...
34
1,239
mlflow
tests/tensorflow/test_mlflow_callback.py
.py
import numpy as np import pytest import tensorflow as tf from tensorflow import keras import mlflow from mlflow.tensorflow.callback import MlflowCallback @pytest.mark.parametrize(("log_every_epoch", "log_every_n_steps"), [(True, None), (False, 1)]) def test_tf_mlflow_callback(log_every_epoch, log_every_n_steps): ...
58
1,835
mlflow
tests/tensorflow/test_tensorflow2_core_model_export.py
.py
import os from typing import Any, NamedTuple from unittest import mock import numpy as np import pytest import tensorflow as tf import mlflow.tensorflow from mlflow.models import Model, infer_signature class ToyModel(tf.Module): def __init__(self, w, b): super().__init__() self.w = w sel...
130
3,954
mlflow
tests/tensorflow/test_keras_model_export.py
.py
import os import random import shutil from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pytest import tensorflow as tf import yaml from packaging.version import Version from sklearn import datasets from tensorflow.keras import backend as K from tensorflow.keras.layers imp...
746
27,844
mlflow
tests/tensorflow/iris_data_utils.py
.py
# From https://github.com/tensorflow/models/blob/master/samples/core/get_started/iris_data.py # This file is the example used by TensorFlow to get users started. This code is used for testing. import pandas as pd import tensorflow as tf TRAIN_URL = "http://download.tensorflow.org/data/iris_training.csv" TEST_URL = "ht...
89
2,876
mlflow
tests/tensorflow/test_keras_pyfunc_model_works_with_all_input_types.py
.py
import json import os import numpy as np import pandas as pd import pytest import tensorflow as tf from packaging.version import Version from pyspark.sql.functions import struct from sklearn import datasets from tensorflow.keras.layers import Concatenate, Dense, Input, Lambda from tensorflow.keras.models import Model,...
417
14,658
mlflow
tests/tensorflow/test_tensorflow2_autolog.py
.py
# pep8: disable=E501 import functools import json import os import pickle import sys from pathlib import Path from unittest.mock import patch import numpy as np import pytest import tensorflow as tf import yaml from packaging.version import Version from tensorflow.keras import layers import mlflow from mlflow import...
1,456
52,429
mlflow
tests/docker/test_integrations.py
.py
import os from datetime import timedelta import pytest from testcontainers.compose import DockerCompose from testcontainers.core.wait_strategies import HttpWaitStrategy import mlflow @pytest.mark.parametrize( "compose_file", [ "docker-compose.mssql-test.yaml", "docker-compose.mysql-test.yaml...
49
1,359
mlflow
tests/docker/conftest.py
.py
import subprocess import pytest @pytest.fixture(scope="package", autouse=True) def build_mlflow_image(): subprocess.check_call([ "docker", "build", "-t", "mlflow-integration-test", "-f", "docker/Dockerfile.full.dev", ".", ]) yield # Clean up the...
20
438
mlflow
tests/system_metrics/test_system_metrics_logging.py
.py
import logging import threading import time from typing import Any, Callable from unittest import mock import pytest import mlflow from mlflow.entities import Metric, Run, RunData, RunInfo from mlflow.exceptions import MlflowException from mlflow.system_metrics.system_metrics_monitor import SystemMetricsMonitor @py...
320
11,524
mlflow
tests/system_metrics/test_collect_metrics.py
.py
from mlflow.system_metrics.metrics.cpu_monitor import CPUMonitor from mlflow.system_metrics.metrics.disk_monitor import DiskMonitor from mlflow.system_metrics.metrics.gpu_monitor import GPUMonitor from mlflow.system_metrics.metrics.network_monitor import NetworkMonitor def test_cpu_monitor(): cpu_monitor = CPUMon...
89
3,644
mlflow
tests/semantic_kernel/test_semantic_kernel_autolog.py
.py
import asyncio from unittest import mock import openai import pytest import pytest_asyncio from semantic_kernel import Kernel from semantic_kernel.agents import AgentResponseItem from semantic_kernel.connectors.ai.open_ai import OpenAIChatCompletion from semantic_kernel.contents import ChatMessageContent from semantic...
523
18,825
mlflow
tests/semantic_kernel/resources.py
.py
import openai from semantic_kernel import Kernel from semantic_kernel.agents import ChatCompletionAgent from semantic_kernel.connectors.ai.open_ai import ( OpenAIChatCompletion, OpenAITextCompletion, OpenAITextEmbedding, ) from semantic_kernel.contents import ChatHistory from semantic_kernel.functions impor...
167
5,681
mlflow
tests/semantic_kernel/conftest.py
.py
import importlib import openai import pytest import pytest_asyncio from opentelemetry import trace as trace_api from opentelemetry.util._once import Once from tests.helper_functions import start_mock_openai_server from tests.tracing.helper import ( reset_autolog_state, # noqa: F401 ) @pytest.fixture(autouse=Tr...
35
863
mlflow
tests/smolagents/test_smolagents_autolog.py
.py
from types import SimpleNamespace from unittest.mock import patch import pytest import smolagents from packaging.version import Version import mlflow from mlflow.entities.span import SpanType from mlflow.tracing.constant import SpanAttributeKey from tests.tracing.helper import get_traces _DUMMY_INPUT = "Explain qua...
257
8,801
mlflow
tests/lightgbm/test_lightgbm_autolog.py
.py
import functools import json import os import pickle from unittest import mock from unittest.mock import patch import lightgbm as lgb import matplotlib as mpl import numpy as np import pandas as pd import polars as pl import pytest from packaging.version import Version from sklearn import datasets import mlflow impor...
830
29,671
mlflow
tests/lightgbm/test_lightgbm_model_export.py
.py
import json import os from pathlib import Path from typing import NamedTuple from unittest import mock import cloudpickle import lightgbm as lgb import numpy as np import pandas as pd import pytest import skops import yaml from sklearn import datasets from sklearn.pipeline import Pipeline import mlflow.lightgbm impor...
649
24,341
mlflow
tests/autogen/test_autogen_autolog.py
.py
import pytest from autogen_agentchat.agents import AssistantAgent from autogen_agentchat.messages import MultiModalMessage from autogen_core import FunctionCall, Image from autogen_core.models import CreateResult from autogen_ext.models.replay import ReplayChatCompletionClient import mlflow from mlflow.entities.span i...
372
11,367
mlflow
tests/sagemaker/test_sagemaker_deployment_client.py
.py
import json import os import re import time from functools import wraps from io import BytesIO from typing import NamedTuple from unittest import mock import boto3 import botocore import numpy as np import pandas as pd import pytest from click.testing import CliRunner from moto.core import DEFAULT_ACCOUNT_ID from skle...
1,707
65,165
mlflow
tests/sagemaker/test_batch_deployment.py
.py
import os import time from functools import wraps from typing import NamedTuple from unittest import mock import boto3 import botocore import numpy as np import pytest from click.testing import CliRunner from moto.core import DEFAULT_ACCOUNT_ID from sklearn.linear_model import LogisticRegression import mlflow import ...
527
19,533
mlflow
tests/sagemaker/test_cli.py
.py
import os import shutil from pathlib import Path from unittest import mock import docker import pytest from click.testing import CliRunner import mlflow from mlflow.models.docker_utils import build_image_from_context from mlflow.sagemaker.cli import build_and_push_container from tests.pyfunc.docker.test_docker impor...
161
5,612
mlflow
tests/sagemaker/conftest.py
.py
import pytest from mlflow.store.artifact.s3_artifact_repo import _cached_get_s3_client @pytest.fixture(autouse=True) def reset_cached_get_s3_client(): # `_cached_get_s3_client` is a process-global lru_cache whose key does not include the # resolved AWS credentials. Under pytest-xdist a worker runs many modul...
14
657
mlflow
tests/sagemaker/mock/mock_sagemaker_urls.py
.py
from tests.sagemaker.mock import SageMakerResponse url_bases = [ "https?://api.sagemaker.(.+).amazonaws.com", ] url_paths = { "{0}/$": SageMakerResponse.dispatch, }
10
175
mlflow
tests/sagemaker/mock/__init__.py
.py
import json import time from datetime import datetime from typing import Any, NamedTuple from moto.core import DEFAULT_ACCOUNT_ID, BackendDict, BaseBackend, BaseModel from moto.core.models import base_decorator from moto.core.responses import BaseResponse class SageMakerResourceWithArn(NamedTuple): resource: Any...
1,091
41,509
mlflow
tests/sagemaker/mock/test_sagemaker_service_mock.py
.py
import boto3 import pytest from tests.helper_functions import set_boto_credentials # noqa: F401 from tests.sagemaker.mock import mock_sagemaker @pytest.fixture def sagemaker_client(): return boto3.client("sagemaker", region_name="us-west-2") def create_sagemaker_model(sagemaker_client, model_name): return...
682
24,929
mlflow
tests/mistral/test_mistral_autolog.py
.py
from unittest.mock import patch import httpx import pytest try: from mistralai.client import Mistral # mistralai >= 2.0 from mistralai.client.models import ( AssistantMessage, ChatCompletionChoice, ChatCompletionResponse, FunctionCall, ToolCall, UsageInfo, ...
318
10,868
mlflow
tests/haystack/test_haystack_tracing.py
.py
import sys from unittest.mock import patch import pytest from haystack import Document, Pipeline, component from haystack.components.rankers import LostInTheMiddleRanker from haystack.components.retrievers import InMemoryBM25Retriever from haystack.document_stores.in_memory import InMemoryDocumentStore import mlflow ...
228
7,342
mlflow
tests/haystack/conftest.py
.py
import pytest from opentelemetry import trace as otel_trace import mlflow from mlflow.tracing.provider import provider from mlflow.utils.autologging_utils import AUTOLOGGING_INTEGRATIONS @pytest.fixture(autouse=True) def clear_autolog_state(reset_tracing): for key in list(AUTOLOGGING_INTEGRATIONS.keys()): ...
24
789
mlflow
tests/integration/utils.py
.py
from click.testing import CliRunner def invoke_cli_runner(*args, **kwargs): """ Helper method to invoke the CliRunner while asserting that the exit code is actually 0. """ res = CliRunner().invoke(*args, **kwargs) assert res.exit_code == 0, f"Got non-zero exit code {res.exit_code}. Output is: {re...
12
346
mlflow
tests/integration/async_logging/test_async_logging_integration.py
.py
import io import pickle import time import uuid import pytest import mlflow from mlflow import MlflowClient from mlflow.entities.metric import Metric from mlflow.entities.param import Param from mlflow.entities.run_tag import RunTag @pytest.fixture(autouse=True) def flush_async_logging(): """Flush async logging...
241
8,250
mlflow
tests/resources/example_virtualenv_conda_project/entrypoint.py
.py
import argparse import os import sys import numpy as np import sklearn from sklearn.pipeline import make_pipeline from sklearn.preprocessing import StandardScaler from sklearn.svm import SVC import mlflow parser = argparse.ArgumentParser() parser.add_argument( "--test", action="store_true", help="If spec...
34
911
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/dummy_evaluator.py
.py
import io import os import tempfile import pandas as pd from PIL import Image from sklearn import metrics as sk_metrics from mlflow import MlflowClient from mlflow.entities import Metric from mlflow.models.evaluation import ( EvaluationArtifact, EvaluationResult, ModelEvaluator, ) from mlflow.models.evalu...
119
4,626
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/app.py
.py
""" To run a tracking server with this app, use `mlflow server --app-name custom_app`. """ import logging # This would be all that plugin author is required to import from mlflow.server import app as custom_app # Can do custom logging on either the app or logging itself # but you'll possibly have to clear the existi...
40
1,045
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/dummy_backend.py
.py
from mlflow.entities import RunStatus from mlflow.projects.backend.abstract_backend import AbstractBackend from mlflow.projects.submitted_run import SubmittedRun from mlflow.projects.utils import fetch_and_validate_project, get_or_create_run class DummySubmittedRun(SubmittedRun): """ A run that just does noth...
45
1,109
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/sqlalchemy_store.py
.py
import urllib.parse from mlflow.store.model_registry.sqlalchemy_store import SqlAlchemyStore class PluginRegistrySqlAlchemyStore(SqlAlchemyStore): def __init__(self, store_uri=None): path = urllib.parse.urlparse(store_uri).path if store_uri else None self.is_plugin = True super().__init__...
11
327
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/fake_deployment_plugin.py
.py
import os from mlflow.deployments import BaseDeploymentClient, PredictionsResponse f_deployment_name = "fake_deployment_name" f_endpoint_name = "fake_endpoint_name" class PluginDeploymentClient(BaseDeploymentClient): def create_deployment(self, name, model_uri, flavor=None, config=None, endpoint=None): ...
64
2,115
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/file_store.py
.py
import urllib.parse from mlflow.store.tracking.file_store import FileStore class PluginFileStore(FileStore): """FileStore provided through entrypoints system""" def __init__(self, store_uri=None, artifact_uri=None): path = urllib.parse.urlparse(store_uri).path if store_uri else None self.is_...
13
379
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/request_header_provider.py
.py
from mlflow.tracking.request_header.abstract_request_header_provider import RequestHeaderProvider class PluginRequestHeaderProvider(RequestHeaderProvider): """RequestHeaderProvider provided through plugin system""" def in_context(self): return False def request_headers(self): return {"te...
12
335
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/dummy_dataset_source.py
.py
from typing import Any from urllib.parse import urlparse from mlflow.data.dataset_source import DatasetSource from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE class DummyDatasetSource(DatasetSource): def __init__(self, uri): self._uri = uri ...
56
1,535
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/default_experiment_provider.py
.py
from mlflow.tracking.default_experiment.abstract_context import DefaultExperimentProvider class PluginDefaultExperimentProvider(DefaultExperimentProvider): """DefaultExperimentProvider provided through plugin system""" def in_context(self): return False def get_experiment_id(self): retur...
12
340
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/request_auth_provider.py
.py
from mlflow.tracking.request_auth.abstract_request_auth_provider import RequestAuthProvider class PluginRequestAuthProvider(RequestAuthProvider): """RequestAuthProvider provided through plugin system""" def get_name(self): return "test_auth_provider_name" def get_auth(self): return {"aut...
12
356
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/run_context_provider.py
.py
from mlflow.tracking.context.abstract_context import RunContextProvider class PluginRunContextProvider(RunContextProvider): """RunContextProvider provided through plugin system""" def in_context(self): return False def tags(self): return {"test": "tag"}
12
286
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/local_artifact.py
.py
from mlflow.store.artifact.local_artifact_repo import LocalArtifactRepository class PluginLocalArtifactRepository(LocalArtifactRepository): """LocalArtifactRepository provided through plugin system""" is_plugin = True
8
229
mlflow
tests/resources/mlflow-test-plugin/mlflow_test_plugin/dummy_dataset.py
.py
import json from typing import Any import numpy as np import pandas as pd from mlflow.data.dataset import Dataset from mlflow.types import Schema from mlflow.types.utils import _infer_schema from mlflow_test_plugin.dummy_dataset_source import DummyDatasetSource class DummyDataset(Dataset): def __init__( ...
76
2,248
mlflow
tests/resources/example_project/tracking_test.py
.py
import sys import mlflow def call_tracking_apis(): mlflow.log_metric("some_key", 3) def main(use_start_run): if use_start_run: with mlflow.start_run(): call_tracking_apis() else: call_tracking_apis() if __name__ == "__main__": main(use_start_run=int(sys.argv[1]))
20
315
mlflow
tests/resources/example_project/check_conda_env.py
.py
# Import a dependency in MLflow's setup.py that's in our conda.yaml but not included with MLflow # by default, verify that we can use it. import os import sys import psutil import mlflow def main(expected_env_name): actual_conda_env = os.environ.get("CONDA_DEFAULT_ENV", None) assert actual_conda_env == exp...
23
586
mlflow
tests/resources/example_project/greeter.py
.py
""" Example program helping verify functionality for passing parameters other than those required in the MLproject file. """ import argparse if __name__ == "__main__": parser = argparse.ArgumentParser() parser.add_argument("greeting", help="Greeting to use", type=str) parser.add_argument("name", help="Nam...
18
646
mlflow
tests/resources/example_mlflow_2.12_langchain_model/lc_model.py
.py
from typing import Any from langchain.prompts import ChatPromptTemplate from langchain.schema.output_parser import StrOutputParser from langchain.schema.runnable import RunnablePassthrough from langchain.text_splitter import CharacterTextSplitter from langchain_community.chat_models import ChatDatabricks, ChatMlflow f...
77
2,483
mlflow
tests/resources/data/dataset_source.py
.py
from typing import Any from urllib.parse import urlparse from mlflow.artifacts import download_artifacts from mlflow.data.dataset_source import DatasetSource from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE class SampleDatasetSource(DatasetSource): de...
55
1,522
mlflow
tests/resources/data/dataset.py
.py
import base64 import hashlib import json from typing import Any import numpy as np import pandas as pd from mlflow.data.dataset import Dataset from mlflow.types import Schema from mlflow.types.utils import _infer_schema from tests.resources.data.dataset_source import SampleDatasetSource class SampleDataset(Dataset...
68
1,881
mlflow
tests/resources/onnx/generate_onnx_models.py
.py
""" Generates the following test resources: - tf_model_multiple_inputs_float32.onnx - tf_model_multiple_inputs_float64.onnx - sklearn_model.onnx Usage: python generate_onnx_models.py """ import numpy as np import onnx import onnxmltools import pandas as pd import tensorflow.compat.v1 as tf import tf2onnx...
79
2,381
mlflow
tests/resources/db/initial_models.py
.py
# Snapshot of MLflow DB models as of the 0.9.1 release, prior to the first database migration. # This file corresponds to the first database schema that we can reasonably expect users to be # running and exists to test that the oldest database schema can be brought up-to-date. # Copied from https://github.com/mlflow/ml...
242
8,156
mlflow
tests/resources/example_docker_project/scripts/docker_tracking_test.py
.py
import sys import tempfile import mlflow def call_tracking_apis(): mlflow.log_metric("some_key", 3) with tempfile.NamedTemporaryFile("w") as temp_file: temp_file.write("Temporary content.") mlflow.log_artifact(temp_file.name) def main(use_start_run): if use_start_run: with mlflo...
24
477
mlflow
tests/telemetry/test_client.py
.py
import json import logging import threading import time import warnings from unittest import mock import pytest import mlflow from mlflow.environment_variables import ( _MLFLOW_TELEMETRY_PRE_WARM_DATABRICKS_SDK, _MLFLOW_TELEMETRY_SESSION_ID, MLFLOW_ENABLE_DB_SDK, ) from mlflow.telemetry.client import ( ...
1,409
48,877
mlflow
tests/telemetry/test_track.py
.py
import time from unittest import mock import pytest from mlflow.environment_variables import MLFLOW_DISABLE_TELEMETRY from mlflow.telemetry.client import ( TelemetryClient, _fetch_server_info, get_telemetry_client, set_telemetry_client, ) from mlflow.telemetry.events import CreateLoggedModelEvent, Eve...
384
13,242
mlflow
tests/telemetry/test_tracked_events.py
.py
import json import time from unittest import mock from unittest.mock import AsyncMock, MagicMock, patch import pandas as pd import pytest import sklearn.neighbors as knn from click.testing import CliRunner from fastapi import Request import mlflow from mlflow import MlflowClient from mlflow.entities import ( Eval...
2,655
84,225
mlflow
tests/telemetry/test_installation_id.py
.py
import json import uuid from unittest import mock import pytest import mlflow from mlflow.telemetry.client import get_telemetry_client, set_telemetry_client from mlflow.telemetry.installation_id import get_or_create_installation_id from mlflow.utils.os import is_windows from mlflow.version import VERSION @pytest.fi...
92
3,204
mlflow
tests/telemetry/helper_functions.py
.py
import json from typing import Any def validate_telemetry_record( mock_telemetry_client, mock_requests, event_name: str, params=None, *, status="success", search_index=True, check_params=True, ) -> dict[str, Any]: """ Validate the telemetry record at the given index. """ ...
40
1,059
mlflow
tests/telemetry/test_events.py
.py
from unittest.mock import Mock import pandas as pd import pytest from mlflow.entities.evaluation_dataset import DatasetGranularity, EvaluationDataset from mlflow.entities.gateway_budget_policy import ( BudgetAction, BudgetDuration, BudgetDurationUnit, BudgetTargetScope, BudgetUnit, ) from mlflow.e...
1,025
33,162
mlflow
tests/telemetry/test_utils.py
.py
from pathlib import Path from unittest.mock import Mock, patch import pytest import mlflow.telemetry.utils from mlflow.telemetry.constant import ( CONFIG_STAGING_URL, CONFIG_URL, FALLBACK_UI_CONFIG, UI_CONFIG_STAGING_URL, UI_CONFIG_URL, ) from mlflow.telemetry.schemas import Environment from mlflo...
161
5,409
mlflow
tests/telemetry/conftest.py
.py
from unittest.mock import Mock, patch import pytest import mlflow.telemetry.utils from mlflow.telemetry.client import ( TelemetryClient, _fetch_server_info, _set_telemetry_client, get_telemetry_client, ) from mlflow.utils.server_info import _clear_server_info_cache from mlflow.version import VERSION ...
110
3,397
mlflow
tests/artifacts/test_artifacts.py
.py
import os import pathlib import uuid from typing import NamedTuple from unittest import mock import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.utils.file_utils import mkdir, path_to_local_file_uri from mlflow.utils.os import is_windows class Artifact(NamedTuple): uri: str ...
405
15,653
mlflow
tests/deployments/test_deployments.py
.py
from unittest import mock import pytest from mlflow import deployments from mlflow.deployments.plugin_manager import DeploymentPlugins from mlflow.exceptions import MlflowException f_model_uri = "fake_model_uri" f_endpoint_name = "fake_endpoint_name" f_deployment_id = "fake_deployment_name" f_flavor = "fake_flavor" ...
127
3,992
mlflow
tests/deployments/test_interface.py
.py
import pytest import mlflow.deployments.utils from mlflow.deployments.interface import get_deploy_client mlflow.deployments.utils._deployments_target = None def test_get_deploy_client_no_args(): mlflow.deployments.utils._deployments_target = None assert get_deploy_client() is None def test_get_deploy_clie...
33
866
mlflow
tests/deployments/test_cli.py
.py
import json import os from unittest import mock import pytest from click.testing import CliRunner from mlflow.deployments import cli from mlflow.exceptions import MlflowException f_model_uri = "fake_model_uri" f_name = "fake_deployment_name" f_flavor = "fake_flavor" f_target = "faketarget" runner = CliRunner() def...
154
4,731
mlflow
tests/deployments/test_utils.py
.py
import pytest from mlflow.deployments.utils import ( get_deployments_target, set_deployments_target, ) from mlflow.exceptions import MlflowException def test_set_deployments_target(monkeypatch): monkeypatch.setattr("mlflow.deployments.utils._deployments_target", None) valid_target = "databricks" ...
42
1,362
mlflow
tests/deployments/mlflow/test_mlflow.py
.py
from unittest import mock import pytest from mlflow.deployments import get_deploy_client from mlflow.deployments.mlflow import MlflowDeploymentClient from mlflow.environment_variables import MLFLOW_DEPLOYMENT_CLIENT_HTTP_REQUEST_TIMEOUT def test_get_deploy_client(): client = get_deploy_client("http://localhost:...
268
9,734
mlflow
tests/deployments/databricks/test_databricks.py
.py
import os import warnings from unittest import mock import pytest from mlflow.deployments import get_deploy_client from mlflow.exceptions import MlflowException @pytest.fixture(autouse=True) def mock_databricks_credentials(monkeypatch): monkeypatch.setenv("DATABRICKS_HOST", "https://test.cloud.databricks.com") ...
606
22,900
mlflow
tests/deployments/openai/test_openai.py
.py
from unittest import mock import pytest from mlflow.deployments import get_deploy_client from mlflow.exceptions import MlflowException @pytest.fixture def mock_openai_creds(monkeypatch): monkeypatch.setenv("OPENAI_API_KEY", "my-secret-key") @pytest.fixture def mock_azure_openai_creds(monkeypatch): monkeyp...
217
6,547
mlflow
tests/dev/test_update_mlflow_versions.py
.py
import difflib import re from pathlib import Path import pytest from packaging.version import Version from dev.update_mlflow_versions import ( get_current_py_version, replace_java, replace_java_pom_xml, replace_pyproject_toml, replace_python, replace_r, replace_ts, ) # { filename: expecte...
171
5,424
mlflow
tests/dev/test_check_function_signatures.py
.py
import ast from dev.check_function_signatures import check_signature_compatibility def test_no_changes(): old_code = "def func(a, b=1): pass" new_code = "def func(a, b=1): pass" old_tree = ast.parse(old_code) new_tree = ast.parse(new_code) errors = check_signature_compatibility(old_tree.body[0],...
231
7,443
mlflow
tests/dev/test_dev_stubs.py
.py
import importlib.util import json import shutil import subprocess import sys import tempfile from pathlib import Path import pytest from mlflow.assistant.providers.claude_code import ClaudeCodeProvider from mlflow.assistant.types import EventType REPO_ROOT = Path(__file__).resolve().parents[2] DEV_STUBS = REPO_ROOT ...
133
4,462
mlflow
tests/dev/test_annotate_flaky_tests.py
.py
import ast import json import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) import annotate_flaky_tests from annotate_flaky_tests import _split_nodeid, annotate_file def _annotate(tmp_path: Path, source: str, nodeid_suffix: str, attempts: int = 3): """Write `s...
199
7,859
mlflow
tests/dev/test_remove_experimental_decorators.py
.py
import subprocess import sys from pathlib import Path SCRIPT_PATH = "dev/remove_experimental_decorators.py" def test_script_with_specific_file(tmp_path: Path) -> None: test_file = tmp_path / "test.py" test_file.write_text(""" @experimental(version="1.0.0") def func(): pass """) output = subprocess.c...
207
4,789
mlflow
tests/dev/test_update_model_catalog.py
.py
import json import sys from datetime import date from pathlib import Path import pytest sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) from update_model_catalog import ( _extract_long_context_pricing, _extract_modality_pricing, _extract_service_tiers, _extract_tool_pricing, ...
796
24,846
mlflow
tests/dev/test_detect_flaky_tests.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) from detect_flaky_tests import gh_api_objects, parse_failing_tests # A captured pytest failure line as it appears in a raw GitHub Actions log: an ISO # timestamp prefix, ANSI SGR color codes around FAILED/the nod...
79
3,023
mlflow
tests/dev/test_classify_flaky_tests.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) from classify_flaky_tests import _aggregate def test_aggregate_collapses_events_per_test_and_counts(): flakes = [ {"shard": "python (1)", "test": "tests/a.py::t1", "error": "boom"}, {"shard":...
37
1,370
mlflow
tests/dev/test_check_init_py.py
.py
import subprocess import sys from pathlib import Path import pytest def get_check_init_py_script() -> Path: return Path(__file__).resolve().parents[2] / "dev" / "check_init_py.py" @pytest.fixture def temp_git_repo(tmp_path: Path) -> Path: subprocess.check_call(["git", "init"], cwd=tmp_path) subprocess....
227
7,376
mlflow
tests/tracking/test_tracking.py
.py
import filecmp import io import json import os import pathlib import posixpath import random import re from datetime import datetime, timezone from typing import NamedTuple from unittest import mock import pytest import yaml import mlflow from mlflow import MlflowClient, tracking from mlflow.entities import Lifecycle...
1,376
54,372
mlflow
tests/tracking/test_artifact_utils.py
.py
import os from unittest import mock from unittest.mock import ANY from uuid import UUID import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.tracking.artifact_utils import ( _download_artifact_from_uri, _upload_artifact_to_uri, _upload_artifacts_to_databricks, ) def test...
151
6,173
mlflow
tests/tracking/test_client.py
.py
import json import os import pickle import threading import time import uuid from pathlib import Path from unittest import mock from unittest.mock import Mock, patch import pytest from opentelemetry import trace as trace_api from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from pydantic import Base...
4,042
151,764
mlflow
tests/tracking/test_client_workspace.py
.py
from __future__ import annotations from mlflow import MlflowClient from mlflow.entities import TraceArchivalConfig from mlflow.environment_variables import MLFLOW_TRACKING_URI, MLFLOW_WORKSPACE_STORE_URI from mlflow.tracking._workspace import fluent as workspace_fluent from mlflow.tracking._workspace.client import Wor...
252
8,552
mlflow
tests/tracking/test_workspace_registry.py
.py
from __future__ import annotations import pytest from mlflow.store.workspace.rest_store import RestWorkspaceStore from mlflow.store.workspace.sqlalchemy_store import SqlAlchemyStore from mlflow.tracking._workspace.registry import ( UnsupportedWorkspaceStoreURIException, _get_workspace_store_registry, get_...
41
1,295
mlflow
tests/tracking/test_workspace_utils.py
.py
import pytest from mlflow.environment_variables import MLFLOW_TRACKING_URI, MLFLOW_WORKSPACE_STORE_URI from mlflow.utils.workspace_utils import resolve_workspace_store_uri, set_workspace_store_uri @pytest.fixture(autouse=True) def _reset_workspace_uri(monkeypatch): set_workspace_store_uri(None) monkeypatch.d...
39
1,598
mlflow
tests/tracking/test_client_webhooks.py
.py
from pathlib import Path from typing import Iterator import pytest from cryptography.fernet import Fernet from mlflow.entities.webhook import WebhookAction, WebhookEntity, WebhookEvent, WebhookStatus from mlflow.environment_variables import MLFLOW_WEBHOOK_SECRET_ENCRYPTION_KEY from mlflow.exceptions import MlflowExce...
218
8,862
mlflow
tests/tracking/test_span_links_client.py
.py
from mlflow.entities import Link from mlflow.tracking.client import MlflowClient from tests.tracing.helper import get_traces def test_client_start_trace_with_links(): client = MlflowClient() links = [ Link(trace_id="tr-0123456789abcdef0123456789abcdef", span_id="0123456789abcdef"), ] root = ...
49
1,398
mlflow
tests/tracking/test_rest_tracking.py
.py
import json import logging import math import os import pathlib import posixpath import subprocess import sys import time import urllib.parse from dataclasses import asdict from io import StringIO from pathlib import Path from unittest import mock import flask import pandas as pd import pytest import requests from ope...
5,538
202,790
mlflow
tests/tracking/test_mlflow_artifacts.py
.py
import cgi import os import pathlib import subprocess import tempfile from contextlib import contextmanager from io import BytesIO from typing import NamedTuple import pytest import requests import mlflow from mlflow import MlflowClient from mlflow.artifacts import download_artifacts from mlflow.store.tracking.sqlalc...
444
15,871
mlflow
tests/tracking/integration_test_utils.py
.py
import contextlib import logging import os import socket import sys import time from subprocess import Popen from threading import Thread from typing import Any, Generator, Literal import requests import uvicorn from fastapi import FastAPI import mlflow from mlflow.server import ARTIFACT_ROOT_ENV_VAR, BACKEND_STORE_U...
165
5,170
mlflow
tests/tracking/test_log_image.py
.py
import json import os import posixpath import numpy as np import pytest import mlflow from mlflow.utils.file_utils import local_file_uri_to_path from mlflow.utils.time import get_current_time_millis @pytest.mark.parametrize("subdir", [None, ".", "dir", "dir1/dir2", "dir/.."]) def test_log_image_numpy(subdir): i...
367
13,042
mlflow
tests/tracking/test_model_registry.py
.py
import time from pathlib import Path import pytest from mlflow import MlflowClient from mlflow.entities.model_registry import ModelVersion, RegisteredModel from mlflow.exceptions import MlflowException from mlflow.server import handlers from mlflow.server.fastapi_app import app from mlflow.server.handlers import init...
691
29,107
mlflow
tests/tracking/test_log_figure.py
.py
import os import posixpath import uuid import pytest import mlflow from mlflow.utils.file_utils import local_file_uri_to_path from mlflow.utils.os import is_windows @pytest.mark.parametrize("subdir", [None, ".", "dir", "dir1/dir2", "dir/.."]) def test_log_figure_matplotlib(subdir): import matplotlib.pyplot as p...
105
3,517
mlflow
tests/tracking/conftest.py
.py
import pytest import mlflow from mlflow.environment_variables import MLFLOW_ENABLE_ASYNC_TRACE_LOGGING from mlflow.tracing.fluent import _flush_pending_async_trace_writes @pytest.fixture(autouse=True) def enable_async_trace_logging(monkeypatch): """Enable async trace logging for all tests in tests/tracking/ to e...
26
769