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/pydantic_ai/test_pydanticai_v2_tracing.py
.py
import importlib.metadata import pytest from packaging.version import Version if Version(importlib.metadata.version("pydantic_ai")).major < 2: pytest.skip("Pydantic AI 2.x tracing tests", allow_module_level=True) from pydantic import BaseModel, ValidationError from pydantic_ai import Agent, ModelRetry from pydan...
562
18,104
mlflow
tests/pydantic_ai/test_pydanticai_autolog.py
.py
from unittest import mock import pytest from packaging.version import Version import mlflow from mlflow.pydantic_ai import autolog as pydantic_ai_autolog from mlflow.pydantic_ai import autolog_v2 def _call_autolog(**kwargs): # Exercise version dispatch directly, independent of global autologging configuration s...
93
3,040
mlflow
tests/pydantic_ai/test_utils.py
.py
from mlflow.pydantic_ai.utils import parse_usage from mlflow.tracing.constant import TokenUsageKey class _FakeRunUsageWithCache: input_tokens = 1500 output_tokens = 50 total_tokens = 1550 cache_read_tokens = 1200 cache_write_tokens = 300 class _FakeRunUsageNoCache: input_tokens = 1500 ou...
70
1,909
mlflow
tests/pydantic_ai/conftest.py
.py
import pytest import mlflow from tests.tracing.helper import purge_traces @pytest.fixture(autouse=True) def reset_mlflow_autolog_and_traces(): yield mlflow.pydantic_ai.autolog(disable=True) purge_traces() @pytest.fixture(autouse=True) def clear_autolog_state(): from mlflow.utils.autologging_utils ...
28
678
mlflow
tests/keras/test_callback.py
.py
import math import re import keras import numpy as np import mlflow from mlflow.keras.callback import MlflowCallback from mlflow.tracking.fluent import flush_async_logging def test_keras_mlflow_callback_log_every_epoch(): # Prepare data for a 2-class classification. data = np.random.uniform(size=(20, 28, 28...
119
4,027
mlflow
tests/keras/test_autolog.py
.py
import json import math import re import keras import numpy as np import pytest import mlflow from mlflow.models import Model from mlflow.tracking.fluent import flush_async_logging from mlflow.types import Schema, TensorSpec from mlflow.utils.autologging_utils import AUTOLOGGING_INTEGRATIONS @pytest.fixture(autouse...
228
7,642
mlflow
tests/keras/test_save.py
.py
import keras import numpy as np import pytest import mlflow from mlflow.keras.utils import get_model_signature from mlflow.models import ModelSignature from mlflow.types import Schema, TensorSpec def _get_keras_model(): return keras.Sequential([ keras.Input([28, 28, 3]), keras.layers.Flatten(), ...
116
3,986
mlflow
tests/keras/conftest.py
.py
import keras import pytest @pytest.fixture(autouse=True) def clear_keras_session(): # Reset Keras global state before each test so optimizer names aren't uniquified # across tests (a second Adam in the same session becomes "adam_1", which breaks # the optimizer_name assertions in test_autolog.py / test_ca...
14
492
mlflow
tests/h2o/test_h2o_model_export.py
.py
# pep8: disable=E501 import json import os from typing import Any, NamedTuple from unittest import mock import h2o import numpy as np import pandas as pd import pytest import yaml from h2o.estimators.gbm import H2OGradientBoostingEstimator from sklearn import datasets import mlflow import mlflow.h2o import mlflow.py...
391
14,427
mlflow
tests/data/test_code_dataset_source.py
.py
from mlflow.data.code_dataset_source import CodeDatasetSource def test_code_dataset_source_from_path(): tags = { "mlflow_source_type": "NOTEBOOK", "mlflow_source_name": "some_random_notebook_path", } code_datasource = CodeDatasetSource(tags) assert code_datasource.to_dict() == { ...
17
435
mlflow
tests/data/test_artifact_dataset_sources.py
.py
import json import os from unittest import mock import pytest from mlflow.data.dataset_source_registry import get_dataset_source_from_json, resolve_dataset_source from mlflow.data.filesystem_dataset_source import FileSystemDatasetSource from mlflow.store.artifact.s3_artifact_repo import S3ArtifactRepository @pytest...
138
5,771
mlflow
tests/data/test_tensorflow_dataset.py
.py
import json import numpy as np import pytest import tensorflow as tf import mlflow.data from mlflow.data.code_dataset_source import CodeDatasetSource from mlflow.data.evaluation_dataset import EvaluationDataset from mlflow.data.pyfunc_dataset_mixin import PyFuncInputsOutputs from mlflow.data.schema import TensorDatas...
396
15,119
mlflow
tests/data/test_dataset_source_registry.py
.py
from typing import Any from unittest import mock import pytest from mlflow.data.dataset_source_registry import DatasetSourceRegistry from mlflow.exceptions import MlflowException from tests.resources.data.dataset_source import SampleDatasetSource def test_register_entrypoints_and_resolve(tmp_path): from mlflow...
179
7,053
mlflow
tests/data/test_pandas_dataset.py
.py
import json import pandas as pd import pytest import mlflow.data from mlflow.data.code_dataset_source import CodeDatasetSource from mlflow.data.delta_dataset_source import DeltaDatasetSource from mlflow.data.evaluation_dataset import EvaluationDataset from mlflow.data.filesystem_dataset_source import FileSystemDatase...
284
9,563
mlflow
tests/data/test_huggingface_dataset_and_source.py
.py
import json import os import datasets import pandas as pd import pytest from huggingface_hub.errors import HfHubHTTPError import mlflow.data import mlflow.data.huggingface_dataset from mlflow.data.code_dataset_source import CodeDatasetSource from mlflow.data.dataset_source_registry import get_dataset_source_from_json...
293
11,379
mlflow
tests/data/test_polars_dataset.py
.py
from __future__ import annotations import json import re from datetime import date, datetime from pathlib import Path import pandas as pd import polars as pl import pytest from mlflow.data.code_dataset_source import CodeDatasetSource from mlflow.data.evaluation_dataset import EvaluationDataset from mlflow.data.files...
259
9,574
mlflow
tests/data/test_delta_dataset_source.py
.py
import json from unittest import mock import pandas as pd import pytest from mlflow.data.dataset_source_registry import get_dataset_source_from_json from mlflow.data.delta_dataset_source import DeltaDatasetSource from mlflow.exceptions import MlflowException from mlflow.protos.databricks_managed_catalog_messages_pb2 ...
249
9,492
mlflow
tests/data/test_dataset_source.py
.py
import json import pandas as pd import pytest import mlflow.data from mlflow.exceptions import MlflowException from tests.resources.data.dataset_source import SampleDatasetSource def test_load(tmp_path): assert SampleDatasetSource("test:" + str(tmp_path)).load() == str(tmp_path) def test_conversion_to_json_a...
74
2,483
mlflow
tests/data/test_spark_dataset_source.py
.py
import json import pandas as pd import pytest from mlflow.data.dataset_source_registry import get_dataset_source_from_json from mlflow.data.spark_dataset_source import SparkDatasetSource from mlflow.exceptions import MlflowException @pytest.fixture(scope="module") def spark_session(): from pyspark.sql import Sp...
92
3,689
mlflow
tests/data/test_spark_dataset.py
.py
import json import os from typing import TYPE_CHECKING, Any import pandas as pd import pytest from packaging.version import Version import mlflow.data from mlflow.data.code_dataset_source import CodeDatasetSource from mlflow.data.delta_dataset_source import DeltaDatasetSource from mlflow.data.evaluation_dataset impor...
433
15,116
mlflow
tests/data/test_dataset_registry.py
.py
from unittest import mock import pytest import mlflow.data from mlflow.data.dataset import Dataset from mlflow.data.dataset_registry import DatasetRegistry, register_constructor from mlflow.data.dataset_source_registry import DatasetSourceRegistry, resolve_dataset_source from mlflow.exceptions import MlflowException ...
152
5,074
mlflow
tests/data/test_http_dataset_source.py
.py
import json import os from unittest import mock import pandas as pd import pytest from mlflow.data.dataset_source_registry import get_dataset_source_from_json, resolve_dataset_source from mlflow.data.http_dataset_source import HTTPDatasetSource from mlflow.exceptions import MlflowException from mlflow.utils.os import...
189
7,265
mlflow
tests/data/test_numpy_dataset.py
.py
import json import numpy as np import pandas as pd import pytest import mlflow.data from mlflow.data.code_dataset_source import CodeDatasetSource from mlflow.data.evaluation_dataset import EvaluationDataset from mlflow.data.filesystem_dataset_source import FileSystemDatasetSource from mlflow.data.numpy_dataset import...
258
9,429
mlflow
tests/data/test_meta_dataset.py
.py
import json from unittest.mock import patch import pytest pd = pytest.importorskip("pandas") from mlflow.data.delta_dataset_source import DeltaDatasetSource from mlflow.data.http_dataset_source import HTTPDatasetSource from mlflow.data.huggingface_dataset_source import HuggingFaceDatasetSource from mlflow.data.meta_...
120
4,140
mlflow
tests/data/test_dataset.py
.py
import json from mlflow.types.schema import Schema from tests.resources.data.dataset import SampleDataset from tests.resources.data.dataset_source import SampleDatasetSource def test_conversion_to_json(): source_uri = "test:/my/test/uri" source = SampleDatasetSource._resolve(source_uri) dataset = Sample...
43
1,672
mlflow
tests/examples/test_examples.py
.py
import os import re import shutil import sys import uuid from pathlib import Path import pytest import mlflow from mlflow import cli from mlflow.utils import process from mlflow.utils.virtualenv import _get_mlflow_virtualenv_root from tests.helper_functions import clear_hub_cache, flaky, start_mock_openai_server fro...
184
7,271
mlflow
tests/langgraph/test_langgraph_autolog.py
.py
import json import pytest import mlflow from mlflow.entities.span import SpanType from mlflow.entities.span_status import SpanStatusCode from mlflow.tracing.constant import TokenUsageKey, TraceMetadataKey from mlflow.version import IS_TRACING_SDK_ONLY from tests.tracing.helper import get_traces, skip_when_testing_tr...
289
11,022
mlflow
tests/langgraph/test_langgraph_model_export.py
.py
import json import mlflow from mlflow.types.schema import Object, ParamSchema, ParamSpec, Property def test_langgraph_save_as_code(): input_example = {"messages": [{"role": "user", "content": "what is the weather in sf?"}]} with mlflow.start_run(): model_info = mlflow.langchain.log_model( ...
78
3,206
mlflow
tests/langgraph/test_chat_agent_langgraph.py
.py
import json import pytest from langchain_core.messages import AIMessage, ToolMessage import mlflow from mlflow.langchain.chat_agent_langgraph import parse_message from mlflow.types.agent import ChatAgentMessage LC_TOOL_CALL_MSG = AIMessage(**{ "content": "", "additional_kwargs": { "tool_calls": [ ...
283
10,125
mlflow
tests/langgraph/conftest.py
.py
import importlib import openai import pytest from tests.helper_functions import start_mock_openai_server from tests.tracing.helper import reset_autolog_state # noqa: F401 @pytest.fixture(autouse=True) def set_envs(monkeypatch, mock_openai): monkeypatch.setenv("OPENAI_API_KEY", "test") monkeypatch.setenv("O...
28
722
mlflow
tests/langgraph/sample_code/langgraph_chat_agent_custom_inputs.py
.py
import json import os from typing import Any, Generator, Sequence from uuid import uuid4 from langchain_core.language_models import LanguageModelLike from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.runnables import RunnableConfig...
194
6,299
mlflow
tests/langgraph/sample_code/langgraph_with_custom_span.py
.py
from typing import Literal from langchain_core.messages import AIMessage, ToolCall from langchain_core.output_parsers import StrOutputParser from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.prompts import PromptTemplate from langchain_core.tools import tool from langchain_openai import...
60
1,817
mlflow
tests/langgraph/sample_code/langgraph_chat_agent.py
.py
import json import os from typing import Any, Generator, Sequence from langchain_core.language_models import LanguageModelLike from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.runnables import RunnableConfig, RunnableLambda from l...
152
4,670
mlflow
tests/langgraph/sample_code/langgraph_with_autolog.py
.py
from dataclasses import dataclass from langchain.tools import tool from langgraph.graph import END, StateGraph import mlflow mlflow.langchain.autolog() @dataclass class OverallState: name: str = "LangChain" # add whatever fields you need @tool def my_tool(): """ Called as the very first node. Si...
34
778
mlflow
tests/langgraph/sample_code/langgraph_diy.py
.py
# Sample code that contains custom python nodes from typing import Annotated, Sequence, TypedDict from langchain_core.messages import BaseMessage from langchain_openai import ChatOpenAI from langgraph.graph import END, START, StateGraph from langgraph.graph.message import add_messages import mlflow def generate(sta...
47
1,104
mlflow
tests/langgraph/sample_code/langgraph_prebuilt.py
.py
import itertools from typing import Literal from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.tools import tool from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent import mlflow class FakeOp...
50
1,556
mlflow
tests/transformers/test_transformers_autolog.py
.py
import random import numpy as np import optuna import pytest import sklearn.cluster import sklearn.datasets import torch import transformers from datasets import load_dataset from packaging.version import Version from transformers import ( DistilBertForSequenceClassification, DistilBertTokenizerFast, Train...
578
18,175
mlflow
tests/transformers/test_transformers_signature.py
.py
import json import time from unittest import mock import pytest from mlflow.models.signature import ModelSignature from mlflow.transformers import _try_import_conversational_pipeline from mlflow.transformers.signature import ( _TEXT2TEXT_SIGNATURE, format_input_example_for_special_cases, infer_or_get_defa...
199
7,509
mlflow
tests/transformers/test_transformers_llm_inference_utils.py
.py
import uuid from typing import Any, NamedTuple from unittest import mock import pandas as pd import pytest import torch from mlflow.exceptions import MlflowException from mlflow.models import infer_signature from mlflow.transformers.llm_inference_utils import ( _get_default_task_for_llm_inference_task, _get_f...
314
10,571
mlflow
tests/transformers/version.py
.py
import transformers from packaging.version import Version transformers_version = Version(transformers.__version__) IS_NEW_FEATURE_EXTRACTION_API = transformers_version >= Version("4.27.0") IS_TRANSFORMERS_V5_OR_LATER = transformers_version.major >= 5
7
252
mlflow
tests/transformers/test_transformers_model_export.py
.py
import base64 import gc import importlib.util import json import logging import math import os import pathlib import re import shutil import textwrap from contextlib import contextmanager from pathlib import Path from unittest import mock import huggingface_hub import librosa import numpy as np import pandas as pd imp...
3,980
150,812
mlflow
tests/transformers/test_transformers_peft_model.py
.py
import importlib import os import re import pytest import transformers import mlflow from mlflow.exceptions import MlflowException from mlflow.models import Model from mlflow.transformers.flavor_config import FlavorKey from mlflow.transformers.peft import get_peft_base_model, is_peft_model from mlflow.utils.logging_u...
272
9,252
mlflow
tests/transformers/helper.py
.py
import inspect import logging import sys import transformers from packaging.version import Version from mlflow.transformers import _PEFT_PIPELINE_ERROR_MSG, _try_import_conversational_pipeline from mlflow.utils.logging_utils import suppress_logs from tests.helper_functions import flaky from tests.transformers.versio...
341
11,836
mlflow
tests/transformers/test_transformers_prompt_templating.py
.py
from unittest.mock import MagicMock import pytest import transformers import yaml from packaging.version import Version import mlflow from mlflow.exceptions import MlflowException from mlflow.models.model import MLMODEL_FILE_NAME from mlflow.transformers import _SUPPORTED_PROMPT_TEMPLATING_TASK_TYPES, _validate_promp...
241
8,463
mlflow
tests/transformers/test_flavor_configs.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.transformers import _build_pipeline_from_model_input from mlflow.transformers.flavor_config import ( build_flavor_config, update_flavor_conf_to_persist_pretrained_model, ) from mlflow.transformers.torch_utils imp...
187
7,225
mlflow
tests/transformers/conftest.py
.py
import pytest from packaging.version import Version from tests.transformers.helper import ( IS_TRANSFORMERS_V5_OR_LATER, load_audio_classification_pipeline, load_component_multi_modal, load_conversational_pipeline, load_custom_code_pipeline, load_custom_components_pipeline, load_feature_ext...
183
4,842
mlflow
tests/prophet/test_prophet_model_export.py
.py
import json import os from datetime import date, datetime, timedelta from pathlib import Path from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import prophet import pytest import yaml from packaging.version import Version from prophet import Prophet import mlflow imp...
509
18,892
mlflow
tests/agno/test_agno_tracing.py
.py
import sys from unittest.mock import MagicMock, patch import agno import pytest from agno.agent import Agent from agno.exceptions import ModelProviderError from agno.models.anthropic import Claude from agno.tools.function import Function, FunctionCall from anthropic.types import Message, TextBlock, Usage from opentele...
422
15,467
mlflow
tests/agno/conftest.py
.py
import pytest import mlflow @pytest.fixture(autouse=True) def _reset_mlflow(): from mlflow.utils.autologging_utils import AUTOLOGGING_INTEGRATIONS for integ in AUTOLOGGING_INTEGRATIONS.values(): integ.clear() mlflow.utils.import_hooks._post_import_hooks = {} @pytest.fixture(autouse=True) def m...
18
396
mlflow
tests/onnx/test_onnx_model_export.py
.py
import logging import os from pathlib import Path from unittest import mock import numpy as np import onnx import onnxruntime as ort import pandas as pd import pytest import torch import torch.onnx import yaml from packaging.version import Version from sklearn import datasets from torch import nn from torch.utils.data...
946
36,592
mlflow
tests/models/test_container.py
.py
import os from unittest import mock import pytest import yaml from mlflow.models.container import _install_model_dependencies_to_env from mlflow.utils import env_manager as em def _create_model_artifact(model_path, dependencies, build_dependencies=None): """Helper to create a minimal model artifact for testing....
228
7,408
mlflow
tests/models/test_python_api.py
.py
import datetime import json import os import sys from unittest import mock import numpy as np import pandas as pd import pytest import scipy.sparse import mlflow from mlflow.exceptions import MlflowException from mlflow.models.python_api import ( _CONTENT_TYPE_CSV, _CONTENT_TYPE_JSON, _serialize_input_dat...
401
12,834
mlflow
tests/models/test_model_config.py
.py
import os from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.models import ModelConfig dir_path = os.path.dirname(os.path.abspath(__file__)) VALID_CONFIG_PATH = os.path.join(dir_path, "configs/config.yaml") VALID_CONFIG_PATH_2 = os.path.join(dir_path, "configs/config_2....
93
3,666
mlflow
tests/models/test_resources.py
.py
import pytest from mlflow.models.resources import ( DEFAULT_API_VERSION, DatabricksApp, DatabricksFunction, DatabricksGenieSpace, DatabricksLakebase, DatabricksServingEndpoint, DatabricksSQLWarehouse, DatabricksTable, DatabricksUCConnection, DatabricksVectorSearchIndex, _Res...
363
13,623
mlflow
tests/models/test_artifacts.py
.py
import json import pathlib import pickle import numpy as np import pandas as pd import pytest from matplotlib.figure import Figure from mlflow.exceptions import MlflowException from mlflow.models.evaluation.artifacts import ( CsvEvaluationArtifact, ImageEvaluationArtifact, JsonEvaluationArtifact, Nump...
132
4,935
mlflow
tests/models/test_signature.py
.py
import json from dataclasses import asdict, dataclass import numpy as np import pandas as pd import pydantic import pyspark import pytest from sklearn.ensemble import RandomForestRegressor import mlflow from mlflow.exceptions import MlflowException from mlflow.models import Model, ModelSignature, infer_signature, rag...
387
13,706
mlflow
tests/models/test_pyfunc.py
.py
MLFLOW_VERSION = "1.0.0" # we expect this model to be bound to this mlflow version. class PyFuncTestModel: def __init__(self, check_version=True): self._check_version = check_version def predict(self, df): from mlflow.version import VERSION if self._check_version: assert...
19
473
mlflow
tests/models/test_model_input_examples.py
.py
import json import math from io import StringIO from unittest import mock import numpy as np import pandas as pd import pytest import sklearn.linear_model as logreg_module from scipy.sparse import csc_matrix, csr_matrix from sklearn import datasets from sklearn.base import BaseEstimator, ClassifierMixin import mlflow...
454
16,754
mlflow
tests/models/test_display_utils.py
.py
from pathlib import Path from unittest import mock import pytest from mlflow.models import infer_signature from mlflow.models.display_utils import ( _generate_agent_eval_recipe, _should_render_agent_eval_template, ) from mlflow.models.rag_signatures import StringResponse from mlflow.types.llm import ( Cha...
100
3,391
mlflow
tests/models/test_cli.py
.py
import json import os import re import shutil import subprocess import sys import warnings from dataclasses import dataclass from io import BytesIO, StringIO from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pytest import sklearn import sklearn.datasets import sklearn.lin...
1,045
35,512
mlflow
tests/models/test_model.py
.py
import json import os import pathlib import time import uuid from datetime import date from unittest import mock import numpy as np import pandas as pd import pydantic import pytest import sklearn.datasets import sklearn.linear_model from packaging.version import Version from scipy.sparse import csc_matrix import mlf...
787
29,835
mlflow
tests/models/test_utils.py
.py
import os import random from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import pytest import sklearn.linear_model as logreg_module from sklearn import datasets import mlflow from mlflow import MlflowClient from mlflow.entities.model_registry import ModelVersion from...
658
23,191
mlflow
tests/models/test_auth_policy.py
.py
from mlflow.models.auth_policy import AuthPolicy, SystemAuthPolicy, UserAuthPolicy from mlflow.models.resources import ( DatabricksFunction, DatabricksServingEndpoint, DatabricksUCConnection, DatabricksVectorSearchIndex, ) def test_complete_auth_policy(): system_auth_policy = SystemAuthPolicy( ...
121
4,075
mlflow
tests/models/test_wheeled_model.py
.py
import os import random import re from io import BytesIO from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import pytest import sklearn.linear_model as logreg_module import yaml from sklearn import datasets import mlflow import mlflow.pyfunc.scoring_server as pyfunc_s...
509
18,751
mlflow
tests/models/test_dependencies_schema.py
.py
from unittest import mock from mlflow.models import dependencies_schemas from mlflow.models.dependencies_schemas import ( DependenciesSchemas, DependenciesSchemasType, RetrieverSchema, _get_dependencies_schemas, _get_retriever_schema, set_retriever_schema, ) def test_retriever_creation(): ...
287
9,199
mlflow
tests/projects/test_entry_point.py
.py
import os from shlex import quote from unittest import mock import pytest from mlflow.exceptions import ExecutionException from mlflow.projects._project_spec import EntryPoint from mlflow.utils.file_utils import TempDir, path_to_local_file_uri from tests.projects.utils import TEST_PROJECT_DIR, load_project def tes...
263
10,751
mlflow
tests/projects/test_kubernetes.py
.py
from unittest import mock import kubernetes import pytest import yaml from kubernetes.config.config_exception import ConfigException from mlflow.entities import RunStatus from mlflow.exceptions import ExecutionException from mlflow.projects import kubernetes as kb def test_run_command_creation(): command = [ ...
359
13,313
mlflow
tests/projects/utils.py
.py
import filecmp import logging import os import shutil import pytest from mlflow.entities import RunStatus from mlflow.projects import _project_spec from mlflow.utils.file_utils import TempDir, _copy_project TEST_DIR = "tests" TEST_PROJECT_DIR = os.path.abspath(os.path.join(TEST_DIR, "resources", "example_project")) ...
81
2,853
mlflow
tests/projects/test_project_spec.py
.py
import os import textwrap import pytest from mlflow.exceptions import ExecutionException from mlflow.projects import _project_spec from tests.projects.utils import load_project def test_project_get_entry_point(): project = load_project() entry_point = project.get_entry_point("greeter") assert entry_poi...
128
4,450
mlflow
tests/projects/test_databricks.py
.py
import filecmp import json import os import shutil from unittest import mock import pytest import mlflow from mlflow import MlflowClient, cli from mlflow.entities import RunStatus from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.exceptions import MlflowException from mlflow.legacy_databricks_c...
499
18,404
mlflow
tests/projects/test_projects_cli.py
.py
import hashlib import json import logging import os import shutil from pathlib import Path from unittest import mock import pytest from click.testing import CliRunner from mlflow import MlflowClient, cli from mlflow.utils import process from mlflow.utils.environment import _PythonEnv from mlflow.utils.virtualenv impo...
245
8,369
mlflow
tests/projects/test_projects.py
.py
import json import os import shutil import subprocess import uuid from unittest import mock import git import pytest import yaml import mlflow from mlflow import MlflowClient from mlflow.entities import RunStatus, SourceType, ViewType from mlflow.environment_variables import MLFLOW_CONDA_CREATE_ENV_CMD, MLFLOW_CONDA_...
549
19,035
mlflow
tests/projects/test_virtualenv_projects.py
.py
import os from unittest import mock import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.utils.virtualenv import _create_virtualenv from mlflow.utils.yaml_utils import read_yaml, write_yaml from tests.projects.utils import ( TEST_VIRTUALENV_CONDA_PROJECT_DIR, TEST_VIRTUALENV_...
148
4,827
mlflow
tests/projects/test_docker_projects.py
.py
import os from unittest import mock import docker import pytest import mlflow from mlflow import MlflowClient from mlflow.entities import ViewType from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.exceptions import MlflowException from mlflow.legacy_databricks_cli.configure.provider import Data...
331
11,600
mlflow
tests/projects/test_utils.py
.py
import os import tempfile import threading import zipfile from http.server import BaseHTTPRequestHandler, HTTPServer from typing import Generator from unittest import mock import git import pytest import mlflow from mlflow.exceptions import ExecutionException, MlflowException from mlflow.projects import _project_spec...
276
10,245
mlflow
tests/projects/conftest.py
.py
import os import shutil import git import pytest from tests.projects.utils import GIT_PROJECT_BRANCH, TEST_PROJECT_DIR @pytest.fixture def local_git_repo(tmp_path): local_git = str(tmp_path.joinpath("git_repo")) repo = git.Repo.init(local_git) shutil.copytree(src=TEST_PROJECT_DIR, dst=local_git, dirs_ex...
25
657
mlflow
tests/projects/backend/test_loader.py
.py
from mlflow.projects.backend import loader def test_plugin_backend(): backend = loader.load_backend("dummy-backend") assert backend is not None def test_plugin_does_not_exist(): backend = loader.load_backend("my_plugin") assert backend is None
12
264
mlflow
tests/projects/backend/test_local.py
.py
import os from unittest import mock from mlflow.projects.backend.local import _get_docker_artifact_storage_cmd_and_envs def test_docker_s3_artifact_cmd_and_envs_from_env(monkeypatch): mock_env = { "AWS_SECRET_ACCESS_KEY": "mock_secret", "AWS_ACCESS_KEY_ID": "mock_access_key", "MLFLOW_S3_E...
91
3,355
mlflow
tests/db/test_workspace_migration.py
.py
import os import re from contextlib import contextmanager import pytest import sqlalchemy as sa from alembic import command from mlflow.store.db.utils import _get_alembic_config from mlflow.store.tracking.dbmodels.initial_models import Base as InitialBase _LEGACY_REGISTERED_MODEL_TAGS = sa.table( "registered_mod...
1,228
36,303
mlflow
tests/db/test_workspace_move.py
.py
import uuid from pathlib import Path from unittest import mock import pytest import sqlalchemy as sa from mlflow.entities import ExperimentTag, TraceInfo from mlflow.entities.model_registry import ModelVersionTag, RegisteredModelTag from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_s...
762
28,803
mlflow
tests/db/test_tracking_operations.py
.py
import sqlite3 import uuid from unittest import mock import pytest import sqlalchemy.dialects.sqlite.pysqlite import mlflow from mlflow import MlflowClient from mlflow.environment_variables import MLFLOW_TRACKING_URI pytestmark = pytest.mark.notrackingurimock class Model(mlflow.pyfunc.PythonModel): def load_co...
155
5,909
mlflow
tests/db/test_mcp_server_registry.py
.py
from pathlib import Path import pytest from mlflow.entities.mcp_server import MCPStatus from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.store.tracking.sqlalchemy_store import SqlAlchemyStore pytestmark = pytest.mark.notrackingurimock @pytest.fixture def store(tmp_path: Path): artifact_...
161
5,343
mlflow
tests/db/test_schema.py
.py
import difflib import logging import re from pathlib import Path from typing import NamedTuple import pytest from sqlalchemy import create_engine, inspect from sqlalchemy.schema import CreateTable, MetaData, UniqueConstraint _logger = logging.getLogger(__name__) _DIALECT_REFLECTED_UNIQUE_CONSTRAINTS = { "mysql":...
257
8,207
mlflow
tests/db/check_migration.py
.py
""" Usage ----- export MLFLOW_TRACKING_URI=sqlite:///mlruns.db # pre migration python tests/db/check_migration.py pre-migration # post migration python tests/db/check_migration.py post-migration """ import os import uuid from pathlib import Path import click import pandas as pd import sqlalchemy as sa import mlflo...
188
5,490
mlflow
tests/db/conftest.py
.py
import pytest from mlflow.environment_variables import MLFLOW_TRACKING_URI @pytest.fixture(autouse=True) def use_sqlite_if_tracking_uri_env_var_is_not_set(tmp_path, monkeypatch): if not MLFLOW_TRACKING_URI.defined: sqlite_file = tmp_path / "mlruns.sqlite" monkeypatch.setenv(MLFLOW_TRACKING_URI.na...
11
352
mlflow
tests/types/test_type_hints.py
.py
import datetime from typing import Any, Dict, List, Optional, Union, get_args from unittest import mock import numpy as np import pandas as pd import pydantic import pytest from scipy.sparse import csc_matrix, csr_matrix from mlflow.exceptions import MlflowException from mlflow.models.utils import PyFuncOutput, _enfo...
510
18,021
mlflow
tests/types/test_genai_types.py
.py
import pytest from pydantic import ValidationError from mlflow.types.chat import ChatCompletionResponse def test_instantiation_chat_completion(): response_structure = { "id": "1", "object": "1", "created": 1, "model": "model", "choices": [ { "in...
91
3,043
mlflow
tests/types/test_schema.py
.py
import datetime import json import math import re from dataclasses import dataclass, field from typing import Optional import numpy as np import pandas as pd import pyspark import pyspark.sql.types as T import pytest from scipy.sparse import csc_matrix, csr_matrix from mlflow.exceptions import MlflowException from ml...
2,007
71,028
mlflow
tests/helpers/db_mocks.py
.py
from __future__ import annotations from contextlib import contextmanager from unittest import mock def mock_get_managed_session_maker(*args, **kwargs): @contextmanager def _manager(): session = mock.MagicMock() def _mock_query(*q_args, **q_kwargs): query = mock.MagicMock() ...
25
661
mlflow
tests/claude_code/test_config.py
.py
import json import pytest from mlflow.claude_code.config import ( MLFLOW_TRACING_ENABLED, get_env_var, get_tracing_status, load_claude_config, save_claude_config, setup_environment_config, ) @pytest.fixture def temp_settings_path(tmp_path): """Provide a temporary settings.json path for t...
334
11,671
mlflow
tests/claude_code/test_tracing.py
.py
import importlib import json import logging from pathlib import Path import pytest from claude_agent_sdk.types import ( AssistantMessage, ResultMessage, TextBlock, ToolResultBlock, ToolUseBlock, UserMessage, ) import mlflow import mlflow.claude_code.tracing as tracing_module from mlflow.claude...
906
30,720
mlflow
tests/claude_code/test_autolog.py
.py
import sys from unittest.mock import MagicMock, patch import pytest from claude_agent_sdk.types import AssistantMessage, ResultMessage, TextBlock, UserMessage import mlflow.anthropic from mlflow.anthropic.autolog import patched_claude_sdk_init def test_anthropic_autolog_without_claude_sdk(): sys.modules.pop("cl...
138
4,426
mlflow
tests/claude_code/test_plugin.py
.py
import json import subprocess from unittest import mock import click import pytest from mlflow.claude_code.plugin import disable_tracing_plugin, ensure_plugin_installed def test_disable_tracing_plugin_removes_env_only(tmp_path): settings_path = tmp_path / ".claude" / "settings.json" settings_path.parent.mkd...
50
1,753
mlflow
tests/claude_code/test_cli.py
.py
import json from pathlib import Path from unittest import mock import pytest from click.testing import CliRunner from mlflow.claude_code.cli import commands @pytest.fixture def runner(): return CliRunner() @pytest.fixture(autouse=True) def _clear_mlflow_env(monkeypatch): for name in ( "MLFLOW_TRAC...
225
8,108
mlflow
tests/pmdarima/test_pmdarima_model_export.py
.py
import json import os from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pmdarima import pytest import yaml import mlflow.pmdarima import mlflow.pyfunc.scoring_server as pyfunc_scoring_server from mlflow import pyfunc from mlflow.exceptions import MlflowException from mlf...
484
19,484
mlflow
tests/crewai/test_crewai_autolog.py
.py
import json from unittest.mock import ANY, Mock, patch import crewai import pytest from crewai import Agent, Crew, Task from crewai.flow.flow import Flow, start from crewai.tools import BaseTool from packaging.version import Version import mlflow from mlflow.crewai.autolog import patched_class_call, patched_standalon...
724
22,567
mlflow
tests/agent/test_prompt.py
.py
from __future__ import annotations from pathlib import Path import pytest from mlflow.agent.agents import AGENTS from mlflow.agent.setup.prompt import _render, build_prompt def test_render_substitutes_placeholder(): assert _render("hello {{ name }}", name="world") == "hello world" def test_render_accepts_no_...
114
3,798
mlflow
tests/agent/test_cli.py
.py
from __future__ import annotations import json import subprocess from pathlib import Path from unittest import mock import click import pytest from click.testing import CliRunner from mlflow.agent.agents import AGENTS from mlflow.agent.setup.cli import _git_root, _is_localhost_tracking_uri, setup from mlflow.telemet...
564
22,807
mlflow
tests/shap/test_log.py
.py
import json from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pytest import shap import sklearn from numba import njit from packaging.version import Version from sklearn.datasets import load_diabetes import mlflow import mlflow.pyfunc.scoring_server as pyfunc_scoring_ser...
515
18,036
mlflow
tests/shap/test_shap.py
.py
import os from typing import Any, NamedTuple import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest import shap from sklearn.datasets import load_diabetes, load_iris from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor import mlflow from mlflow import MlflowClient f...
265
9,075