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/gateway/test_guardrail_utils.py
.py
import json from unittest import mock import pytest from mlflow.entities.gateway_guardrail import ( GatewayGuardrail, GatewayGuardrailConfig, GuardrailAction, GuardrailStage, ) from mlflow.entities.scorer import ScorerVersion from mlflow.gateway.guardrail_utils import ( load_guardrails, run_po...
356
12,676
mlflow
tests/gateway/test_gateway_budget.py
.py
from unittest.mock import MagicMock, patch import fastapi import pytest import mlflow import mlflow.gateway.budget_tracker as _bt_module from mlflow.entities import SpanStatusCode, SpanType from mlflow.entities.gateway_budget_policy import ( BudgetAction, BudgetDuration, BudgetDurationUnit, BudgetTarg...
781
28,015
mlflow
tests/gateway/test_guardrails.py
.py
import json import uuid from typing import Any from unittest import mock import pytest import mlflow from mlflow.entities import SpanType from mlflow.entities.assessment import Feedback from mlflow.entities.gateway_guardrail import GuardrailAction, GuardrailStage from mlflow.gateway.guardrails import GuardrailViolati...
673
24,352
mlflow
tests/gateway/tools.py
.py
import asyncio import json import os import signal import subprocess import sys import threading import time from pathlib import Path from typing import Any, NamedTuple from unittest import mock import aiohttp import requests import uvicorn import yaml from sentence_transformers import SentenceTransformer import mlfl...
293
8,839
mlflow
tests/gateway/test_cli.py
.py
import pytest from click.testing import CliRunner from mlflow.gateway import cli as gateway_cli from mlflow.gateway.cli import start def test_start_help(): runner = CliRunner() res = runner.invoke( start, ["--help"], catch_exceptions=False, ) assert res.exit_code == 0 def te...
71
1,831
mlflow
tests/gateway/test_redis_budget_tracker.py
.py
from datetime import datetime, timedelta, timezone from unittest.mock import patch import pytest from mlflow.entities.gateway_budget_policy import ( BudgetAction, BudgetDuration, BudgetDurationUnit, BudgetTargetScope, BudgetUnit, GatewayBudgetPolicy, ) from mlflow.gateway.budget_tracker import...
429
13,399
mlflow
tests/gateway/test_utils.py
.py
import pytest from fastapi import HTTPException from mlflow.exceptions import MlflowException from mlflow.gateway.exceptions import AIGatewayException from mlflow.gateway.utils import ( SearchRoutesToken, _is_valid_uri, assemble_uri_path, check_configuration_route_name_collisions, get_gateway_uri, ...
411
12,323
mlflow
tests/gateway/schemas/test_completions.py
.py
import time import pydantic import pytest from mlflow.gateway.schemas import completions def test_completions_request(): completions.RequestPayload(**{"prompt": "prompt"}) completions.RequestPayload(**{"prompt": ""}) completions.RequestPayload(**{"prompt": "", "extra": "extra", "temperature": 2.0}) ...
136
3,773
mlflow
tests/gateway/schemas/test_chat.py
.py
import pydantic import pytest from mlflow.gateway.schemas import chat def test_chat_request(): chat.RequestPayload(**{ "messages": [{"role": "user", "content": "content"}], }) chat.RequestPayload(**{ "messages": [ { "role": "user", "content": [ ...
277
8,754
mlflow
tests/gateway/schemas/test_embeddings.py
.py
import pydantic import pytest from mlflow.gateway.schemas import embeddings def test_embeddings_request(): embeddings.RequestPayload(**{"input": "text"}) embeddings.RequestPayload(**{"input": ""}) embeddings.RequestPayload(**{"input": ["prompt"]}) embeddings.RequestPayload(**{"input": "text", "extra"...
37
1,231
mlflow
tests/gateway/providers/test_palm.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig from mlflow.gateway.exceptions imp...
388
12,131
mlflow
tests/gateway/providers/test_mlflow.py
.py
from unittest import mock import pydantic import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig, MlflowModelServingConfig from mlflow.gateway.constants...
320
11,303
mlflow
tests/gateway/providers/test_openai_compatible.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig, _OpenAICompatibleConfig from mlflow.gateway.providers.base import PassthroughAction from mlflow.gateway.providers.openai_compatible import ( OpenAICompatibleAdapter, OpenAICo...
504
16,117
mlflow
tests/gateway/providers/test_openai.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.exceptions import MlflowException from mlflow.gateway.config import End...
1,498
53,664
mlflow
tests/gateway/providers/test_cohere.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig from mlflow.gateway.exceptions imp...
641
20,625
mlflow
tests/gateway/providers/test_togetherai.py
.py
import textwrap from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig from mlflow.gateway.exceptions import AIGatewayExceptio...
599
22,238
mlflow
tests/gateway/providers/test_databricks.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.base import PassthroughAction from mlflow.gateway.providers.databricks import DatabricksConfig, DatabricksProvider from mlflow.gateway.schemas import cha...
355
12,210
mlflow
tests/gateway/providers/test_bedrock.py
.py
import io from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import ( AmazonBedrockConfig, AWSBaseConfig, AWSIdAndKey, AWSRole, EndpointConfig, ) from mlflow.gateway.exceptions import AIGatewayException from mlflow.gateway.providers.bed...
790
27,724
mlflow
tests/gateway/providers/test_ollama.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.ollama import OllamaConfig, OllamaProvider from mlflow.gateway.schemas import chat, embeddings from tests.gateway.tools import MockAsyncResponse, mock_h...
119
3,430
mlflow
tests/gateway/providers/test_litellm.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.base import PassthroughAction from mlflow.gateway.providers.litellm import LiteLLMAdapter, LiteLLMProvider from mlflow.gateway.schemas import chat, embed...
989
33,619
mlflow
tests/gateway/providers/test_openrouter.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.openrouter import OpenRouterProvider from mlflow.gateway.schemas import chat from tests.gateway.tools import MockAsyncResponse, mock_http_client def _...
77
2,193
mlflow
tests/gateway/providers/test_provider_utils.py
.py
from unittest import mock import pytest from mlflow.gateway.providers.utils import ( SUPPORTED_ACCEPT_ENCODING, _aiohttp_post, proxy_root_url, rename_payload_keys, ) from tests.gateway.tools import MockAsyncResponse, mock_http_client def test_rename_payload_keys(): payload = {"old_key1": "value...
123
4,567
mlflow
tests/gateway/providers/test_anthropic.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig from mlflow.gateway.constants impo...
1,698
61,276
mlflow
tests/gateway/providers/test_openai_uc_functions.py
.py
# TODO: ADD MORE TESTS import json from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.openai import OpenAIProvider from mlflow.gateway.schemas import chat from mlflow.gateway.uc_function_utils import ( ...
451
14,855
mlflow
tests/gateway/providers/test_traffic_route_provider.py
.py
from typing import Any import pytest from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.base import TrafficRouteProvider from tests.gateway.providers.test_openai import ( _run_test_chat, _run_test_chat_stream, _run_test_completions, _run_test_completions_stream, _run_t...
76
2,170
mlflow
tests/gateway/providers/test_tracing.py
.py
import time from typing import Any from unittest import mock import pytest import mlflow from mlflow.entities.trace_state import TraceState from mlflow.gateway.providers.base import BaseProvider, PassthroughAction from mlflow.gateway.schemas import chat, embeddings from mlflow.tracing.client import TracingClient from...
507
18,248
mlflow
tests/gateway/providers/test_huggingface.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig from mlflow.gateway.exceptions import AIGatewayException from mlflow.ga...
172
5,957
mlflow
tests/gateway/providers/test_vertex_ai.py
.py
import json from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig, VertexAIConfig from m...
673
23,990
mlflow
tests/gateway/providers/test_groq.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.groq import GroqProvider from mlflow.gateway.schemas import chat from tests.gateway.tools import MockAsyncResponse, mock_http_client def _make_provide...
78
2,182
mlflow
tests/gateway/providers/test_ai21labs.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.exceptions import MlflowException from mlflow.gateway.config import EndpointConfig from mlflow.gateway.excep...
190
6,045
mlflow
tests/gateway/providers/test_fallback.py
.py
from typing import Any from unittest import mock import pytest from fastapi import HTTPException from mlflow.entities.gateway_endpoint import FallbackStrategy from mlflow.gateway.config import EndpointConfig from mlflow.gateway.exceptions import AIGatewayException from mlflow.gateway.providers.base import FallbackPro...
321
10,296
mlflow
tests/gateway/providers/test_deepseek.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.deepseek import DeepSeekProvider from mlflow.gateway.schemas import chat from tests.gateway.tools import MockAsyncResponse, mock_http_client def _make...
77
2,152
mlflow
tests/gateway/providers/test_mistral.py
.py
import math from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.gateway.config import EndpointConfig from mlflow.gateway.ex...
447
14,753
mlflow
tests/gateway/providers/test_portkey.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig, PortkeyConfig from mlflow.gateway.providers.portkey import PortkeyProvider from mlflow.gateway.schemas import chat from tests.gateway.tools import MockAsyncResponse, mock_http_clien...
156
5,544
mlflow
tests/gateway/providers/test_gemini.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.exceptions import AIGatewayException from mlflow.gateway.providers.base import PassthroughAction from mlflow.gateway.providers.gemini import GeminiAdapter, GeminiP...
1,714
55,354
mlflow
tests/gateway/providers/test_xai.py
.py
from unittest import mock import pytest from fastapi.encoders import jsonable_encoder from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.xai import XAIProvider from mlflow.gateway.schemas import chat from tests.gateway.tools import MockAsyncResponse, mock_http_client def _make_provider(...
78
2,128
mlflow
tests/gateway/providers/test_mosaicml.py
.py
from unittest import mock import pytest from aiohttp import ClientTimeout from fastapi import HTTPException from fastapi.encoders import jsonable_encoder from pydantic import ValidationError from mlflow import MlflowException from mlflow.environment_variables import MLFLOW_GATEWAY_ROUTE_TIMEOUT_SECONDS from mlflow.ga...
567
18,649
mlflow
tests/gateway/providers/test_sap_ai_core.py
.py
from typing import Any from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.gateway.config import EndpointConfig from mlflow.gateway.providers.sap_ai_core import ( SapAiCoreAdapter, SapAiCoreConfig, SapAiCoreProvider, ) def _make_endpoint_config(model_name: s...
371
12,817
mlflow
tests/xgboost/test_xgboost_autolog.py
.py
import functools import json import os import pickle from unittest import mock import matplotlib as mpl import numpy as np import pandas as pd import pytest import xgboost as xgb import yaml from packaging.version import Version from sklearn import datasets import mlflow import mlflow.xgboost from mlflow import Mlflo...
787
27,912
mlflow
tests/xgboost/test_xgboost_model_export.py
.py
import json import os from pathlib import Path from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import pytest import xgboost as xgb import yaml from sklearn import datasets from sklearn.pipeline import Pipeline import mlflow.pyfunc.scoring_server as pyfunc_scoring_se...
696
27,191
mlflow
tests/sklearn/test_sklearn_autolog_without_matplotlib.py
.py
from unittest import mock import pytest from sklearn.datasets import load_breast_cancer from sklearn.ensemble import RandomForestClassifier import mlflow from mlflow import MlflowClient from tests.helper_functions import AnyStringWith def is_matplotlib_installed(): try: import matplotlib # noqa: F401 ...
46
1,293
mlflow
tests/sklearn/test_sklearn_autolog.py
.py
import contextlib import doctest import functools import inspect import json import pickle import re from unittest import mock import joblib import matplotlib.pyplot as plt import numpy as np import pandas as pd import polars as pl import pytest import sklearn import sklearn.base import sklearn.cluster import sklearn....
1,858
68,205
mlflow
tests/sklearn/test_sklearn_model_export.py
.py
import json import os import pickle import shutil import tempfile from pathlib import Path from typing import Any, NamedTuple from unittest import mock import cloudpickle import numpy as np import pandas as pd import pytest import sklearn import sklearn.linear_model as glm import sklearn.naive_bayes as nb import sklea...
1,024
38,920
mlflow
tests/assistant/test_tool_executor.py
.py
import asyncio import pytest from mlflow.assistant.config import PermissionsConfig from mlflow.assistant.providers.tool_executor import execute_tool @pytest.fixture def workspace(tmp_path): src = tmp_path / "src" src.mkdir() (src / "main.py").write_text("print('hello')") (tmp_path / "README.md").wri...
104
3,075
mlflow
tests/assistant/test_skill_installer.py
.py
from unittest import mock from mlflow.assistant.skill_installer import ( install_skills, list_bundled_skills, list_installed_skills, ) def test_install_skills_copies_to_destination(tmp_path): destination = tmp_path / "skills" installed = install_skills(destination) assert destination.exists(...
70
1,994
mlflow
tests/assistant/test_custom_view.py
.py
import json from unittest.mock import patch import pytest from pydantic import ValidationError from mlflow.assistant.custom_view import ( CUSTOM_VIEW_RESPONSE_SCHEMA, STRINGIFIED_CUSTOM_VIEW_RESPONSE_SCHEMA, custom_view_response_events, parse_custom_view_response, ) from mlflow.assistant.types import ...
130
4,117
mlflow
tests/assistant/test_gateway_connection.py
.py
from types import SimpleNamespace from unittest import mock import pytest from mlflow.assistant.gateway_connection import ensure_gateway_connection from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import RESOURCE_DOES_NOT_EXIST def _not_found() -> MlflowException: return MlflowExc...
77
2,769
mlflow
tests/assistant/test_config.py
.py
from unittest.mock import patch import pytest from mlflow.assistant.config import AssistantConfig, PermissionsConfig from mlflow.assistant.providers import OllamaProvider from mlflow.assistant.providers.base import clear_config_cache @pytest.fixture(autouse=True) def config_file(tmp_path): config_path = tmp_pat...
95
3,271
mlflow
tests/assistant/test_cli.py
.py
import os from unittest import mock import pytest from click.testing import CliRunner from mlflow.assistant.cli import commands from mlflow.assistant.config import ProviderConfig @pytest.fixture def runner(): return CliRunner() def test_assistant_help(runner): result = runner.invoke(commands, ["--help"]) ...
212
6,868
mlflow
tests/assistant/test_types.py
.py
import json import pytest from mlflow.assistant.types import Event, EventType @pytest.mark.parametrize( ("exc", "expected"), [ (NotImplementedError(), "NotImplementedError()"), (ValueError(), "ValueError()"), (RuntimeError("boom"), "boom"), (ValueError("bad value"), "bad valu...
61
2,012
mlflow
tests/assistant/providers/test_openai_compatible_provider.py
.py
import json from typing import Any from unittest.mock import AsyncMock, MagicMock, patch import pytest from mlflow.assistant.config import PermissionsConfig from mlflow.assistant.providers.base import clear_config_cache from mlflow.assistant.providers.ollama import OllamaProvider from mlflow.assistant.providers.opena...
1,231
44,868
mlflow
tests/assistant/providers/test_codex_provider.py
.py
import json import os from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch import pytest from mlflow.assistant.providers.base import clear_config_cache from mlflow.assistant.providers.codex import CodexProvider from mlflow.assistant.types import EventType def _make_stdout_lines(*dicts) -> ...
808
27,553
mlflow
tests/assistant/providers/test_ollama_provider.py
.py
import json from unittest.mock import MagicMock, patch import pytest from mlflow.assistant.providers import OllamaProvider, list_providers from mlflow.assistant.providers.base import ( ProviderNotConfiguredError, clear_config_cache, ) def _ollama_provider(): for p in list_providers(): if p.name ...
96
3,235
mlflow
tests/assistant/providers/test_mlflow_gateway_provider.py
.py
from types import SimpleNamespace from unittest import mock import pytest from mlflow.assistant.providers import MlflowGatewayProvider, list_providers def _gateway_provider(): for p in list_providers(): if p.name == MlflowGatewayProvider.GATEWAY_PROVIDER_NAME: return p raise AssertionErr...
67
2,476
mlflow
tests/assistant/providers/test_claude_code_provider.py
.py
import errno import json import subprocess import tempfile from pathlib import Path from unittest.mock import AsyncMock, MagicMock, patch import pytest from mlflow.assistant.providers.base import NotAuthenticatedError from mlflow.assistant.providers.claude_code import ClaudeCodeProvider from mlflow.assistant.types im...
861
28,015
mlflow
tests/assistant/providers/test_provider_resolution.py
.py
import pytest from mlflow.assistant.providers import ( ClaudeCodeProvider, CodexProvider, MlflowGatewayProvider, OllamaProvider, resolve_default_provider, ) _PROVIDERS = { "claude_code": ClaudeCodeProvider, "codex": CodexProvider, "mlflow_gateway": MlflowGatewayProvider, "ollama": ...
67
1,811
mlflow
tests/dspy/test_dspy_evaluate.py
.py
import importlib.metadata import dspy import pandas as pd import pytest from dspy.utils.dummies import DummyLM from packaging.version import Version import mlflow from mlflow.tracing.constant import TraceMetadataKey from tests.openai.test_openai_evaluate import purge_traces from tests.tracing.helper import get_trace...
143
4,418
mlflow
tests/dspy/test_dspy_util.py
.py
import importlib.metadata import json import dspy import pytest from packaging.version import Version import mlflow from mlflow.dspy.util import ( log_dspy_dataset, log_dspy_lm_state, log_dspy_module_params, sanitize_params, save_dspy_module_state, ) from mlflow.tracking import MlflowClient @pyt...
145
4,748
mlflow
tests/dspy/test_dspy_autolog.py
.py
import importlib import json import time from unittest import mock import dspy import dspy.teleprompt import pytest from dspy.evaluate import Evaluate from dspy.evaluate.metrics import answer_exact_match from dspy.predict import Predict from dspy.primitives.example import Example from dspy.teleprompt import BootstrapF...
1,234
42,170
mlflow
tests/dspy/test_save.py
.py
import importlib import json from unittest import mock import dspy import dspy.teleprompt import pytest from dspy.utils.dummies import DummyLM, dummy_rm from packaging.version import Version import mlflow from mlflow.exceptions import MlflowException from mlflow.models import Model, ModelSignature from mlflow.types.s...
624
21,010
mlflow
tests/dspy/conftest.py
.py
import dspy import pytest @pytest.fixture(autouse=True) def reset_dspy_settings(): dspy.settings.configure(callbacks=[], lm=None, adapter=None)
8
150
mlflow
tests/cli/test_skills.py
.py
from pathlib import Path from unittest import mock import pytest from click.testing import CliRunner from mlflow.assistant.skill_installer import BundledSkill from mlflow.cli.skills import commands @pytest.fixture def runner(): return CliRunner() @pytest.fixture def mock_bundled_skills(): with mock.patch(...
80
2,576
mlflow
tests/cli/test_ai_commands.py
.py
from unittest import mock from click.testing import CliRunner from mlflow.cli import cli def test_list_commands_cli(): mock_commands = [ { "key": "genai/analyze_experiment", "namespace": "genai", "description": "Analyzes an MLflow experiment", }, { ...
204
6,609
mlflow
tests/cli/test_scorers.py
.py
import json from typing import Any from unittest.mock import patch import pytest from click.testing import CliRunner import mlflow from mlflow.cli.scorers import commands from mlflow.exceptions import MlflowException from mlflow.genai.scorers import get_all_scorers, list_scorers, scorer from mlflow.utils.string_utils...
773
23,142
mlflow
tests/cli/test_crypto.py
.py
import logging from contextlib import contextmanager from unittest import mock import pytest from click.testing import CliRunner from mlflow.cli.crypto import commands from mlflow.exceptions import MlflowException @pytest.fixture(autouse=True) def suppress_logging(): original_root = logging.root.level origi...
415
15,629
mlflow
tests/cli/test_eval.py
.py
import re from unittest import mock import click import pandas as pd import pytest import mlflow from mlflow.cli.eval import evaluate_traces from mlflow.entities import Trace, TraceInfo from mlflow.genai.scorers.base import scorer def test_evaluate_traces_with_single_trace_table_output(): experiment_id = mlflow...
218
7,730
mlflow
tests/cli/test_traces.py
.py
import json import logging from unittest import mock import pytest from click.testing import CliRunner from mlflow.cli.traces import commands from mlflow.entities import ( AssessmentSourceType, MlflowExperimentLocation, Trace, TraceData, TraceInfo, TraceLocation, TraceLocationType, Tra...
229
7,221
mlflow
tests/cli/test_datasets.py
.py
import json import pytest from click.testing import CliRunner import mlflow from mlflow.cli.datasets import commands from mlflow.genai.datasets import create_dataset @pytest.fixture def runner(): return CliRunner(catch_exceptions=False) @pytest.fixture def experiment(): exp_id = mlflow.create_experiment("...
185
5,785
mlflow
tests/cli/test_genai_eval_utils.py
.py
from unittest import mock import click import pandas as pd import pytest from mlflow.cli.genai_eval_utils import ( NA_VALUE, Assessment, EvalResult, extract_assessments_from_results, format_table_output, resolve_scorers, ) from mlflow.exceptions import MlflowException from mlflow.tracing.const...
478
14,268
mlflow
tests/pydantic_ai/test_pydanticai_tracing.py
.py
import importlib.metadata import sys import types from unittest.mock import patch import pytest from packaging.version import Version PYDANTIC_AI_VERSION = Version(importlib.metadata.version("pydantic_ai")) if PYDANTIC_AI_VERSION.major >= 2: pytest.skip("Pydantic AI 1.x tracing tests", allow_module_level=True) f...
587
20,989
mlflow
tests/pydantic_ai/test_pydanticai_fluent_tracing.py
.py
import importlib.metadata from contextlib import asynccontextmanager from unittest.mock import patch import pytest from packaging.version import Version PYDANTIC_AI_VERSION = Version(importlib.metadata.version("pydantic_ai")) if PYDANTIC_AI_VERSION.major >= 2: pytest.skip("Pydantic AI 1.x fluent tracing tests", a...
461
16,129
mlflow
tests/pydantic_ai/test_pydanticai_mcp_tracing.py
.py
import importlib.metadata from unittest.mock import patch import pytest from packaging.version import Version if Version(importlib.metadata.version("pydantic_ai")).major >= 2: pytest.skip("Pydantic AI 1.x MCP tracing tests", allow_module_level=True) from pydantic_ai.mcp import MCPServerStdio import mlflow from ...
122
3,400
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