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
docs/api_reference/mcp_server_registry_api_docs.py
.py
import json from pathlib import Path from fastapi import FastAPI from mlflow.server.mcp_server_api import mcp_server_router API_HTML = """ <!DOCTYPE html> <html> <head> <link type="text/css" rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css" /> <link...
63
1,656
mlflow
docs/api_reference/conftest.py
.py
import os import pytest import mlflow @pytest.fixture(autouse=True) def tracking_uri_mock(tmp_path, monkeypatch): tracking_uri = "sqlite:///{}".format(tmp_path / "mlruns.sqlite") mlflow.set_tracking_uri(tracking_uri) monkeypatch.setenv("MLFLOW_TRACKING_URI", tracking_uri) yield mlflow.set_tracki...
29
676
mlflow
docs/api_reference/theme/mlflow/__init__.py
.py
"""Sphinx ReadTheDocs theme. From https://github.com/ryan-roemer/sphinx-bootstrap-theme. """ import os VERSION = (0, 1, 9) __version__ = ".".join(str(v) for v in VERSION) __version_full__ = __version__ def get_html_theme_path(): """Return list of HTML theme paths.""" return os.path.abspath(os.path.dirnam...
18
350
mlflow
docs/api_reference/source/testcode_block.py
.py
""" Standalone script to extract code blocks marked with :test: from Python docstrings. Uses AST to parse Python files and extract docstrings with test code blocks. """ import ast import re import subprocess import textwrap from pathlib import Path _CODE_BLOCK_HEADER_REGEX = re.compile(r"^\.\.\s+code-block::\s*py(tho...
212
7,011
mlflow
docs/api_reference/source/languagesections/__init__.py
.py
import os from docutils import nodes from docutils.parsers.rst import Directive from sphinx.util import logging from sphinx.util.osutil import copyfile logger = logging.getLogger(__name__) JS_FILE = "languagesections.js" class CodeSectionDirective(Directive): has_content = True def run(self): self...
58
1,607
mlflow
docs/scripts/build-all.py
.py
import os import shutil import subprocess from pathlib import Path import click import mlflow mlflow_version = mlflow.version.VERSION def build_docs(package_manager, version): env = os.environ.copy() # ensure it ends with a "/" base_url = env.get("DOCS_BASE_URL", "/docs/").rstrip("/") + "/" api_re...
93
2,366
mlflow
docs/scripts/convert-notebooks.py
.py
""" Converts all .ipynb files from the docs/ folder into .mdx files. This script uses nbconvert to do the processing. """ import multiprocessing import re from pathlib import Path import nbformat import yaml from nbconvert.exporters import MarkdownExporter from nbconvert.preprocessors import Preprocessor SOURCE_DIR...
118
3,591
mlflow
docs/scripts/build-api-docs.py
.py
import os import shutil import subprocess import click @click.command() @click.option("--with-r", "with_r", is_flag=True, default=False, help="Build R documentation") @click.option( "--with-ts", "with_ts", is_flag=True, default=True, help="Build TypeScript documentation" ) def main(with_r, with_ts): try: ...
44
1,550
mlflow
tests/generate_ui_test_data.py
.py
""" Small script used to generate mock data to test the UI. """ import argparse import itertools import random import string from random import random as rand import mlflow from mlflow import MlflowClient def log_metrics(metrics): for k, values in metrics.items(): for v in values: mlflow.log...
195
6,890
mlflow
tests/test_exceptions.py
.py
import json import pickle import pytest from mlflow.exceptions import MlflowException, RestException from mlflow.protos.databricks_pb2 import ( ENDPOINT_NOT_FOUND, INTERNAL_ERROR, INVALID_PARAMETER_VALUE, INVALID_STATE, IO_ERROR, RESOURCE_ALREADY_EXISTS, ) def test_error_code_constructor(): ...
213
7,849
mlflow
tests/test_environment_variables.py
.py
import os import pytest from mlflow.environment_variables import _BooleanEnvironmentVariable, _EnvironmentVariable @pytest.mark.parametrize("value", [0, 1, "0", "1", "TRUE", "FALSE"]) def test_boolean_environment_variable_invalid_default_value(value): with pytest.raises(ValueError, match=r"must be one of \[True...
91
3,104
mlflow
tests/test_flavors.py
.py
import ast import os import mlflow def read_file(path): with open(path) as f: return f.read() def is_model_flavor(src): for node in ast.iter_child_nodes(ast.parse(src)): if ( isinstance(node, ast.Assign) and isinstance(node.targets[0], ast.Name) and node....
41
988
mlflow
tests/simple_repository_server.py
.py
"""PEP 700-compliant Simple Repository API server for serving wheels in tests. This replaces the plain ``http.server`` approach so that uv's ``exclude-newer`` can filter packages by upload time when resolving the local dev wheel. """ from __future__ import annotations import hashlib import json import threading from...
125
4,427
mlflow
tests/test_skinny_client_omits_data_science_libs.py
.py
import os import pytest @pytest.fixture(autouse=True) def is_skinny(): if "MLFLOW_SKINNY" not in os.environ: pytest.skip("This test is only valid for the skinny client") def test_fails_import_flask(): import mlflow # noqa: F401 with pytest.raises(ImportError, match="flask"): import fl...
31
647
mlflow
tests/test_version.py
.py
from mlflow import version def test_is_release_version(monkeypatch): monkeypatch.setattr(version, "VERSION", "1.19.0") assert version.is_release_version() monkeypatch.setattr(version, "VERSION", "1.19.0.dev0") assert not version.is_release_version()
10
269
mlflow
tests/__init__.py
.py
from mlflow.utils.logging_utils import _configure_mlflow_loggers _configure_mlflow_loggers(root_module_name=__name__)
4
119
mlflow
tests/test_mismatch.py
.py
import warnings from importlib.metadata import PackageNotFoundError from unittest import mock import pytest from mlflow.mismatch import _check_version_mismatch @pytest.mark.parametrize( ("mlflow_version", "skinny_version"), [ ("1.0.0", "1.0.0"), ("1.0.0.dev0", "1.0.0"), ("1.0.0", "1....
85
2,706
mlflow
tests/test_skinny_client_omits_sql_libs.py
.py
import os import sys import pytest @pytest.mark.skipif( "MLFLOW_SKINNY" not in os.environ, reason="This test is only valid for the skinny client" ) def test_fails_import_sqlalchemy(): import mlflow # noqa: F401 with pytest.raises(ImportError, match="sqlalchemy"): import sqlalchemy # noqa: F401...
30
776
mlflow
tests/check_mlflow_lazily_imports_ml_packages.py
.py
""" Tests that `import mlflow` and `mlflow.autolog()` do not import ML packages. """ import importlib import logging import sys import mlflow logger = logging.getLogger() def main(): ml_packages = { "catboost", "h2o", "lightgbm", "onnx", "pytorch_lightning", "pys...
57
1,380
mlflow
tests/test_skinny_client_autolog_without_scipy.py
.py
import os import pytest @pytest.mark.skipif( "MLFLOW_SKINNY" not in os.environ, reason="This test is only valid for the skinny client" ) def test_autolog_without_scipy(): import mlflow with pytest.raises(ImportError, match="scipy"): import scipy # noqa: F401 assert not mlflow.models.utils....
19
389
mlflow
tests/helper_functions.py
.py
import functools import json import logging import numbers import os import random import signal import socket import subprocess import sys import tempfile import time import uuid from contextlib import contextmanager from functools import wraps from pathlib import Path from typing import Iterator from unittest import ...
854
27,931
mlflow
tests/test_mlflow_version_comp.py
.py
import os import subprocess import sys import uuid from pathlib import Path import numpy as np import sklearn from pyspark.sql import SparkSession from sklearn.linear_model import LinearRegression import mlflow from mlflow.models import Model def check_load(model_uri: str) -> None: Model.load(model_uri) mod...
230
9,038
mlflow
tests/test_xdist_serial_partition.py
.py
# Tests for the xdist serial/parallel partition used by the two-pass `python` CI job. # # The `python` job runs the suite twice: `--serial=exclude` (parallel bulk) and # `--serial=only` (serial tail). The safety-critical property is that these two passes # form an *exhaustive, disjoint* partition of the collected tests...
198
9,104
mlflow
tests/test_import.py
.py
import subprocess import sys from pathlib import Path import pytest from mlflow.utils.os import is_windows @pytest.mark.skipif(is_windows(), reason="This test fails on Windows") def test_import_mlflow(tmp_path: Path): tmp_script = tmp_path.joinpath("test.py") tmp_script.write_text( """ from pathlib ...
36
822
mlflow
tests/test_cli.py
.py
import os import shutil import subprocess import sys import tempfile import time from pathlib import Path from unittest import mock from urllib.parse import unquote, urlparse from urllib.request import url2pathname import click import numpy as np import pytest import requests from botocore.stub import Stubber from cli...
1,893
67,287
mlflow
tests/test_runs.py
.py
import json import logging import os import textwrap from unittest import mock from unittest.mock import patch import pytest from click.testing import CliRunner import mlflow from mlflow import experiments from mlflow.exceptions import MlflowException from mlflow.runs import create_run, link_traces, list_run from mlf...
597
19,179
mlflow
tests/test_skinny_client_anthropic_import.py
.py
# Regression test for https://github.com/mlflow/mlflow/issues/21779: # mlflow-skinny users couldn't use mlflow.anthropic.autolog() because importing # mlflow.types.chat transitively pulled in numpy via # mlflow.types.__init__ -> mlflow.types.llm -> mlflow.types.schema. import importlib.util import os import pytest ...
25
876
mlflow
tests/conftest.py
.py
import cProfile import inspect import io import json import logging import os import posixpath import pstats import re import shutil import sqlite3 import subprocess import sys import tempfile import threading import time import uuid from collections import defaultdict from contextlib import nullcontext from dataclasse...
1,405
50,338
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