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/utils/test_validation.py | .py | import copy
import socket
import time
from unittest.mock import patch
import pytest
from mlflow.entities import Metric, Param, RunTag
from mlflow.environment_variables import MLFLOW_ARTIFACT_LOCATION_MAX_LENGTH
from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VA... | 784 | 26,931 |
mlflow | tests/utils/test_arguments_utils.py | .py | import functools
import pytest
from mlflow.utils.arguments_utils import _get_arg_names
def no_args():
pass
def positional(a, b):
return a, b
def keyword(a=0, b=0):
return a, b
def positional_and_keyword(a, b=0):
return a, b
def keyword_only(*, a, b=0):
return a, b
def var_positional(*a... | 61 | 1,062 |
mlflow | tests/utils/test_databricks_sql_warehouse.py | .py | import time
from datetime import timedelta
from unittest import mock
import pytest
from databricks.sdk.service.sql import State
from mlflow.environment_variables import (
MLFLOW_SQL_WAREHOUSE_AUTO_START,
MLFLOW_SQL_WAREHOUSE_AUTO_START_TIMEOUT_SECONDS,
)
from mlflow.exceptions import MlflowException
from mlfl... | 130 | 4,784 |
mlflow | tests/utils/test_name_utils.py | .py | from mlflow.utils.name_utils import _generate_random_name, _generate_unique_integer_id
def test_random_name_generation():
# Validate exhausted loop truncation
name = _generate_random_name(max_length=8)
assert len(name) == 8
# Validate default behavior while calling 1000 times that names end in intege... | 21 | 775 |
mlflow | tests/utils/test_request_utils.py | .py | import socket
import subprocess
import sys
from unittest import mock
import pytest
from requests.adapters import HTTPAdapter
from mlflow.utils import request_utils
from mlflow.utils.request_utils import (
TCPKeepAliveHTTPAdapter,
_build_socket_options,
)
def test_request_utils_does_not_import_mlflow(tmp_pat... | 254 | 8,825 |
mlflow | tests/utils/test_docstring_utils.py | .py | import warnings
from mlflow.utils.docstring_utils import (
ParamDocs,
_indent,
docstring_version_compatibility_warning,
format_docstring,
)
def test_indent_empty():
a = ""
b = " " * 4
assert _indent(a, b) == a
def test_indent_single_line():
a = "x"
b = " " * 4
assert _indent... | 174 | 3,661 |
mlflow | tests/utils/test_logging_utils.py | .py | import logging
import os
import re
import subprocess
import sys
import uuid
from io import StringIO
import pytest
import mlflow
from mlflow.utils import logging_utils
from mlflow.utils.logging_utils import (
LOGGING_LINE_FORMAT,
SensitiveQueryParamFilter,
_configure_mlflow_loggers,
_redact_sensitive_q... | 383 | 11,819 |
mlflow | tests/utils/test_autologging_utils.py | .py | import warnings
from threading import Thread
from mlflow import MlflowClient
from mlflow.entities import Metric
from mlflow.utils.autologging_utils.logging_and_warnings import (
_WarningsController,
)
from mlflow.utils.autologging_utils.metrics_queue import (
_metrics_queue,
_metrics_queue_lock,
flush_... | 96 | 3,592 |
mlflow | tests/utils/test_unity_catalog_oss_utils.py | .py | from mlflow.entities.model_registry import RegisteredModel
from mlflow.protos.unity_catalog_messages_pb2 import (
RegisteredModelInfo,
)
from mlflow.utils._unity_catalog_oss_utils import get_registered_model_from_uc_oss_proto
def test_registered_model_from_uc_oss_proto():
expected_registered_model = Registere... | 27 | 822 |
mlflow | tests/utils/test_data.py | .py | import os
from mlflow.projects import _project_spec
from mlflow.utils.data_utils import is_uri
TEST_DIR = "tests"
TEST_PROJECT_DIR = os.path.join(TEST_DIR, "resources", "example_project")
def load_project():
return _project_spec.load_project(directory=TEST_PROJECT_DIR)
def test_is_uri():
assert is_uri("s3... | 20 | 509 |
mlflow | tests/utils/test_credentials.py | .py | from unittest import mock
from unittest.mock import patch
import pytest
from mlflow import get_tracking_uri
from mlflow.environment_variables import MLFLOW_TRACKING_PASSWORD, MLFLOW_TRACKING_USERNAME
from mlflow.exceptions import MlflowException
from mlflow.utils.credentials import login, read_mlflow_creds
def test... | 151 | 4,918 |
mlflow | tests/utils/test_databricks_utils.py | .py | import builtins
import json
import os
import platform
import sys
import time
from unittest import mock
import pytest
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.legacy_databricks_cli.configure.provider import (
DatabricksConfig,
DatabricksModelServingConfigProvider,
)
from mlflow.u... | 1,467 | 58,783 |
mlflow | tests/utils/test_annotations.py | .py | import re
from dataclasses import dataclass, fields
import pytest
from mlflow.utils.annotations import _get_min_indent_of_docstring, deprecated, keyword_only
# Suppress expected deprecation warnings from test fixtures
pytestmark = pytest.mark.filterwarnings("ignore:.*is deprecated.*:FutureWarning")
class MyClass:
... | 329 | 8,393 |
mlflow | tests/utils/test_rest_utils.py | .py | import re
import time
import warnings
from unittest import mock
import numpy
import pytest
import requests
from mlflow.deployments.databricks import DatabricksDeploymentClient
from mlflow.environment_variables import (
_MLFLOW_DATABRICKS_TRAFFIC_ID,
MLFLOW_HTTP_REQUEST_TIMEOUT,
)
from mlflow.exceptions import... | 1,043 | 40,718 |
mlflow | tests/utils/test_python_env.py | .py | from unittest import mock
import pytest
from mlflow.utils import PYTHON_VERSION
from mlflow.utils.environment import _PythonEnv
def test_constructor_argument_validation():
with pytest.raises(TypeError, match="`python` must be a string"):
_PythonEnv(python=1)
with pytest.raises(TypeError, match="`bu... | 147 | 3,577 |
mlflow | tests/utils/test_utils.py | .py | import importlib.metadata
import socket
from unittest import mock
import pytest
from packaging.version import Version
from mlflow.utils import (
AttrDict,
_chunk_dict,
_get_fully_qualified_class_name,
_truncate_dict,
get_installed_version,
merge_dicts,
)
def test_truncate_dict():
d = {"1... | 255 | 7,273 |
mlflow | tests/utils/test_time.py | .py | import time
from mlflow.utils.time import Timer
def test_timer():
with Timer() as t:
time.sleep(0.1)
assert f"{t}" == f"{t.elapsed}"
assert f"{t:.3f}" == f"{t.elapsed:.3f}"
| 12 | 197 |
mlflow | tests/utils/test_requirements_utils.py | .py | import importlib
import os
import sys
from importlib.metadata import version
from unittest import mock
import cloudpickle
import importlib_metadata
import pytest
import mlflow
import mlflow.utils.requirements_utils
from mlflow.exceptions import MlflowException
from mlflow.utils.environment import infer_pip_requiremen... | 779 | 28,482 |
mlflow | tests/utils/test_resources/dummy_package/pandas.py | .py | # This module is meant to test shadowing of the 3rd party module
raise Exception(
"This package should not have been imported! "
"This means that the sys.path was not configured correctly"
)
| 6 | 199 |
mlflow | tests/utils/test_resources/dummy_package/operator.py | .py | # This module is meant to test shadowing of the built-in operator module
raise Exception(
"This package should not have been imported! "
"This means that the sys.path was not configured correctly"
)
| 6 | 207 |
mlflow | tests/pyspark/optuna/test_study.py | .py | import logging
import os
import numpy as np
import pyspark
import pytest
from optuna.exceptions import TrialPruned
from optuna.pruners import NopPruner, ThresholdPruner
from optuna.samplers import TPESampler
from optuna.study import StudyDirection
from optuna.trial import TrialState
from packaging.version import Versi... | 386 | 13,398 |
mlflow | tests/gateway/test_openai_compatibility.py | .py | from unittest import mock
import openai
import pytest
from mlflow.gateway.providers.openai import OpenAIProvider
from tests.gateway.tools import (
UvicornGateway,
save_yaml,
)
@pytest.fixture(scope="module")
def config():
return {
"endpoints": [
{
"name": "chat",
... | 160 | 4,707 |
mlflow | tests/gateway/test_gateway_app.py | .py | from unittest import mock
import pytest
from fastapi.testclient import TestClient
from mlflow.exceptions import MlflowException
from mlflow.gateway.app import create_app_from_config, create_app_from_env
from mlflow.gateway.config import GatewayConfig
from mlflow.gateway.constants import (
MLFLOW_GATEWAY_CRUD_ENDP... | 279 | 8,585 |
mlflow | tests/gateway/test_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... | 654 | 23,334 |
mlflow | tests/gateway/test_gateway_config_parsing.py | .py | import re
import pytest
import yaml
from mlflow.exceptions import MlflowException
from mlflow.gateway.config import (
AnthropicConfig,
EndpointConfig,
LiteLLMConfig,
OpenAIConfig,
_load_gateway_config,
_resolve_api_key_from_input,
_save_route_config,
)
from mlflow.gateway.utils import asse... | 454 | 15,759 |
mlflow | tests/gateway/test_runner.py | .py | from pathlib import Path
import pytest
from tests.gateway.tools import Gateway, save_yaml
BASE_ROUTE = "/api/2.0/endpoints/"
@pytest.fixture
def basic_config_dict():
return {
"endpoints": [
{
"name": "completions-gpt4",
"endpoint_type": "llm/v1/completions",
... | 231 | 7,059 |
mlflow | tests/gateway/test_tracing_utils.py | .py | import asyncio
import json
from typing import Any
import pytest
import mlflow
from mlflow.entities import SpanType
from mlflow.gateway.constants import MLFLOW_GATEWAY_CALLER_HEADER
from mlflow.gateway.schemas.chat import StreamResponsePayload
from mlflow.gateway.tracing_utils import (
_extract_caller,
_get_mo... | 1,135 | 41,606 |
mlflow | tests/gateway/test_provider_registry.py | .py | import pytest
from mlflow.exceptions import MlflowException
from mlflow.gateway.provider_registry import provider_registry
def test_registry_keys_returns_all_providers_by_default():
keys = provider_registry.keys()
assert len(keys) > 0
assert "openai" in keys
assert "anthropic" in keys
def test_regi... | 37 | 1,188 |
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 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.