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/artifact/test_hdfs_artifact_repo.py
.py
import sys from unittest import mock from unittest.mock import call import pyarrow import pytest from mlflow.entities import FileInfo from mlflow.store.artifact.hdfs_artifact_repo import ( HdfsArtifactRepository, _parse_extra_conf, _relative_path_remote, _resolve_base_path, ) @pytest.fixture def hdf...
224
7,724
mlflow
tests/store/artifact/test_artifact_repository_registry.py
.py
from importlib import reload from unittest import mock import pytest import mlflow from mlflow.store.artifact import artifact_repository_registry from mlflow.store.artifact.artifact_repository_registry import ArtifactRepositoryRegistry def test_standard_artifact_registry(): mock_entrypoint = mock.Mock() moc...
117
4,103
mlflow
tests/store/artifact/test_http_artifact_repo.py
.py
import os import posixpath import shutil from unittest import mock import pytest from requests import HTTPError from mlflow.entities.multipart_upload import ( CreateMultipartUploadResponse, MultipartUploadCredential, MultipartUploadPart, ) from mlflow.entities.presigned_download import PresignedDownloadUr...
802
28,154
mlflow
tests/store/artifact/test_models_artifact_repo.py
.py
from pathlib import Path from unittest import mock import pytest from mlflow import MlflowClient from mlflow.entities.model_registry import ModelVersion from mlflow.environment_variables import MLFLOW_TRACE_ARCHIVAL_CONFIG from mlflow.store.artifact.databricks_models_artifact_repo import DatabricksModelsArtifactRepos...
312
12,087
mlflow
tests/store/artifact/test_ftp_artifact_repo.py
.py
import ftplib import posixpath from ftplib import FTP from unittest.mock import MagicMock import pytest from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository from mlflow.store.artifact.ftp_artifact_repo import FTPArtifactRepository @pytest.fixture def ftp_mock(): return MagicMoc...
423
13,952
mlflow
tests/store/artifact/test_presigned_url_artifact_repo.py
.py
import json import os import random import string from unittest import mock from unittest.mock import ANY import pytest import requests from mlflow.environment_variables import MLFLOW_MULTIPART_DOWNLOAD_CHUNK_SIZE from mlflow.exceptions import RestException from mlflow.protos.databricks_artifacts_pb2 import ArtifactC...
364
13,972
mlflow
tests/store/artifact/test_dbfs_artifact_repo_delegation.py
.py
import os from unittest import mock import pytest from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository from mlflow.store.artifact.databricks_run_artifact_repo import DatabricksRunArtifactRepository from mlflow.store.artifact.dbfs_artifact_repo import DbfsRestArtifactRepository from m...
56
2,532
mlflow
tests/store/artifact/test_unity_catalog_oss_models_artifact_repo.py
.py
import json from unittest import mock from unittest.mock import ANY from requests import Response from mlflow import MlflowClient from mlflow.store.artifact.optimized_s3_artifact_repo import OptimizedS3ArtifactRepository from mlflow.store.artifact.unity_catalog_oss_models_artifact_repo import ( UnityCatalogOSSMod...
84
3,350
mlflow
tests/store/artifact/test_mlflow_artifact_repo.py
.py
import os import posixpath import threading import time from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository from mlflow.store.artifact.mlflow_artifacts_repo import MlflowArtifactsRepository from ml...
595
20,724
mlflow
tests/store/artifact/test_dbfs_artifact_repo.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.store.artifact.databricks_run_artifact_repo import DatabricksRunArtifactRepository from mlflow.store.artifact.dbfs_artifact_repo import ( DbfsRestArtifactRepository, dbfs_artifact_repo_factory, ) from mlflow.stor...
83
3,429
mlflow
tests/store/artifact/test_cli.py
.py
import json import pathlib from unittest import mock import pytest from click.testing import CliRunner import mlflow from mlflow.entities import FileInfo from mlflow.store.artifact.cli import _file_infos_to_json, download_artifacts from mlflow.tracking.artifact_utils import _download_artifact_from_uri @pytest.fixtu...
140
5,083
mlflow
tests/store/artifact/test_databricks_sdk_models_artifact_repo.py
.py
import io from types import SimpleNamespace from unittest import mock import pytest from databricks.sdk import WorkspaceClient from databricks.sdk.errors.platform import NotFound from databricks.sdk.service.files import DirectoryEntry, DownloadResponse from mlflow.entities.file_info import FileInfo from mlflow.entiti...
283
11,267
mlflow
tests/store/artifact/test_local_artifact_repo.py
.py
import io import json import os import pathlib import posixpath import stat from unittest import mock import pytest from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from mlflow.entities.span import Span, SpanAttributeKey from mlflow.entities.trace_data import TraceData from mlflow.exceptions impor...
683
26,418
mlflow
tests/store/artifact/test_r2_artifact_repo.py
.py
import posixpath from unittest import mock from unittest.mock import ANY import pytest from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository from mlflow.store.artifact.s3_artifact_repo import _cached_get_s3_client from tests.helper_functions import set_boto_credentials # noqa: F401 ...
92
3,204
mlflow
tests/store/artifact/test_azure_blob_artifact_repo.py
.py
import base64 import json import os import posixpath from unittest import mock import pytest from azure.core.exceptions import ResourceNotFoundError from azure.storage.blob import BlobPrefix, BlobProperties, BlobServiceClient from mlflow.entities.multipart_upload import MultipartUploadPart from mlflow.exceptions impo...
608
24,396
mlflow
tests/store/artifact/test_dbfs_fuse_artifact_repo.py
.py
import os from unittest import mock from unittest.mock import PropertyMock import pytest from mlflow.store.artifact.artifact_repository_registry import get_artifact_repository TEST_FILE_1_CONTENT = "Hello 🍆🍔".encode() TEST_FILE_2_CONTENT = "World 🍆🍔🍆".encode() TEST_FILE_3_CONTENT = "¡🍆🍆🍔🍆🍆!".encode() @py...
135
4,493
mlflow
tests/store/artifact/test_databricks_sdk_artifact_repo.py
.py
import importlib.metadata from unittest import mock import pytest from mlflow.store.artifact.databricks_sdk_artifact_repo import _sdk_supports_large_file_uploads def test_sdk_supports_large_file_uploads_true(): with mock.patch("importlib.metadata.version", return_value="0.45.0") as mock_version: assert ...
33
1,265
mlflow
tests/store/artifact/test_runs_artifact_repo.py
.py
from unittest import mock from unittest.mock import Mock import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.store.artifact.runs_artifact_repo import RunsArtifactRepository from mlflow.store.artifact.s3_artifact_repo import S3ArtifactRepository from mlflow.store.entities.paged_list i...
169
6,852
mlflow
tests/store/artifact/test_s3_artifact_repo.py
.py
import json import os import posixpath import tarfile import urllib.parse from datetime import datetime, timezone from unittest import mock from unittest.mock import ANY import botocore.exceptions import pytest import requests from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from mlflow.entities i...
1,163
45,245
mlflow
tests/store/artifact/utils/test_model_utils.py
.py
from unittest import mock import pytest from mlflow import MlflowClient from mlflow.entities.model_registry import ModelVersion from mlflow.exceptions import MlflowException from mlflow.store.artifact.utils.models import _parse_model_uri, get_model_name_and_version from mlflow.tracking._model_registry.client import M...
256
9,894
mlflow
tests/store/model_registry/test_abstract_store.py
.py
import json import threading import time from unittest import mock import pytest from mlflow.entities.logged_model import LoggedModel from mlflow.entities.logged_model_tag import LoggedModelTag from mlflow.entities.model_registry.model_version import ModelVersion from mlflow.entities.model_registry.model_version_tag ...
741
25,029
mlflow
tests/store/model_registry/test_sqlalchemy_store.py
.py
import concurrent.futures import shutil import time import uuid from pathlib import Path from unittest import mock import pytest from sqlalchemy import create_engine, text from mlflow.entities.model_registry import ( ModelVersion, ModelVersionTag, RegisteredModelTag, ) from mlflow.entities.model_registry....
2,540
97,722
mlflow
tests/store/model_registry/test_rest_store_workspace.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.store.model_registry.rest_store import RestStore from mlflow.utils.rest_utils import MlflowHostCreds ACTIVE_WORKSPACE = "team-a" def test_model_registry_rest_store_workspace_guard(): creds = MlflowHostCreds("https...
26
756
mlflow
tests/store/model_registry/test_file_store.py
.py
import pytest pytestmark = pytest.mark.skip(reason="FileStore is no longer supported") import time import uuid from typing import NamedTuple from unittest import mock import pytest import mlflow from mlflow.entities.model_registry import ( ModelVersion, ModelVersionTag, RegisteredModelTag, ) from mlflow...
1,903
74,340
mlflow
tests/store/model_registry/test_sqlalchemy_workspace_store.py
.py
import shutil import uuid import pytest from mlflow.entities.model_registry import ModelVersionTag, RegisteredModelTag from mlflow.entities.webhook import WebhookAction, WebhookEntity, WebhookEvent from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES from mlflow.exceptions import MlflowException from mlf...
382
17,001
mlflow
tests/store/model_registry/test_rest_store.py
.py
import json import uuid from unittest import mock import pytest from mlflow.entities.model_registry import ModelVersion, ModelVersionTag, RegisteredModelTag from mlflow.entities.model_registry.model_version_status import ModelVersionStatus from mlflow.exceptions import MlflowException from mlflow.prompt.registry_util...
517
16,369
mlflow
tests/store/model_registry/test_rest_store_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...
215
8,743
mlflow
tests/store/model_registry/test_read_write_routing.py
.py
import shutil from pathlib import Path import pytest import sqlalchemy import sqlalchemy.orm from mlflow.store.db.utils import _get_routing_session_maker from mlflow.store.model_registry.sqlalchemy_store import SqlAlchemyStore @pytest.fixture def write_db_uri(tmp_path: Path) -> str: return f"sqlite:///{tmp_path...
158
5,299
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