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/deployments/test_utils.py
.py
import pytest from mlflow.deployments.utils import ( get_deployments_target, set_deployments_target, ) from mlflow.exceptions import MlflowException def test_set_deployments_target(monkeypatch): monkeypatch.setattr("mlflow.deployments.utils._deployments_target", None) valid_target = "databricks" ...
42
1,362
mlflow
tests/deployments/mlflow/test_mlflow.py
.py
from unittest import mock import pytest from mlflow.deployments import get_deploy_client from mlflow.deployments.mlflow import MlflowDeploymentClient from mlflow.environment_variables import MLFLOW_DEPLOYMENT_CLIENT_HTTP_REQUEST_TIMEOUT def test_get_deploy_client(): client = get_deploy_client("http://localhost:...
268
9,734
mlflow
tests/deployments/databricks/test_databricks.py
.py
import os import warnings from unittest import mock import pytest from mlflow.deployments import get_deploy_client from mlflow.exceptions import MlflowException @pytest.fixture(autouse=True) def mock_databricks_credentials(monkeypatch): monkeypatch.setenv("DATABRICKS_HOST", "https://test.cloud.databricks.com") ...
606
22,900
mlflow
tests/deployments/openai/test_openai.py
.py
from unittest import mock import pytest from mlflow.deployments import get_deploy_client from mlflow.exceptions import MlflowException @pytest.fixture def mock_openai_creds(monkeypatch): monkeypatch.setenv("OPENAI_API_KEY", "my-secret-key") @pytest.fixture def mock_azure_openai_creds(monkeypatch): monkeyp...
217
6,547
mlflow
tests/dev/test_update_mlflow_versions.py
.py
import difflib import re from pathlib import Path import pytest from packaging.version import Version from dev.update_mlflow_versions import ( get_current_py_version, replace_java, replace_java_pom_xml, replace_pyproject_toml, replace_python, replace_r, replace_ts, ) # { filename: expecte...
171
5,424
mlflow
tests/dev/test_check_function_signatures.py
.py
import ast from dev.check_function_signatures import check_signature_compatibility def test_no_changes(): old_code = "def func(a, b=1): pass" new_code = "def func(a, b=1): pass" old_tree = ast.parse(old_code) new_tree = ast.parse(new_code) errors = check_signature_compatibility(old_tree.body[0],...
231
7,443
mlflow
tests/dev/test_dev_stubs.py
.py
import importlib.util import json import shutil import subprocess import sys import tempfile from pathlib import Path import pytest from mlflow.assistant.providers.claude_code import ClaudeCodeProvider from mlflow.assistant.types import EventType REPO_ROOT = Path(__file__).resolve().parents[2] DEV_STUBS = REPO_ROOT ...
133
4,462
mlflow
tests/dev/test_annotate_flaky_tests.py
.py
import ast import json import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) import annotate_flaky_tests from annotate_flaky_tests import _split_nodeid, annotate_file def _annotate(tmp_path: Path, source: str, nodeid_suffix: str, attempts: int = 3): """Write `s...
199
7,859
mlflow
tests/dev/test_remove_experimental_decorators.py
.py
import subprocess import sys from pathlib import Path SCRIPT_PATH = "dev/remove_experimental_decorators.py" def test_script_with_specific_file(tmp_path: Path) -> None: test_file = tmp_path / "test.py" test_file.write_text(""" @experimental(version="1.0.0") def func(): pass """) output = subprocess.c...
207
4,789
mlflow
tests/dev/test_update_model_catalog.py
.py
import json import sys from datetime import date from pathlib import Path import pytest sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) from update_model_catalog import ( _extract_long_context_pricing, _extract_modality_pricing, _extract_service_tiers, _extract_tool_pricing, ...
796
24,846
mlflow
tests/dev/test_detect_flaky_tests.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) from detect_flaky_tests import gh_api_objects, parse_failing_tests # A captured pytest failure line as it appears in a raw GitHub Actions log: an ISO # timestamp prefix, ANSI SGR color codes around FAILED/the nod...
79
3,023
mlflow
tests/dev/test_classify_flaky_tests.py
.py
import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "dev")) from classify_flaky_tests import _aggregate def test_aggregate_collapses_events_per_test_and_counts(): flakes = [ {"shard": "python (1)", "test": "tests/a.py::t1", "error": "boom"}, {"shard":...
37
1,370
mlflow
tests/dev/test_check_init_py.py
.py
import subprocess import sys from pathlib import Path import pytest def get_check_init_py_script() -> Path: return Path(__file__).resolve().parents[2] / "dev" / "check_init_py.py" @pytest.fixture def temp_git_repo(tmp_path: Path) -> Path: subprocess.check_call(["git", "init"], cwd=tmp_path) subprocess....
227
7,376
mlflow
tests/tracking/test_tracking.py
.py
import filecmp import io import json import os import pathlib import posixpath import random import re from datetime import datetime, timezone from typing import NamedTuple from unittest import mock import pytest import yaml import mlflow from mlflow import MlflowClient, tracking from mlflow.entities import Lifecycle...
1,376
54,372
mlflow
tests/tracking/test_artifact_utils.py
.py
import os from unittest import mock from unittest.mock import ANY from uuid import UUID import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.tracking.artifact_utils import ( _download_artifact_from_uri, _upload_artifact_to_uri, _upload_artifacts_to_databricks, ) def test...
151
6,173
mlflow
tests/tracking/test_client.py
.py
import json import os import pickle import threading import time import uuid from pathlib import Path from unittest import mock from unittest.mock import Mock, patch import pytest from opentelemetry import trace as trace_api from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from pydantic import Base...
4,042
151,764
mlflow
tests/tracking/test_client_workspace.py
.py
from __future__ import annotations from mlflow import MlflowClient from mlflow.entities import TraceArchivalConfig from mlflow.environment_variables import MLFLOW_TRACKING_URI, MLFLOW_WORKSPACE_STORE_URI from mlflow.tracking._workspace import fluent as workspace_fluent from mlflow.tracking._workspace.client import Wor...
252
8,552
mlflow
tests/tracking/test_workspace_registry.py
.py
from __future__ import annotations import pytest from mlflow.store.workspace.rest_store import RestWorkspaceStore from mlflow.store.workspace.sqlalchemy_store import SqlAlchemyStore from mlflow.tracking._workspace.registry import ( UnsupportedWorkspaceStoreURIException, _get_workspace_store_registry, get_...
41
1,295
mlflow
tests/tracking/test_workspace_utils.py
.py
import pytest from mlflow.environment_variables import MLFLOW_TRACKING_URI, MLFLOW_WORKSPACE_STORE_URI from mlflow.utils.workspace_utils import resolve_workspace_store_uri, set_workspace_store_uri @pytest.fixture(autouse=True) def _reset_workspace_uri(monkeypatch): set_workspace_store_uri(None) monkeypatch.d...
39
1,598
mlflow
tests/tracking/test_client_webhooks.py
.py
from pathlib import Path from typing import Iterator import pytest from cryptography.fernet import Fernet from mlflow.entities.webhook import WebhookAction, WebhookEntity, WebhookEvent, WebhookStatus from mlflow.environment_variables import MLFLOW_WEBHOOK_SECRET_ENCRYPTION_KEY from mlflow.exceptions import MlflowExce...
218
8,862
mlflow
tests/tracking/test_span_links_client.py
.py
from mlflow.entities import Link from mlflow.tracking.client import MlflowClient from tests.tracing.helper import get_traces def test_client_start_trace_with_links(): client = MlflowClient() links = [ Link(trace_id="tr-0123456789abcdef0123456789abcdef", span_id="0123456789abcdef"), ] root = ...
49
1,398
mlflow
tests/tracking/test_rest_tracking.py
.py
import json import logging import math import os import pathlib import posixpath import subprocess import sys import time import urllib.parse from dataclasses import asdict from io import StringIO from pathlib import Path from unittest import mock import flask import pandas as pd import pytest import requests from ope...
5,538
202,790
mlflow
tests/tracking/test_mlflow_artifacts.py
.py
import cgi import os import pathlib import subprocess import tempfile from contextlib import contextmanager from io import BytesIO from typing import NamedTuple import pytest import requests import mlflow from mlflow import MlflowClient from mlflow.artifacts import download_artifacts from mlflow.store.tracking.sqlalc...
444
15,871
mlflow
tests/tracking/integration_test_utils.py
.py
import contextlib import logging import os import socket import sys import time from subprocess import Popen from threading import Thread from typing import Any, Generator, Literal import requests import uvicorn from fastapi import FastAPI import mlflow from mlflow.server import ARTIFACT_ROOT_ENV_VAR, BACKEND_STORE_U...
165
5,170
mlflow
tests/tracking/test_log_image.py
.py
import json import os import posixpath import numpy as np import pytest import mlflow from mlflow.utils.file_utils import local_file_uri_to_path from mlflow.utils.time import get_current_time_millis @pytest.mark.parametrize("subdir", [None, ".", "dir", "dir1/dir2", "dir/.."]) def test_log_image_numpy(subdir): i...
367
13,042
mlflow
tests/tracking/test_model_registry.py
.py
import time from pathlib import Path import pytest from mlflow import MlflowClient from mlflow.entities.model_registry import ModelVersion, RegisteredModel from mlflow.exceptions import MlflowException from mlflow.server import handlers from mlflow.server.fastapi_app import app from mlflow.server.handlers import init...
691
29,107
mlflow
tests/tracking/test_log_figure.py
.py
import os import posixpath import uuid import pytest import mlflow from mlflow.utils.file_utils import local_file_uri_to_path from mlflow.utils.os import is_windows @pytest.mark.parametrize("subdir", [None, ".", "dir", "dir1/dir2", "dir/.."]) def test_log_figure_matplotlib(subdir): import matplotlib.pyplot as p...
105
3,517
mlflow
tests/tracking/conftest.py
.py
import pytest import mlflow from mlflow.environment_variables import MLFLOW_ENABLE_ASYNC_TRACE_LOGGING from mlflow.tracing.fluent import _flush_pending_async_trace_writes @pytest.fixture(autouse=True) def enable_async_trace_logging(monkeypatch): """Enable async trace logging for all tests in tests/tracking/ to e...
26
769
mlflow
tests/tracking/context/test_databricks_cluster_context.py
.py
from unittest import mock from mlflow.tracking.context.databricks_cluster_context import DatabricksClusterRunContext from mlflow.utils.mlflow_tags import MLFLOW_DATABRICKS_CLUSTER_ID def test_databricks_cluster_run_context_in_context(): with mock.patch("mlflow.utils.databricks_utils.is_in_cluster") as in_cluster...
22
844
mlflow
tests/tracking/context/test_jupyter_notebook_context.py
.py
import json from unittest import mock import pytest from mlflow.entities import SourceType from mlflow.tracking.context.jupyter_notebook_context import ( JupyterNotebookRunContext, _get_kernel_id, _get_notebook_name, _get_notebook_path_from_sessions, _get_running_servers, _get_sessions_noteboo...
349
11,792
mlflow
tests/tracking/context/test_default_context.py
.py
from unittest import mock import pytest from mlflow.entities import SourceType from mlflow.tracking.context.default_context import DefaultRunContext from mlflow.utils.mlflow_tags import MLFLOW_SOURCE_NAME, MLFLOW_SOURCE_TYPE, MLFLOW_USER MOCK_SCRIPT_NAME = "/path/to/script.py" @pytest.fixture def patch_script_name...
43
1,413
mlflow
tests/tracking/context/test_git_context.py
.py
from unittest import mock import git import pytest from mlflow.tracking.context.git_context import GitRunContext from mlflow.utils.mlflow_tags import ( MLFLOW_GIT_BRANCH, MLFLOW_GIT_COMMIT, MLFLOW_GIT_REPO_URL, ) MOCK_SCRIPT_NAME = "/path/to/script.py" MOCK_COMMIT_HASH = "commit-hash" MOCK_BRANCH_NAME = ...
79
2,382
mlflow
tests/tracking/context/test_registry.py
.py
from importlib import reload from unittest import mock import pytest import mlflow.tracking.context.registry from mlflow.tracking.context.databricks_job_context import DatabricksJobRunContext from mlflow.tracking.context.databricks_notebook_context import DatabricksNotebookRunContext from mlflow.tracking.context.data...
161
5,786
mlflow
tests/tracking/context/test_databricks_job_context.py
.py
from unittest import mock from mlflow.entities import SourceType from mlflow.tracking.context.databricks_job_context import DatabricksJobRunContext from mlflow.utils.mlflow_tags import ( MLFLOW_DATABRICKS_JOB_ID, MLFLOW_DATABRICKS_JOB_RUN_ID, MLFLOW_DATABRICKS_JOB_TYPE, MLFLOW_DATABRICKS_WEBAPP_URL, ...
101
4,567
mlflow
tests/tracking/context/test_databricks_notebook_context.py
.py
from unittest import mock from mlflow.entities import SourceType from mlflow.tracking.context.databricks_notebook_context import DatabricksNotebookRunContext from mlflow.utils.mlflow_tags import ( MLFLOW_DATABRICKS_NOTEBOOK_ID, MLFLOW_DATABRICKS_NOTEBOOK_PATH, MLFLOW_DATABRICKS_WEBAPP_URL, MLFLOW_DATAB...
94
4,201
mlflow
tests/tracking/context/test_databricks_repo_context.py
.py
from unittest import mock from mlflow.tracking.context.databricks_repo_context import DatabricksRepoRunContext from mlflow.utils.mlflow_tags import ( MLFLOW_DATABRICKS_GIT_REPO_COMMIT, MLFLOW_DATABRICKS_GIT_REPO_PROVIDER, MLFLOW_DATABRICKS_GIT_REPO_REFERENCE, MLFLOW_DATABRICKS_GIT_REPO_REFERENCE_TYPE, ...
85
3,804
mlflow
tests/tracking/context/test_databricks_command_context.py
.py
from unittest import mock from mlflow.tracking.context.databricks_command_context import DatabricksCommandRunContext from mlflow.utils.mlflow_tags import MLFLOW_DATABRICKS_NOTEBOOK_COMMAND_ID def test_databricks_command_run_context_in_context(): with mock.patch("mlflow.utils.databricks_utils.get_job_group_id", r...
22
891
mlflow
tests/tracking/context/test_system_environment_context.py
.py
from mlflow.tracking.context.system_environment_context import SystemEnvironmentContext def test_system_environment_context_in_context(monkeypatch): monkeypatch.setenv("MLFLOW_RUN_CONTEXT", '{"A": "B"}') assert SystemEnvironmentContext().in_context() monkeypatch.delenv("MLFLOW_RUN_CONTEXT", raising=True) ...
14
570
mlflow
tests/tracking/request_auth/test_registry.py
.py
from importlib import reload from unittest import mock import pytest import mlflow.tracking.request_auth.registry from mlflow.tracking.request_auth.registry import RequestAuthProviderRegistry, fetch_auth def test_request_auth_provider_registry_register(): provider_class = mock.Mock() registry = RequestAuth...
94
3,388
mlflow
tests/tracking/request_auth/test_kubernetes_request_auth_provider.py
.py
from contextlib import contextmanager from pathlib import Path from unittest import mock import pytest pytest.importorskip("kubernetes") from kubernetes.config.config_exception import ConfigException import mlflow.tracking.request_auth.kubernetes_request_auth_provider as _k8s_auth from mlflow.exceptions import Mlfl...
425
14,456
mlflow
tests/tracking/fluent/test_create_experiment_trace_location.py
.py
from unittest import mock import pytest import mlflow import mlflow.tracking.fluent as fluent_module from mlflow.entities import Experiment from mlflow.entities.experiment_tag import ExperimentTag from mlflow.entities.trace_location import UnityCatalog from mlflow.exceptions import MlflowException def _experiment(e...
142
4,872
mlflow
tests/tracking/fluent/test_fluent.py
.py
import json import multiprocessing import os import random import re import subprocess import sys import threading import time import uuid from collections import defaultdict from concurrent.futures import ThreadPoolExecutor from importlib import reload from itertools import zip_longest from pathlib import Path from ty...
2,815
107,479
mlflow
tests/tracking/fluent/test_set_experiment_trace_location.py
.py
from unittest import mock import pytest import mlflow from mlflow.entities import Experiment from mlflow.entities.experiment_tag import ExperimentTag from mlflow.entities.trace_location import UnityCatalog from mlflow.exceptions import MlflowException from mlflow.tracking._uc_upsell import show_existing_experiment_up...
470
18,608
mlflow
tests/tracking/fluent/test_fluent_autolog.py
.py
import contextlib import inspect import sys from io import StringIO from typing import Any, NamedTuple from unittest import mock import anthropic import autogen import boto3 import dspy import google.genai import groq import keras import langchain import lightgbm import lightning import litellm import llama_index.core...
517
18,825
mlflow
tests/tracking/fluent/test_metric_value_conversion_utils.py
.py
import numpy as np import pytest 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 from tests.helpe...
40
1,327
mlflow
tests/tracking/default_experiment/test_registry.py
.py
from importlib import reload from unittest import mock import pytest import mlflow.tracking.default_experiment.registry from mlflow.tracking.default_experiment.databricks_notebook_experiment_provider import ( DatabricksNotebookExperimentProvider, ) from mlflow.tracking.default_experiment.registry import ( Def...
166
5,733
mlflow
tests/tracking/default_experiment/test_databricks_notebook_experiment_provider.py
.py
from unittest import mock import pytest from mlflow import MlflowClient from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE from mlflow.tracking.default_experiment.databricks_notebook_experiment_provider import ( DatabricksNotebookExperimentProvider, ) fr...
84
3,181
mlflow
tests/tracking/_model_registry/test_model_registry_client.py
.py
from unittest import mock from unittest.mock import ANY import pytest from mlflow.entities.model_registry import ( ModelVersion, ModelVersionTag, RegisteredModel, RegisteredModelTag, ) from mlflow.exceptions import MlflowException from mlflow.store.entities.paged_list import PagedList from mlflow.stor...
550
20,253
mlflow
tests/tracking/_model_registry/test_model_registry_fluent.py
.py
import logging import os import subprocess from pathlib import Path from unittest import mock import pytest import requests import mlflow from mlflow import MlflowClient, register_model from mlflow.entities.model_registry import ModelVersion, RegisteredModel from mlflow.exceptions import MlflowException from mlflow.p...
607
22,571
mlflow
tests/tracking/_model_registry/test_utils.py
.py
import io import pickle from unittest import mock import pytest from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.store._unity_catalog.registry.rest_store import UcModelRegistryStore from mlflow.store._unity_catalog.registry.uc_native_rest_store import UcNativeModelRegistryStore from mlflow.sto...
358
13,647
mlflow
tests/tracking/_tracking_service/test_tracking_service_client.py
.py
from unittest import mock import pytest from mlflow.entities import Metric, Param, Run, RunInfo, RunTag from mlflow.exceptions import MlflowException from mlflow.tracking._tracking_service.client import TrackingServiceClient @pytest.fixture def mock_store(): with mock.patch("mlflow.tracking._tracking_service.ut...
157
5,705
mlflow
tests/tracking/_tracking_service/test_utils.py
.py
import io import itertools import os import pickle import uuid from importlib import reload from pathlib import Path from unittest import mock from urllib.parse import urlparse from urllib.request import url2pathname import pytest import mlflow from mlflow.environment_variables import ( MLFLOW_ENABLE_WORKSPACES, ...
548
20,669
mlflow
tests/tracking/request_header/test_databricks_request_header_provider.py
.py
import itertools from unittest import mock import pytest from mlflow.tracking.request_header.databricks_request_header_provider import ( DatabricksRequestHeaderProvider, ) bool_values = [True, False] @pytest.mark.parametrize( ("is_in_databricks_notebook", "is_in_databricks_job", "is_in_cluster"), list(...
92
3,768
mlflow
tests/tracking/request_header/test_registry.py
.py
from importlib import reload from unittest import mock import pytest import mlflow.tracking.request_header.registry from mlflow.tracking.request_header.databricks_request_header_provider import ( DatabricksRequestHeaderProvider, ) from mlflow.tracking.request_header.registry import ( RequestHeaderProviderRegi...
164
5,720
mlflow
tests/tracking/request_header/test_default_request_header_provider.py
.py
from mlflow.tracking.request_header.default_request_header_provider import ( _DEFAULT_HEADERS, DefaultRequestHeaderProvider, ) def test_default_request_header_provider_in_context(): assert DefaultRequestHeaderProvider().in_context() def test_default_request_header_provider_request_headers(): request...
14
427
mlflow
tests/pytest/test_plugin.py
.py
from __future__ import annotations import os import subprocess import sys from pathlib import Path from mlflow.pytest import session as _session from mlflow.tracking import MlflowClient from mlflow.utils.mlflow_tags import MLFLOW_RUN_TYPE, MLFLOW_RUN_TYPE_TEST # ------------------------------------------------------...
244
7,345
mlflow
tests/prompt/test_promptlab_model.py
.py
from unittest import mock import pandas as pd from mlflow.deployments import set_deployments_target from mlflow.entities.param import Param from mlflow.prompt.promptlab_model import _PromptlabModel set_deployments_target("http://localhost:5000") def construct_model(route): return _PromptlabModel( "Writ...
100
2,834
mlflow
tests/catboost/test_catboost_model_export.py
.py
import json import os from pathlib import Path from typing import Any, NamedTuple from unittest import mock import catboost as cb import numpy as np import pandas as pd import pytest import yaml from packaging.version import Version from sklearn import datasets from sklearn.pipeline import Pipeline import mlflow.catb...
539
20,242
mlflow
tests/genai/test_genai_import_without_agent_sdk.py
.py
import json from unittest import mock from unittest.mock import patch import pytest from mlflow.genai.datasets import create_dataset, delete_dataset, get_dataset from mlflow.genai.scorers import ( Guidelines, delete_scorer, get_scorer, list_scorers, ) from mlflow.genai.scorers.base import Scorer from ...
175
6,406
mlflow
tests/genai/test_scheduled_scorers.py
.py
from mlflow.genai.scheduled_scorers import ( ScorerScheduleConfig, ) from mlflow.genai.scorers.base import Scorer class MockScorer(Scorer): """Mock scorer for testing purposes.""" name: str = "mock_scorer" def __call__(self, *, outputs=None, **kwargs): return {"score": 1.0} def test_schedu...
29
795
mlflow
tests/genai/test_mcp_tool_discovery.py
.py
from __future__ import annotations import asyncio import socket import sys import threading import time from types import SimpleNamespace from typing import Any from unittest import mock import pytest from mlflow.entities.mcp_server import MCPRemoteTransportType, MCPTool from mlflow.exceptions import MlflowException...
416
13,857
mlflow
tests/genai/test_agent_server.py
.py
import contextvars from typing import Any, AsyncGenerator from unittest.mock import AsyncMock, Mock, patch import httpx import pytest from fastapi.testclient import TestClient from mlflow.genai.agent_server import ( AgentServer, get_invoke_function, get_request_headers, get_stream_function, invoke...
1,325
44,175
mlflow
tests/genai/test_git_versioning.py
.py
import subprocess from pathlib import Path from unittest import mock import pytest import mlflow from mlflow.genai import disable_git_model_versioning, enable_git_model_versioning from mlflow.genai.git_versioning import _get_active_git_context from mlflow.utils.mlflow_tags import MLFLOW_GIT_DIFF @pytest.fixture(aut...
270
10,188
mlflow
tests/genai/test_mcp_servers.py
.py
from __future__ import annotations import json import urllib.request from pathlib import Path from unittest import mock import pytest from mlflow import genai from mlflow.entities.mcp_server import MCPRemoteTransportType, MCPStatus, MCPTool from mlflow.exceptions import MlflowException from mlflow.genai.mcp_tool_dis...
1,273
47,638
mlflow
tests/genai/test_agent_tester.py
.py
from unittest import mock import pydantic import pytest from mlflow.genai.agent_tester import ( _DEFAULT_NUM_TEST_CASES, _DEFAULT_TESTING_GUIDANCE, AgentTestResult, _AgentDescription, _describe_agent_from_response, _describe_agent_from_traces, _generate_test_cases, _get_agent_response_...
566
18,875
mlflow
tests/genai/conftest.py
.py
import functools import os from unittest import mock import pytest import mlflow import mlflow.telemetry.utils from mlflow.entities.assessment import Expectation from mlflow.entities.document import Document from mlflow.entities.span import SpanType from mlflow.genai.scorers.validation import IS_DBX_AGENTS_INSTALLED ...
116
3,732
mlflow
tests/genai/simulators/test_distillation.py
.py
from unittest import mock import pydantic import pytest from mlflow.entities.session import Session from mlflow.genai.simulators.distillation import ( _distill_goal_and_persona, _GoalAndPersona, generate_test_cases, ) @pytest.fixture def mock_session(): trace = mock.MagicMock() return Session([t...
214
7,042
mlflow
tests/genai/simulators/test_simulator.py
.py
import re from unittest.mock import Mock, patch import pandas as pd import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.genai.datasets.evaluation_dataset import EvaluationDataset from mlflow.genai.simulators import ( BaseSimulatedUserAgent, ConversationSimulator, Simulate...
1,020
34,999
mlflow
tests/genai/simulators/test_utils.py
.py
from unittest import mock import pytest from mlflow.genai.simulators.utils import ( format_history, get_default_simulation_model, invoke_model_without_tracing, ) @pytest.mark.parametrize( ("history", "expected"), [ ([], None), ([{"role": "user", "content": "Hello"}], "user: Hello...
108
3,451
mlflow
tests/genai/simulators/conftest.py
.py
from contextlib import contextmanager from unittest.mock import Mock, patch import pytest @pytest.fixture def mock_trace(): trace = Mock() trace.info.trace_metadata = {} trace.info.tags = {} return trace @pytest.fixture def simulation_mocks(mock_trace): """Fixture providing common mocks for con...
142
3,895
mlflow
tests/genai/evaluate/test_pytest_integration.py
.py
from __future__ import annotations import os import subprocess import sys import textwrap from pathlib import Path from mlflow.pytest.session import TAG_TEST_NAME from mlflow.tracking import MlflowClient _GENERATED_TEST = """ import mlflow from mlflow.genai.scorers import scorer @scorer def always_pass(*, outputs)...
62
1,651
mlflow
tests/genai/evaluate/test_evaluation.py
.py
import threading import uuid from concurrent.futures import ThreadPoolExecutor from dataclasses import dataclass from pathlib import Path from typing import Any, Literal from unittest import mock from unittest.mock import ANY, MagicMock import pandas as pd import pytest import mlflow from mlflow.entities.assessment i...
2,305
81,131
mlflow
tests/genai/evaluate/test_entities.py
.py
import numpy as np import pandas as pd from mlflow.entities.dataset_record_source import DatasetRecordSource, DatasetRecordSourceType from mlflow.genai.evaluation.entities import EvalItem, EvaluationResult from mlflow.genai.judges import CategoricalRating def test_eval_item_from_dataset_row_extracts_source(): so...
192
6,264
mlflow
tests/genai/evaluate/test_rate_limiter.py
.py
import pytest from mlflow.genai.evaluation.harness import ( AUTO_INITIAL_RPS, _make_rate_limiter, _parse_rate_limit, ) from mlflow.genai.evaluation.rate_limiter import ( NoOpRateLimiter, RPSRateLimiter, call_with_retry, eval_retry_context, is_rate_limit_error, ) from mlflow.genai.judges...
409
11,356
mlflow
tests/genai/evaluate/test_session_utils.py
.py
from unittest.mock import Mock, patch import pytest import mlflow from mlflow.entities import TraceData, TraceInfo, TraceLocation, TraceState from mlflow.entities.assessment import Feedback from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType from mlflow.entities.trace import Trace fro...
564
19,171
mlflow
tests/genai/evaluate/test_to_predict_fn.py
.py
import importlib.metadata from unittest import mock import pytest import mlflow from mlflow.entities.trace_info import TraceInfo from mlflow.environment_variables import MLFLOW_ENABLE_ASYNC_TRACE_LOGGING from mlflow.exceptions import MlflowException from mlflow.genai.evaluation.base import to_predict_fn from mlflow.g...
602
22,727
mlflow
tests/genai/evaluate/test_telemetry.py
.py
from unittest import mock import pytest from mlflow.genai import Scorer, scorer from mlflow.genai.evaluation.telemetry import ( _BATCH_SIZE_HEADER, _CLIENT_NAME_HEADER, _CLIENT_VERSION_HEADER, _SESSION_ID_HEADER, emit_metric_usage_event, ) from mlflow.genai.judges import make_judge from mlflow.gen...
301
9,154
mlflow
tests/genai/evaluate/test_context.py
.py
import threading from unittest import mock import pytest import mlflow from mlflow.environment_variables import MLFLOW_TRACKING_USERNAME from mlflow.genai.evaluation.context import NoneContext, _set_context, eval_context, get_context @pytest.fixture(autouse=True) def reset_context(): yield _set_context(None...
77
1,834
mlflow
tests/genai/evaluate/test_utils.py
.py
import json import sys from typing import Any, Literal from unittest.mock import MagicMock, Mock, patch import pandas as pd import pytest import mlflow from mlflow.entities.assessment_source import AssessmentSource from mlflow.entities.span import SpanType from mlflow.entities.trace import Trace from mlflow.exception...
637
21,914
mlflow
tests/genai/evaluate/test_job.py
.py
import os from unittest import mock import pytest from mlflow.entities.run_status import RunStatus from mlflow.genai.evaluation.job import invoke_genai_evaluate_job def _serialized_scorer(name: str = "scorer") -> str: return f'{{"name": "{name}"}}' def test_invoke_genai_evaluate_job_has_metadata(): """Wit...
205
9,040
mlflow
tests/genai/judges/test_alignment_optimizer.py
.py
from unittest.mock import Mock, patch import pytest from mlflow.entities.trace import Trace from mlflow.genai.judges import AlignmentOptimizer, Judge, make_judge from mlflow.genai.judges.base import JudgeField from mlflow.genai.judges.optimizers import MemAlignOptimizer from mlflow.genai.judges.utils import get_defau...
190
6,254
mlflow
tests/genai/judges/test_builtin.py
.py
import json from unittest import mock import pytest from mlflow.entities.assessment import ( AssessmentError, AssessmentSource, AssessmentSourceType, Feedback, ) from mlflow.exceptions import MlflowException from mlflow.genai import judges from mlflow.genai.evaluation.entities import EvalItem, EvalRes...
737
26,811
mlflow
tests/genai/judges/test_judge_tool_list_spans.py
.py
from unittest import mock import pytest from mlflow.entities.span import Span from mlflow.entities.span_status import SpanStatus, SpanStatusCode from mlflow.entities.trace import Trace from mlflow.entities.trace_data import TraceData from mlflow.entities.trace_info import TraceInfo from mlflow.entities.trace_location...
156
5,345
mlflow
tests/genai/judges/test_judge_tool_get_span.py
.py
import pytest from mlflow.entities.span import Span from mlflow.entities.trace import Trace from mlflow.entities.trace_data import TraceData from mlflow.entities.trace_info import TraceInfo from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_state import TraceState from mlflow.genai.jud...
234
6,967
mlflow
tests/genai/judges/test_judge_tool_get_span_image.py
.py
import base64 import json from typing import Any import mlflow from mlflow.genai.judges.tools.get_span_image import ( _ATTACHMENT_REF_RE, GetSpanImageTool, SpanImageResult, ) from mlflow.tracing.attachments import Attachment from mlflow.types.llm import ToolDefinition # 1x1 PNG-ish bytes; content is opaqu...
241
9,353
mlflow
tests/genai/judges/test_judge_tool_get_traces_in_session.py
.py
from unittest.mock import MagicMock, patch import pytest from mlflow.entities.trace import Trace, TraceData from mlflow.entities.trace_info import TraceInfo as MlflowTraceInfo from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_state import TraceState from mlflow.exceptions import Mlfl...
166
6,004
mlflow
tests/genai/judges/test_judge_tool_registry.py
.py
import inspect import json import pytest import mlflow from mlflow.entities.span import SpanType from mlflow.entities.trace import Trace from mlflow.entities.trace_info import TraceInfo from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_state import TraceState from mlflow.exceptions i...
218
6,602
mlflow
tests/genai/judges/test_judge_base.py
.py
from typing import Any import pytest from mlflow.entities.assessment import Feedback from mlflow.entities.trace import Trace from mlflow.genai.judges import Judge from mlflow.genai.judges.base import JudgeField from mlflow.genai.scorers.base import Scorer class MockJudgeImplementation(Judge): def __init__(self,...
113
3,686
mlflow
tests/genai/judges/test_judge_tool_get_trace_info.py
.py
from mlflow.entities.trace import Trace from mlflow.entities.trace_info import TraceInfo from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_state import TraceState from mlflow.genai.judges.tools.get_trace_info import GetTraceInfoTool from mlflow.types.llm import ToolDefinition def tes...
81
2,474
mlflow
tests/genai/judges/test_search_trace_regex_tool.py
.py
import json import pytest from mlflow.entities.trace import Trace from mlflow.entities.trace_data import TraceData from mlflow.entities.trace_info import TraceInfo from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_state import TraceState from mlflow.genai.judges.tools.search_trace_re...
307
11,174
mlflow
tests/genai/judges/test_make_judge.py
.py
import json import sys import types import typing from dataclasses import asdict from typing import Any, Literal from unittest import mock from unittest.mock import patch import pandas as pd import pydantic import pytest from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan import mlflow import mlflow....
4,196
143,063
mlflow
tests/genai/judges/test_custom_prompt_judge.py
.py
import json from unittest import mock import pytest from mlflow.entities.assessment import AssessmentError from mlflow.entities.assessment_source import AssessmentSourceType from mlflow.genai.judges.adapters.gateway_adapter import InvokeOutput from mlflow.genai.judges.custom_prompt_judge import _remove_choice_bracket...
184
5,913
mlflow
tests/genai/judges/test_judge_tool_get_root_span.py
.py
import pytest from mlflow.entities.span import Span from mlflow.entities.trace import Trace from mlflow.entities.trace_data import TraceData from mlflow.entities.trace_info import TraceInfo from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_state import TraceState from mlflow.genai.jud...
259
7,772
mlflow
tests/genai/judges/test_judge_tool_search_traces.py
.py
from unittest import mock import pytest from mlflow.entities.assessment import Expectation, Feedback from mlflow.entities.assessment_error import AssessmentError from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType from mlflow.entities.span import Span from mlflow.entities.trace import...
452
14,984
mlflow
tests/genai/judges/test_judge_tool_get_span_performance_and_timing_report.py
.py
from mlflow.entities.span import Span from mlflow.entities.trace import Trace from mlflow.entities.trace_data import TraceData from mlflow.entities.trace_info import TraceInfo from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_state import TraceState from mlflow.genai.judges.tools.get_s...
883
26,386
mlflow
tests/genai/judges/optimizers/test_simba.py
.py
from importlib import reload from unittest.mock import MagicMock, patch import dspy import pytest from mlflow.exceptions import MlflowException from mlflow.genai.judges.optimizers import SIMBAAlignmentOptimizer def test_dspy_optimize_no_dspy(): # Since dspy import is now at module level, we need to test this di...
113
4,620
mlflow
tests/genai/judges/optimizers/test_dspy_utils.py
.py
import json import time from unittest.mock import MagicMock, Mock, patch import dspy import pytest from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from mlflow.entities.assessment import Feedback from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType from mlflow.entit...
769
26,718
mlflow
tests/genai/judges/optimizers/test_dspy_base.py
.py
from typing import Any, Callable, Collection from unittest.mock import MagicMock, Mock, patch import dspy import litellm import pytest from mlflow.entities.trace import Trace from mlflow.exceptions import MlflowException from mlflow.genai.judges import make_judge from mlflow.genai.judges.optimizers.dspy import DSPyAl...
520
19,866
mlflow
tests/genai/judges/optimizers/test_gepa.py
.py
from importlib import reload from unittest.mock import MagicMock, patch import dspy import pytest from mlflow.exceptions import MlflowException from mlflow.genai.judges.optimizers import GEPAAlignmentOptimizer from tests.genai.judges.optimizers.conftest import create_mock_judge_invocator def test_dspy_optimize_no_...
178
7,140
mlflow
tests/genai/judges/optimizers/conftest.py
.py
"""Shared test fixtures for optimizer tests.""" import json import time from typing import Any from unittest.mock import Mock import dspy import pytest from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from mlflow.entities.assessment import Feedback from mlflow.entities.assessment_source import As...
675
22,803