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/webhooks/test_delivery.py
.py
import json from pathlib import Path from unittest.mock import Mock, patch import pytest from mlflow.entities.webhook import Webhook, WebhookAction, WebhookEntity, WebhookEvent from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES from mlflow.store.model_registry.file_store import FileStore from mlflow.st...
178
6,013
mlflow
tests/webhooks/test_ssrf.py
.py
import http.server import socket import threading from collections.abc import Iterator from unittest import mock import pytest import requests from urllib3.util.retry import Retry from mlflow.webhooks.delivery import _create_webhook_session from mlflow.webhooks.ssrf import SSRFProtectedHTTPAdapter, SSRFProtectionErro...
132
5,773
mlflow
tests/webhooks/app.py
.py
import base64 import hashlib import hmac import itertools import json import sys from pathlib import Path import fastapi import uvicorn from fastapi import HTTPException, Request from mlflow.webhooks.constants import ( WEBHOOK_DELIVERY_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_VERSION, WE...
242
7,351
mlflow
tests/webhooks/test_e2e.py
.py
import contextlib import os import subprocess import sys import time from dataclasses import dataclass from pathlib import Path from typing import Any, Generator import psutil import pytest import requests from cryptography.fernet import Fernet from mlflow import MlflowClient from mlflow.entities.webhook import Webho...
960
33,039
mlflow
tests/spacy/test_spacy_model_export.py
.py
import json import os import random from pathlib import Path from typing import Any, NamedTuple from unittest import mock import pandas as pd import pytest import spacy import yaml from packaging.version import Version from spacy.util import compounding, minibatch import mlflow.pyfunc.scoring_server as pyfunc_scoring...
512
19,731
mlflow
tests/demo/test_generate.py
.py
import threading from unittest import mock from mlflow.demo import generate_all_demos from mlflow.demo.base import BaseDemoGenerator, DemoFeature, DemoResult from mlflow.environment_variables import MLFLOW_WORKSPACE from mlflow.utils.workspace_context import ( clear_server_request_workspace, get_request_worksp...
122
4,029
mlflow
tests/demo/test_prompts_generator.py
.py
import pytest from mlflow.demo.base import DEMO_PROMPT_PREFIX, DemoFeature, DemoResult from mlflow.demo.data import DEMO_PROMPTS from mlflow.demo.generators.prompts import PromptsDemoGenerator from mlflow.genai.prompts import load_prompt, search_prompts @pytest.fixture def prompts_generator(): generator = Prompt...
141
4,195
mlflow
tests/demo/test_api_routes.py
.py
from pathlib import Path import pytest import requests import mlflow from mlflow.server import handlers from mlflow.server.fastapi_app import app from mlflow.server.handlers import initialize_backend_stores from tests.helper_functions import get_safe_port from tests.tracking.integration_test_utils import ServerThrea...
104
3,413
mlflow
tests/demo/test_registry.py
.py
import pytest from mlflow.demo.base import BaseDemoGenerator, DemoFeature def test_register_and_get(fresh_registry, stub_generator): fresh_registry.register(stub_generator) assert fresh_registry.get(DemoFeature.TRACES) is stub_generator def test_register_duplicate_raises(fresh_registry, stub_generator): ...
49
1,523
mlflow
tests/demo/test_judges_generator.py
.py
import pytest from mlflow.demo.base import DemoFeature, DemoResult from mlflow.demo.generators.judges import DEMO_JUDGE_PREFIX, JudgesDemoGenerator from mlflow.genai.scorers.registry import list_scorers @pytest.fixture def judges_generator(): generator = JudgesDemoGenerator() original_version = generator.ver...
87
2,382
mlflow
tests/demo/test_traces_generator.py
.py
import pytest import mlflow from mlflow import get_experiment_by_name, set_experiment from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DemoFeature, DemoResult from mlflow.demo.generators.traces import ( _PROVIDER_TO_LLM_SPAN_NAME, DEMO_SESSION_TURN_TAG, DEMO_TRACE_TYPE_TAG, DEMO_VERSION_TAG, Trac...
293
11,051
mlflow
tests/demo/test_base.py
.py
import pytest from mlflow.demo.base import ( DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX, BaseDemoGenerator, DemoFeature, DemoResult, ) def test_demo_feature_enum(): assert DemoFeature.TRACES == "traces" assert DemoFeature.EVALUATION == "evaluation" assert isinstance(DemoFeature.TRACES, ...
133
3,567
mlflow
tests/demo/test_search_traces_flush.py
.py
from unittest import mock from mlflow import set_experiment from mlflow.demo.base import DEMO_EXPERIMENT_NAME from mlflow.demo.generators.evaluation import EvaluationDemoGenerator from mlflow.demo.generators.issues import IssuesDemoGenerator from mlflow.demo.generators.traces import TracesDemoGenerator def test_eval...
43
1,409
mlflow
tests/demo/test_evaluation_generator.py
.py
import pytest import mlflow from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DemoFeature, DemoResult from mlflow.demo.data import ALL_DEMO_TRACES from mlflow.demo.generators.evaluation import EvaluationDemoGenerator from mlflow.demo.generators.traces import TracesDemoGenerator @pytest.fixture def evaluation_genera...
119
3,806
mlflow
tests/demo/test_review_queues_generator.py
.py
import pytest import mlflow from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DemoFeature, DemoResult from mlflow.demo.generators.review_queues import ( DEMO_DEFAULT_REVIEWER, DEMO_LABEL_SCHEMAS, DEMO_REVIEW_QUEUE_NAME, DEMO_REVIEWERS, ReviewQueuesDemoGenerator, ) from mlflow.tracking._tracking_se...
149
4,872
mlflow
tests/demo/test_cli.py
.py
import socket import sys from unittest import mock import click import pytest from click.testing import CliRunner import mlflow from mlflow.cli import cli from mlflow.cli.demo import _check_server_connection, demo from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX from mlflow.demo.generators.traces...
185
5,393
mlflow
tests/demo/test_demo_integration.py
.py
from pathlib import Path import pytest from mlflow import MlflowClient, set_tracking_uri from mlflow.demo import generate_all_demos from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX from mlflow.demo.data import DEMO_PROMPTS from mlflow.demo.generators.evaluation import ( DEMO_DATASET_BASELINE_...
599
21,255
mlflow
tests/demo/conftest.py
.py
import pytest from mlflow.demo.base import BaseDemoGenerator, DemoFeature, DemoResult from mlflow.demo.registry import DemoRegistry class StubGenerator(BaseDemoGenerator): name = DemoFeature.TRACES def __init__(self, version: int = 1): self._version = version self.generate_called = False ...
74
1,718
mlflow
tests/gemini/test_gemini_autolog.py
.py
# Tests for the new Gemini Python SDK: # https://github.com/googleapis/python-genai import asyncio import base64 import importlib.metadata import re from unittest.mock import patch import pytest from google import genai from packaging.version import Version import mlflow from mlflow.entities import SpanLogLevel from...
747
24,934
mlflow
tests/gemini/test_legacy_gemini_autolog.py
.py
# Tests for the legacy Gemini Python SDK: # https://github.com/google-gemini/generative-ai-python import base64 from unittest.mock import patch import google.generativeai as genai import pytest from packaging.version import Version import mlflow from mlflow.entities.span import SpanType from tests.tracing.helper im...
354
11,180
mlflow
tests/gemini/test_gemini_genai_semconv_converter.py
.py
import json from unittest.mock import patch import pytest from google import genai import mlflow from mlflow.gemini.genai_semconv_converter import _convert_part from mlflow.tracing.constant import GenAiSemconvKey from tests.gemini.test_gemini_autolog import ( _dummy_generate_content, _generate_content_respon...
163
5,495
mlflow
tests/evaluate/test_deprecated.py
.py
import warnings from contextlib import contextmanager from unittest.mock import patch import pandas as pd import pytest import mlflow _TEST_DATA = pd.DataFrame({"x": [1, 2, 3], "y": [4, 5, 6]}) @pytest.mark.parametrize("tracking_uri", ["databricks", "http://localhost:5000"]) def test_global_evaluate_warn_in_tracki...
41
1,298
mlflow
tests/evaluate/test_evaluation.py
.py
import hashlib import io import json import os import re import signal import subprocess import uuid from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import pytest import sklearn import sklearn.compose import sklearn.datasets import sklearn.impute import sklearn.linea...
2,416
87,304
mlflow
tests/evaluate/test_default_evaluator_delta.py
.py
import tempfile import pandas as pd import pytest from pyspark.sql import SparkSession import mlflow from mlflow.exceptions import MlflowException def language_model(inputs: list[str]) -> list[str]: return inputs def test_write_to_delta_fails_without_spark(): with mlflow.start_run(): model_info = ...
146
5,012
mlflow
tests/evaluate/test_validation.py
.py
import random from unittest import mock import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.models.evaluation import ( EvaluationResult, MetricThreshold, ModelEvaluator, evaluate, ) from mlflow.models.evaluation.evaluator_registry import _model_evaluation_registry fro...
966
37,112
mlflow
tests/evaluate/test_default_evaluator.py
.py
from __future__ import annotations import io import json import os import re from os.path import join as path_join from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pytest from matplotlib.figure import Figure from PIL import Image, ImageChops from pyspark.ml.linalg impor...
4,565
164,786
mlflow
tests/evaluate/logging/test_fluent.py
.py
import pytest import mlflow from mlflow.entities import Metric from mlflow.evaluation import Assessment, Evaluation, log_evaluations from mlflow.evaluation.assessment import AssessmentSource, AssessmentSourceType from mlflow.evaluation.evaluation_tag import EvaluationTag from tests.evaluate.logging.utils import get_e...
218
8,241
mlflow
tests/evaluate/logging/test_assessment.py
.py
from unittest.mock import patch import pytest from mlflow.entities.assessment_source import AssessmentSourceType from mlflow.evaluation import Assessment from mlflow.evaluation.assessment import AssessmentSource from mlflow.exceptions import MlflowException def test_assessment_equality(): source_1 = AssessmentS...
328
10,543
mlflow
tests/evaluate/logging/test_assessment_entity.py
.py
import pytest from mlflow.evaluation.assessment import AssessmentEntity, AssessmentSource from mlflow.exceptions import MlflowException def test_assessment_equality(): source_1 = AssessmentSource(source_type="HUMAN", source_id="user_1") source_2 = AssessmentSource(source_type="HUMAN", source_id="user_1") ...
226
6,794
mlflow
tests/evaluate/logging/utils.py
.py
import pandas as pd from mlflow.evaluation.evaluation import EvaluationEntity as EvaluationEntity from mlflow.evaluation.utils import ( _get_assessments_dataframe_schema, _get_evaluations_dataframe_schema, _get_metrics_dataframe_schema, _get_tags_dataframe_schema, ) from mlflow.exceptions import Mlflow...
227
7,637
mlflow
tests/evaluate/logging/test_evaluation.py
.py
from unittest import mock from mlflow.entities import Metric from mlflow.evaluation import Assessment, Evaluation from mlflow.evaluation.assessment import AssessmentSource from mlflow.evaluation.evaluation_tag import EvaluationTag def test_evaluation_equality(): inputs = {"feature1": 1.0, "feature2": 2.0} ou...
247
8,548
mlflow
tests/evaluate/logging/test_evaluation_tag.py
.py
import pytest from mlflow.evaluation.evaluation_tag import EvaluationTag def test_evaluation_tag_equality(): tag1 = EvaluationTag(key="tag1", value="value1") tag2 = EvaluationTag(key="tag1", value="value1") tag3 = EvaluationTag(key="tag1", value="value2") tag4 = EvaluationTag(key="tag2", value="value...
50
1,392
mlflow
tests/evaluate/logging/test_evaluation_entity.py
.py
from mlflow.entities import Metric from mlflow.evaluation.assessment import AssessmentEntity, AssessmentSource from mlflow.evaluation.evaluation import EvaluationEntity from mlflow.evaluation.evaluation_tag import EvaluationTag def test_evaluation_equality(): source_1 = AssessmentSource(source_type="HUMAN", sourc...
185
6,161
mlflow
tests/evaluate/logging/test_utils.py
.py
from mlflow.entities import Metric from mlflow.evaluation.assessment import AssessmentEntity, AssessmentSource from mlflow.evaluation.evaluation import EvaluationEntity from mlflow.evaluation.evaluation_tag import EvaluationTag from mlflow.evaluation.utils import evaluations_to_dataframes def test_evaluations_to_data...
269
9,390
mlflow
tests/uc_oss/test_uc_oss_integration.py
.py
import os import subprocess import sys import pandas as pd import pytest from sklearn import datasets from sklearn.ensemble import RandomForestClassifier from sklearn.model_selection import train_test_split import mlflow from mlflow.exceptions import MlflowException from tests.helper_functions import get_safe_port f...
157
5,710
mlflow
tests/bedrock/test_bedrock_autolog.py
.py
import base64 import io import json from pathlib import Path from unittest import mock import boto3 import pytest from botocore.exceptions import NoCredentialsError from botocore.response import StreamingBody from packaging.version import Version import mlflow from mlflow.entities import SpanLogLevel from mlflow.trac...
1,540
49,709
mlflow
tests/bedrock/test_genai_semconv_converter.py
.py
import base64 import json from pathlib import Path from unittest import mock import boto3 import pytest import mlflow from mlflow.bedrock.genai_semconv_converter import _convert_image from mlflow.tracing.constant import GenAiSemconvKey from tests.tracing.helper import capture_otel_export, reset_autolog_state # noqa...
257
8,860
mlflow
tests/strands/test_strands_tracing.py
.py
import json from collections.abc import AsyncIterator, Sequence from typing import Any from strands import Agent from strands.models.model import Model from strands.tools.tools import PythonAgentTool import mlflow from mlflow.entities import SpanType from mlflow.environment_variables import MLFLOW_USE_DEFAULT_TRACER_...
323
10,130
mlflow
tests/strands/conftest.py
.py
import pytest from opentelemetry import trace as otel_trace import mlflow from mlflow.tracing.provider import provider @pytest.fixture(autouse=True) def clear_autolog_state(reset_tracing): # Reset strands tracer singleton to clear cached tracer provider try: import strands.telemetry.tracer as strands...
32
1,013
mlflow
tests/diffusers/test_diffusers_model_export.py
.py
import importlib.util import json from pathlib import Path import numpy as np import pytest import yaml pytest.importorskip("diffusers") pytest.importorskip("safetensors") from unittest.mock import MagicMock, Mock, patch from safetensors.numpy import save_file import mlflow import mlflow.diffusers from mlflow.diff...
724
22,570
mlflow
tests/tracing/test_provider.py
.py
import random import threading from concurrent.futures import ThreadPoolExecutor from unittest import mock import pytest from opentelemetry import trace from opentelemetry.sdk.trace.id_generator import RandomIdGenerator import mlflow from mlflow.entities.trace_location import ( MlflowExperimentLocation, UCSch...
1,234
44,146
mlflow
tests/tracing/test_tracing_client.py
.py
import contextvars import json import uuid from unittest.mock import Mock, patch import pytest from opentelemetry import trace as trace_api from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan import mlflow from mlflow.entities.experiment import Experiment from mlflow.entities.experiment_tag import Ex...
796
29,115
mlflow
tests/tracing/test_fluent.py
.py
import asyncio import json import os import subprocess import sys import threading import time import uuid import warnings from concurrent.futures import ThreadPoolExecutor, as_completed from dataclasses import asdict from datetime import datetime from unittest import mock import pytest from opentelemetry.sdk.trace.ex...
3,255
112,287
mlflow
tests/tracing/test_assessment.py
.py
import os from unittest import mock import pytest import mlflow from mlflow.entities.assessment import ( AssessmentError, Expectation, Feedback, IssueReference, ) from mlflow.entities.assessment_source import AssessmentSource, AssessmentSourceType from mlflow.entities.issue import IssueStatus from mlf...
1,088
38,795
mlflow
tests/tracing/test_distributed.py
.py
import os import re import subprocess import sys import time from contextlib import contextmanager from pathlib import Path from typing import Iterator import requests import mlflow from mlflow.tracing.distributed import ( get_tracing_context_headers_for_http_request, set_tracing_context_from_http_request_hea...
208
8,537
mlflow
tests/tracing/test_databricks.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.tracing.databricks import set_databricks_monitoring_sql_warehouse_id def test_set_databricks_monitoring_sql_warehouse_id_requires_databricks_tracking_uri(): with mock.patch("mlflow.get_tracking_uri", return_value="...
52
2,167
mlflow
tests/tracing/test_enablement.py
.py
from unittest import mock import pytest import mlflow from mlflow.entities.trace_location import UCSchemaLocation from mlflow.exceptions import MlflowException from mlflow.tracing.enablement import ( set_experiment_trace_location, unset_experiment_trace_location, ) from tests.tracing.helper import skip_when_...
153
6,007
mlflow
tests/tracing/test_attachments_integration.py
.py
import mlflow from mlflow.tracing.attachments import Attachment def test_attachment_roundtrip_with_local_tracking(): image_bytes = b"\x89PNG\r\n\x1a\n fake png content" audio_bytes = b"RIFF fake wav content" with mlflow.start_span(name="integration-span") as span: span.set_inputs({ "p...
52
1,892
mlflow
tests/tracing/test_trace_archival_config.py
.py
from unittest.mock import patch import pytest import mlflow.tracing.trace_archival_config as trace_archival_config_module from mlflow.environment_variables import MLFLOW_TRACE_ARCHIVAL_CONFIG from mlflow.exceptions import MlflowException from mlflow.tracing.trace_archival_config import get_trace_archival_server_confi...
167
5,865
mlflow
tests/tracing/test_span_links_api.py
.py
import mlflow from mlflow.entities import Link from mlflow.entities.span import NoOpSpan from mlflow.tracing.fluent import start_span_no_context from tests.tracing.helper import get_traces # --- Integration tests for start_span with links --- def test_start_span_with_links(): links = [ Link(trace_id="tr...
131
3,791
mlflow
tests/tracing/test_log_level.py
.py
import logging import pytest import mlflow from mlflow.entities import SpanLogLevel from mlflow.entities.span import Span, SpanType from mlflow.entities.span_event import SpanEvent from mlflow.exceptions import MlflowException from mlflow.tracing.constant import SpanAttributeKey from mlflow.tracing.utils.default_log_...
268
9,486
mlflow
tests/tracing/test_attachments.py
.py
import pytest from mlflow.tracing.attachments import Attachment def test_attachment_init(): att = Attachment(content_type="image/png", content_bytes=b"fakepng") assert att.id is not None assert att.content_type == "image/png" assert att.content_bytes == b"fakepng" def test_attachment_ids_are_unique...
117
3,799
mlflow
tests/tracing/test_otel_logging.py
.py
import gzip import time import zlib from pathlib import Path from typing import Iterator from unittest import mock import pytest import requests from opentelemetry import trace as otel_trace from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.proto.collector.trace.v1.t...
1,085
38,321
mlflow
tests/tracing/test_archival.py
.py
from unittest import mock import pytest from mlflow.tracing.archival import ( disable_databricks_trace_archival, enable_databricks_trace_archival, ) from mlflow.version import IS_TRACING_SDK_ONLY if IS_TRACING_SDK_ONLY: pytest.skip("Databricks archival enablement requires skinny", allow_module_level=True...
79
2,939
mlflow
tests/tracing/helper.py
.py
import os import time import uuid from concurrent.futures import ThreadPoolExecutor from dataclasses import dataclass, field from typing import Any from unittest import mock import opentelemetry.trace as trace_api import pytest from opentelemetry.sdk.trace import Event, ReadableSpan from opentelemetry.sdk.trace.export...
349
11,869
mlflow
tests/tracing/test_trace_manager.py
.py
import json import time from threading import Thread from mlflow.entities import LiveSpan, Span from mlflow.entities.model_registry.prompt_version import PromptVersion from mlflow.entities.span_status import SpanStatusCode from mlflow.tracing.constant import TraceTagKey from mlflow.tracing.trace_manager import InMemor...
300
10,883
mlflow
tests/tracing/test_otel_loading.py
.py
import uuid from pathlib import Path from unittest import mock import pytest from opentelemetry import trace as otel_trace from opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter from opentelemetry.sdk.resources import Resource as OTelSDKResource from opentelemetry.sdk.trace import TracerPro...
701
26,404
mlflow
tests/tracing/conftest.py
.py
import random import subprocess import tempfile import time from unittest import mock import pytest import mlflow from mlflow.environment_variables import ( MLFLOW_ENABLE_ASYNC_LOGGING, MLFLOW_ENABLE_ASYNC_TRACE_LOGGING, ) from mlflow.tracing.fluent import _flush_pending_async_trace_writes @pytest.fixture(a...
123
3,529
mlflow
tests/tracing/export/test_async_export_queue.py
.py
import multiprocessing import threading import time from concurrent.futures import ThreadPoolExecutor from unittest import mock from mlflow.tracing.export.async_export_queue import AsyncTraceExportQueue, Task from tests.tracing.helper import skip_when_testing_trace_sdk def test_async_queue_handle_tasks(): queue...
132
3,898
mlflow
tests/tracing/export/test_uc_table_exporter.py
.py
import time from concurrent.futures import ThreadPoolExecutor from unittest import mock import pytest from mlflow.entities.span import Span from mlflow.tracing.export.uc_table import DatabricksUCTableSpanExporter from mlflow.tracing.trace_manager import InMemoryTraceManager from mlflow.tracing.utils import generate_t...
270
10,352
mlflow
tests/tracing/export/test_mlflow_v3_attachments.py
.py
from unittest.mock import MagicMock, patch from mlflow.tracing.attachments import Attachment from mlflow.tracing.constant import SpansLocation, TraceTagKey from mlflow.tracing.export.mlflow_v3 import MlflowV3SpanExporter def _make_trace_info_mock(): info = MagicMock() info.trace_id = "tr-test123" info.ta...
126
4,421
mlflow
tests/tracing/export/test_mlflow_v3_exporter.py
.py
import json import os import threading import time from concurrent.futures import ThreadPoolExecutor from unittest import mock import pytest from google.protobuf.json_format import ParseDict import mlflow from mlflow.entities import LiveSpan from mlflow.entities.model_registry import PromptVersion from mlflow.entitie...
1,137
45,342
mlflow
tests/tracing/export/test_inference_table_exporter.py
.py
import json from unittest import mock import pytest import mlflow from mlflow.entities import LiveSpan, Trace from mlflow.entities.model_registry import PromptVersion from mlflow.entities.trace_info import TraceInfo from mlflow.tracing.constant import TraceMetadataKey, TraceSizeStatsKey from mlflow.tracing.export.inf...
503
18,865
mlflow
tests/tracing/export/genai_semconv/test_translator.py
.py
import json import pytest from opentelemetry.sdk.trace import ReadableSpan from opentelemetry.trace import SpanContext, SpanKind, TraceFlags from opentelemetry.trace.status import Status, StatusCode from mlflow.tracing.constant import GenAiSemconvKey, SpanAttributeKey from mlflow.tracing.export.genai_semconv.translat...
247
8,301
mlflow
tests/tracing/display/test_ipython.py
.py
import json from collections import defaultdict from unittest.mock import Mock import pytest import mlflow from mlflow.tracing.display import ( IPythonTraceDisplayHandler, get_display_handler, get_notebook_iframe_html, ) from tests.tracing.helper import create_trace, skip_module_when_testing_trace_sdk s...
339
10,855
mlflow
tests/tracing/otel/test_voltagent_translator.py
.py
import json from unittest import mock import pytest from mlflow.entities.span import Span, SpanType from mlflow.tracing.constant import SpanAttributeKey from mlflow.tracing.otel.translation import ( translate_span_type_from_otel, translate_span_when_storing, ) from mlflow.tracing.otel.translation.voltagent im...
224
7,478
mlflow
tests/tracing/otel/test_livekit_translator.py
.py
import json from unittest import mock import pytest from mlflow.entities.span import Span, SpanType from mlflow.tracing.constant import SpanAttributeKey from mlflow.tracing.otel.translation import ( translate_span_type_from_otel, translate_span_when_storing, ) from mlflow.tracing.otel.translation.livekit impo...
321
10,123
mlflow
tests/tracing/otel/test_otel_archival.py
.py
from __future__ import annotations import json import pytest from opentelemetry.proto.trace.v1.trace_pb2 import TracesData from opentelemetry.sdk.resources import Resource as OTelResource from opentelemetry.sdk.trace import Event as OTelEvent from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from o...
223
7,622
mlflow
tests/tracing/otel/test_span_translation.py
.py
import json from typing import Any from unittest import mock import pytest from mlflow.entities.span import Span, SpanType from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKey from mlflow.tracing.otel.translation import ( sanitize_attributes, translate_loaded_span, translate_span_type_from_...
943
32,345
mlflow
tests/tracing/otel/test_vercel_ai_translator.py
.py
import json from unittest import mock import pytest from mlflow.entities.span import Span from mlflow.tracing.constant import SpanAttributeKey from mlflow.tracing.otel.translation import translate_span_when_storing @pytest.mark.parametrize( ("attributes", "expected_inputs", "expected_outputs"), [ # ...
200
8,199
mlflow
tests/tracing/processor/test_otel_processor.py
.py
from unittest import mock from opentelemetry.sdk.trace.export import SpanExportResult from mlflow.entities.trace_info import TraceInfo, TraceLocation, TraceState from mlflow.tracing.constant import TRACE_SCHEMA_VERSION_KEY, SpanAttributeKey from mlflow.tracing.processor.otel import OtelSpanProcessor from mlflow.traci...
115
4,142
mlflow
tests/tracing/processor/test_inference_table_processor.py
.py
import json from unittest import mock import pytest from mlflow.entities.span import LiveSpan from mlflow.entities.trace_state import TraceState from mlflow.tracing.constant import ( TRACE_SCHEMA_VERSION, TRACE_SCHEMA_VERSION_KEY, SpanAttributeKey, TraceMetadataKey, ) from mlflow.tracing.processor.inf...
220
7,846
mlflow
tests/tracing/processor/test_mlflow_v3_processor.py
.py
import json from unittest import mock import pytest from opentelemetry.sdk.trace.export import BatchSpanProcessor, SpanExportResult import mlflow.tracking.context.default_context from mlflow.entities.span import LiveSpan from mlflow.entities.trace_status import TraceStatus from mlflow.environment_variables import MLF...
438
15,240
mlflow
tests/tracing/processor/test_otel_metrics.py
.py
import time import pytest from opentelemetry import metrics from opentelemetry.sdk.metrics import MeterProvider from opentelemetry.sdk.metrics.export import InMemoryMetricReader import mlflow @pytest.fixture def metric_reader() -> InMemoryMetricReader: """Create an in-memory metric reader for testing.""" re...
108
3,690
mlflow
tests/tracing/processor/test_uc_table_processor.py
.py
from unittest import mock import pytest import mlflow import mlflow.tracking.context.default_context from mlflow.entities.span import LiveSpan from mlflow.entities.trace_location import TraceLocationType, UCSchemaLocation from mlflow.entities.trace_state import TraceState from mlflow.environment_variables import MLFL...
217
8,473
mlflow
tests/tracing/opentelemetry/test_integration.py
.py
import pytest from opentelemetry import trace as otel_trace from opentelemetry.sdk.trace import TracerProvider from opentelemetry.sdk.trace.export import SimpleSpanProcessor from opentelemetry.sdk.trace.export.in_memory_span_exporter import InMemorySpanExporter import mlflow from mlflow.entities.span import SpanStatus...
456
19,470
mlflow
tests/tracing/utils/test_warning.py
.py
import logging import warnings import pytest import mlflow from mlflow.tracing.utils.warning import suppress_warning from tests.tracing.helper import skip_when_testing_trace_sdk def test_suppress_token_detach_warning(caplog): logger = logging.getLogger("opentelemetry.context") logger.setLevel(logging.INFO)...
104
3,448
mlflow
tests/tracing/utils/test_otlp_auth.py
.py
import base64 from collections.abc import Generator from contextlib import contextmanager from unittest.mock import patch from mlflow.tracing.utils.otlp import MLFLOW_EXPERIMENT_ID_HEADER, build_otlp_headers from mlflow.utils.credentials import MlflowCreds @contextmanager def mock_creds(username: str | None = None, ...
52
1,963
mlflow
tests/tracing/utils/test_processor.py
.py
from unittest.mock import patch import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.tracing.utils.processor import validate_span_processors from tests.tracing.helper import get_traces @mlflow.trace def predict(text: str): return "Answer: " + text @pytest.fixture(autouse=True...
143
4,271
mlflow
tests/tracing/utils/test_exception.py
.py
import pytest from mlflow.exceptions import MlflowTracingException from mlflow.tracing.utils.exception import raise_as_trace_exception def test_raise_as_trace_exception(): @raise_as_trace_exception def test_fn(): raise ValueError("error") with pytest.raises(MlflowTracingException, match="error")...
20
452
mlflow
tests/tracing/utils/test_timeout.py
.py
import time from concurrent.futures import ThreadPoolExecutor from unittest import mock import pytest import mlflow from mlflow.entities.span_event import SpanEvent from mlflow.entities.span_status import SpanStatusCode from mlflow.tracing.export.inference_table import _TRACE_BUFFER, pop_trace from mlflow.tracing.tra...
163
5,402
mlflow
tests/tracing/utils/test_config.py
.py
import pytest import mlflow from mlflow.tracing.config import TracingConfig, get_config @pytest.fixture(autouse=True) def reset_tracing_config(): mlflow.tracing.reset() def test_tracing_config_default_values(): config = TracingConfig() assert config.span_processors == [] def test_configure(): # D...
115
3,089
mlflow
tests/tracing/utils/test_prompt.py
.py
import json import pytest from mlflow.entities.model_registry import PromptVersion from mlflow.exceptions import MlflowException from mlflow.tracing.utils.prompt import update_linked_prompts_tag def test_update_linked_prompts_tag(): pv1 = PromptVersion(name="test_prompt", version=1, template="Test template") ...
42
1,804
mlflow
tests/tracing/utils/test_search.py
.py
import pytest from mlflow.exceptions import MlflowException from mlflow.tracing.utils.search import _FieldParser, _parse_fields, _ParsedField @pytest.mark.parametrize( ("field", "expected"), [ # no dot ("span.inputs", _ParsedField("span", "inputs", None)), ("span.outputs", _ParsedFiel...
81
3,234
mlflow
tests/tracing/utils/test_environment.py
.py
from unittest import mock import pytest from mlflow.tracing.utils.environment import resolve_env_metadata from mlflow.utils.mlflow_tags import ( MLFLOW_DATABRICKS_NOTEBOOK_ID, MLFLOW_DATABRICKS_NOTEBOOK_PATH, MLFLOW_GIT_BRANCH, MLFLOW_GIT_COMMIT, MLFLOW_GIT_REPO_URL, MLFLOW_SOURCE_NAME, ML...
61
2,020
mlflow
tests/tracing/utils/test_truncation.py
.py
import json from unittest.mock import patch import pytest 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.tracing.utils.truncation import _get_trunc...
233
7,103
mlflow
tests/tracing/utils/test_copy.py
.py
import time import pytest import mlflow from mlflow.tracing.utils.copy import copy_trace_to_experiment from tests.tracing.helper import purge_traces def _create_test_span_dict(request_id="test-trace", parent_id=None): """Helper to create a minimal valid span dict for testing""" return { "name": "ro...
124
3,659
mlflow
tests/tracing/utils/test_utils.py
.py
import json import logging from unittest import mock from unittest.mock import Mock, patch import litellm import pytest from opentelemetry import trace as trace_api from pydantic import ValidationError import mlflow from mlflow.entities import ( LiveSpan, SpanType, ) from mlflow.entities.span import SpanType ...
871
28,999
mlflow
tests/tracing/utils/test_otlp.py
.py
import gzip import time import zlib from collections.abc import Callable import pytest from fastapi import HTTPException import mlflow from mlflow.entities.span import SpanType from mlflow.environment_variables import MLFLOW_TRACE_ENABLE_OTLP_DUAL_EXPORT from mlflow.tracing.processor.mlflow_v3 import MlflowV3SpanProc...
332
13,052
mlflow
tests/tracing/fixtures/flask_tracing_server.py
.py
"""Flask server for distributed tracing tests.""" import sys import requests from flask import Flask, jsonify, request import mlflow from mlflow.tracing.distributed import ( get_tracing_context_headers_for_http_request, set_tracing_context_from_http_request_headers, ) REQUEST_TIMEOUT = 20 app = Flask(__nam...
81
2,476
mlflow
tests/tracing/sample_code/model_with_add_trace.py
.py
import mlflow _SAMPLE_TRACE = { "info": { "request_id": "2e72d64369624e6888324462b62dc120", "experiment_id": "0", "timestamp_ms": 1726145090860, "execution_time_ms": 162, "status": "OK", "request_metadata": { "mlflow.trace_schema.version": "2", ...
57
1,714
mlflow
tests/entities/test_gateway_endpoint.py
.py
from mlflow.entities import ( GatewayEndpoint, GatewayEndpointBinding, GatewayEndpointModelMapping, GatewayModelDefinition, GatewayModelLinkageType, GatewayResourceType, ) def test_model_definition_creation_full(): model_def = GatewayModelDefinition( model_definition_id="model-def-...
409
13,573
mlflow
tests/entities/test_job_status.py
.py
import pytest from mlflow.entities._job_status import JobStatus from mlflow.protos.jobs_pb2 import JobStatus as ProtoJobStatus @pytest.mark.parametrize( ("status", "expected_proto"), [ (JobStatus.PENDING, ProtoJobStatus.JOB_STATUS_PENDING), (JobStatus.RUNNING, ProtoJobStatus.JOB_STATUS_IN_PRO...
20
697
mlflow
tests/entities/test_assessment.py
.py
import json import time from unittest.mock import patch import pytest from mlflow.entities.assessment import ( Assessment, AssessmentError, AssessmentSource, Expectation, ExpectationValue, Feedback, FeedbackValue, IssueReference, IssueReferenceValue, ) from mlflow.entities.assessme...
757
26,152
mlflow
tests/entities/test_span_status.py
.py
import pytest from opentelemetry import trace as trace_api from opentelemetry.proto.trace.v1.trace_pb2 import Status as OTelProtoStatus from opentelemetry.trace import Status as OTelStatus from opentelemetry.trace import StatusCode as OTelStatusCode from mlflow.entities import SpanStatus, SpanStatusCode from mlflow.ex...
112
4,246
mlflow
tests/entities/test_trace_state.py
.py
import pytest from mlflow.entities.trace_state import TraceState from mlflow.protos.service_pb2 import TraceInfoV3 as ProtoTraceInfo @pytest.mark.parametrize( ("state", "proto_state"), [ (TraceState.STATE_UNSPECIFIED, ProtoTraceInfo.State.STATE_UNSPECIFIED), (TraceState.OK, ProtoTraceInfo.Sta...
19
613
mlflow
tests/entities/test_run_inputs.py
.py
from mlflow.entities import RunInputs from mlflow.entities.dataset_input import DatasetInput def _check_inputs(run_datasets, datasets): for d1, d2 in zip(run_datasets, datasets): assert d1.dataset.digest == d2.dataset.digest assert d1.dataset.name == d2.dataset.name assert d1.dataset.sourc...
45
1,451
mlflow
tests/entities/test_evaluation_dataset.py
.py
import json from unittest.mock import Mock, patch import pandas as pd import pytest from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from mlflow.entities.dataset_record import DatasetRecord from mlflow.entities.dataset_record_source import DatasetRecordSourceType from mlflow.entities.evaluation_da...
747
23,993
mlflow
tests/entities/test_metric.py
.py
import re import pytest from mlflow.entities import Metric from mlflow.exceptions import MlflowException from mlflow.utils.time import get_current_time_millis from tests.helper_functions import random_int, random_str def _check(metric, key, value, timestamp, step): assert type(metric) == Metric assert metr...
104
2,892
mlflow
tests/entities/test_trace_metrics.py
.py
import pytest from mlflow.entities.trace_metrics import ( AggregationType, MetricAggregation, MetricDataPoint, MetricViewType, ) from mlflow.protos import service_pb2 as pb @pytest.mark.parametrize( ("view_type", "expected_proto"), list(zip(MetricViewType, pb.MetricViewType.values(), strict=T...
134
4,943