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
qutip
qutip/tests/core/data/test_properties.py
.py
import numpy as np import pytest import qutip from qutip import data as _data from qutip import CoreOptions from . import conftest from qutip.core.data.dia import clean_dia @pytest.fixture(params=[_data.CSR, _data.Dense, _data.Dia], ids=["CSR", "Dense", "Dia"]) def datatype(request): return request.param class ...
257
10,244
qutip
qutip/tests/core/data/test_convert.py
.py
import numpy as np import pytest from scipy import sparse from qutip import data, CoreOptions from .test_mathematics import UnaryOpMixin def test_init_empty_data(): shape = (3, 3) base_data = data.Data(shape) assert base_data.shape[0] == shape[0] assert base_data.shape[1] == shape[1] @pytest.mark.pa...
118
4,874
qutip
qutip/tests/core/data/test_dispatch.py
.py
import pytest import itertools import qutip from qutip.core.data.dispatch import Dispatcher, _constructed_specialisation import qutip.core.data as _data class pseudo_dipatched: def __init__(self, types, output): if output: self.output = types[-1] self.inputs = types[:-1] el...
218
6,802
qutip
qutip/tests/core/data/test_block_operations.py
.py
import pytest import numpy as np from qutip.core import data as _data from qutip.core.data import csr, Dense from . import conftest @pytest.mark.parametrize('outtype', _data.to.dtypes) def test_empty_block_build(outtype): """block_build with no blocks should return a zero matrix""" block_rows = np.array([], d...
247
9,641
qutip
qutip/tests/core/data/test_reshape.py
.py
from .test_mathematics import UnaryOpMixin import pytest import numpy as np from qutip import data from qutip.core.data import CSR, Dense, Dia class TestSplitColumns(UnaryOpMixin): def op_numpy(self, matrix): return [column[:, np.newaxis] for column in matrix.T] specialisations = [ pytest.par...
127
4,694
qutip
qutip/tests/core/data/test_norm.py
.py
from . import test_mathematics as testing import numpy as np import scipy.linalg import pytest from qutip import data from qutip.core.data import CSR, Dense, Dia import numbers class TestOneNorm(testing.UnaryOpMixin): def op_numpy(self, matrix): return scipy.linalg.norm(matrix, 1) specialisations = [...
74
2,402
qutip
qutip/tests/core/data/test_ptrace.py
.py
from . import test_mathematics as testing import numpy as np import scipy.linalg import pytest from qutip import data from qutip.core.data import CSR, Dense, Dia class TestPtrace(testing.UnaryOpMixin): def op_numpy(self, matrix, dims, sel): sel.sort() ndims = len(dims) dkeep = [dims[x] for...
110
3,571
qutip
qutip/tests/core/data/test_mean.py
.py
import pytest import numpy as np import qutip import numbers from qutip.core.data.mean import mean_csr, mean_dia, mean_dense from qutip.core.data.mean import mean_abs_csr, mean_abs_dia, mean_abs_dense from qutip.core.data import CSR, Dia, Dense from . import test_mathematics as testing class TestMean(testing.UnaryOp...
84
2,632
qutip
qutip/tests/core/data/test_mathematics.py
.py
import itertools import numpy as np import pytest import scipy import warnings from qutip.core import data from qutip.core.data import Data, Dense, CSR, Dia from qutip.core.data.dense import OrderEfficiencyWarning from . import conftest # The ParameterSet is actually a pretty hidden type, so it's easiest to access #...
1,247
45,538
qutip
qutip/tests/core/data/conftest.py
.py
import numpy as np import scipy.sparse import qutip def shuffle_indices_scipy_csr(matrix, gen=None): """ Given a scipy CSR matrix or array, shuffle the indices within each row and return a new object of the same type. This should represent the same matrix, but in the less efficient, "unsorted" manne...
139
5,014
qutip
qutip/tests/piqs/test_piqs.py
.py
""" Tests for Permutational Invariant Quantum solver (PIQS). """ import math import numpy as np from numpy.testing import ( assert_raises, assert_array_equal, assert_array_almost_equal, assert_almost_equal, assert_equal, ) from scipy.sparse import block_diag, coo_matrix from qutip import Qobj, entro...
1,575
52,275
qutip
qutip/legacy/rcsolve.py
.py
""" This module provides exact solvers for a system-bath setup using the reaction coordinate method. """ # Author: Neill Lambert, Anubhav Vardhan # Contact: nwlambert@gmail.com __all__ = ['rcsolve'] import warnings import numpy as np import scipy.sparse as sp from numpy import matrix from numpy import linalg from .....
121
3,707
qutip
qutip/legacy/__init__.py
.py
import warnings warnings.warn("Function in legacy are untested.") del warnings from .nonmarkov.memorycascade import MemoryCascade
6
131
qutip
qutip/legacy/nonmarkov/memorycascade.py
.py
# @author: Arne L. Grimsmo # @email1: arne.grimsmo@gmail.com # @organization: University of Sherbrooke """ This module is an implementation of the method introduced in [1], for solving open quantum systems subject to coherent feedback with a single discrete time-delay. This method is referred to as the ``memory cascad...
432
12,909
qutip
qutip/_mkl/spsolve.py
.py
import sys import numpy as np import scipy.sparse as sp from ctypes import c_int, byref from numpy.ctypeslib import ndpointer import time from qutip.settings import settings as qset # Load solver functions from mkl_lib pardiso = qset.mkl_lib.pardiso pardiso_delete = qset.mkl_lib.pardiso_handle_delete if sys.maxsize > ...
407
12,901
qutip
qutip/_mkl/spmv.py
.py
import numpy as np from ctypes import POINTER, c_int, c_char, byref from numpy.ctypeslib import ndpointer import qutip.settings as qset zcsrgemv = qset.mkl_lib.mkl_cspblas_zcsrgemv def mkl_spmv(A, x): """ sparse csr_spmv using MKL """ m, _ = A.shape # Pointers to data of the matrix data = A.d...
39
1,196
qutip
qutip/ui/progressbar.py
.py
__all__ = ['BaseProgressBar', 'TextProgressBar', 'EnhancedTextProgressBar', 'TqdmProgressBar', 'HTMLProgressBar', 'progress_bars'] import time import datetime import sys from qutip import settings class BaseProgressBar(object): """ An abstract progress bar with some shared functionality...
207
6,173
qutip
qutip/piqs/piqs.py
.py
"""Permutational Invariant Quantum Solver (PIQS) This module calculates the Liouvillian for the dynamics of ensembles of identical two-level systems (TLS) in the presence of local and collective processes by exploiting permutational symmetry and using the Dicke basis. It also allows to characterize nonlinear functions...
1,920
53,204
mlflow
bin/install.py
.py
""" Install binary tools for MLflow development. """ # ruff: noqa: T201 import argparse import gzip import hashlib import http.client import platform import re import shutil import subprocess import tarfile import tempfile import time import urllib.request from dataclasses import dataclass from pathlib import Path fro...
338
12,008
mlflow
mlflow/environment_variables.py
.py
""" This module defines environment variables used in MLflow. MLflow's environment variables adhere to the following naming conventions: - Public variables: environment variable names begin with `MLFLOW_` - Internal-use variables: For variables used only internally, names start with `_MLFLOW_` """ import os import war...
1,705
80,170
mlflow
mlflow/exceptions.py
.py
import json import logging from mlflow.error_classification import ErrorClass, SqlState from mlflow.protos.databricks_pb2 import ( ABORTED, ALREADY_EXISTS, BAD_REQUEST, CANCELLED, CUSTOMER_UNAUTHORIZED, DATA_LOSS, DEADLINE_EXCEEDED, ENDPOINT_NOT_FOUND, INTERNAL_ERROR, INVALID_PA...
307
11,549
mlflow
mlflow/runs.py
.py
""" CLI for runs """ import json import click import mlflow from mlflow import MlflowClient from mlflow.entities import RunStatus, ViewType from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID, MLFLOW_EXPERIMENT_NAME from mlflow.exceptions import MlflowException from mlflow.mcp.decorator import mlflow_mcp f...
253
8,060
mlflow
mlflow/__main__.py
.py
from mlflow.cli import cli cli.main()
4
39
mlflow
mlflow/__init__.py
.py
""" The ``mlflow`` module provides a high-level "fluent" API for starting and managing MLflow runs. For example: .. code:: python import mlflow mlflow.start_run() mlflow.log_param("my", "param") mlflow.log_metric("score", 100) mlflow.end_run() You can also use the context manager syntax like thi...
451
14,048
mlflow
mlflow/mismatch.py
.py
from __future__ import annotations import importlib.metadata import warnings def _get_version(package_name: str) -> str | None: try: return importlib.metadata.version(package_name) except importlib.metadata.PackageNotFoundError: return None def _check_version_mismatch() -> None: """ ...
43
1,335
mlflow
mlflow/version.py
.py
# Copyright 2018 Databricks, Inc. import importlib.metadata import re VERSION = "3.15.2.dev0" def is_release_version(): return bool(re.match(r"^\d+\.\d+\.\d+$", VERSION)) def _is_package_installed(package_name: str) -> bool: try: importlib.metadata.version(package_name) return True exce...
30
974
mlflow
mlflow/error_classification.py
.py
"""Centralized error classification for MLflow exceptions. Maps error codes to sqlstate codes and error classes for structured error classification and observability. Client-side errors use the KAM0x/XXM0x namespace, while server/CP errors use the KAMCx/XXMCx namespace. Terminology: error_code: The existing MLflo...
198
9,094
mlflow
mlflow/client.py
.py
""" The ``mlflow.client`` module provides a Python CRUD interface to MLflow Experiments, Runs, Model Versions, and Registered Models. This is a lower level API that directly translates to MLflow `REST API <../rest-api.html>`_ calls. For a higher level API for managing an "active run", use the :py:mod:`mlflow` module. "...
13
407
mlflow
mlflow/db.py
.py
import click @click.group("db") def commands(): """ Commands for managing an MLflow tracking database. """ @commands.command() @click.argument("url") def upgrade(url): """ Upgrade the schema of an MLflow tracking database to the latest supported version. **IMPORTANT**: Schema migrations can...
359
12,646
mlflow
mlflow/experiments.py
.py
import json import os import click import mlflow from mlflow.entities import ExperimentTag, ViewType from mlflow.exceptions import MlflowException from mlflow.mcp.decorator import mlflow_mcp from mlflow.protos import databricks_pb2 from mlflow.tracing.constant import TraceExperimentTagKey from mlflow.tracking import ...
420
14,909
mlflow
mlflow/webhooks/types.py
.py
"""Type definitions for MLflow webhook payloads. This module contains class definitions for all webhook event payloads that are sent when various model registry events occur. """ from typing import Literal, TypeAlias, TypedDict from mlflow.entities.webhook import WebhookAction, WebhookEntity, WebhookEvent class Re...
590
15,358
mlflow
mlflow/webhooks/__init__.py
.py
"""MLflow webhooks module. This module provides webhook functionality for MLflow model registry and prompt registry events. """ from mlflow.webhooks.constants import WEBHOOK_SIGNATURE_HEADER from mlflow.webhooks.types import ( ModelVersionAliasCreatedPayload, ModelVersionAliasDeletedPayload, ModelVersionC...
43
1,248
mlflow
mlflow/webhooks/constants.py
.py
# MLflow webhook headers WEBHOOK_SIGNATURE_HEADER = "X-MLflow-Signature" WEBHOOK_TIMESTAMP_HEADER = "X-MLflow-Timestamp" WEBHOOK_DELIVERY_ID_HEADER = "X-MLflow-Delivery-Id" # Webhook signature version WEBHOOK_SIGNATURE_VERSION = "v1"
8
235
mlflow
mlflow/webhooks/delivery.py
.py
"""Webhook delivery implementation following Standard Webhooks conventions. This module implements webhook delivery patterns similar to the Standard Webhooks specification (https://www.standardwebhooks.com), providing consistent and secure webhook delivery with HMAC signature verification and timestamp-based replay pr...
357
11,847
mlflow
mlflow/webhooks/ssrf.py
.py
"""Connection-time SSRF protection for outbound webhook delivery. ``_validate_webhook_url`` resolves the webhook hostname and checks that every resolved IP is public, but it discards the resolved IP and the subsequent ``requests.post`` re-resolves the hostname independently. That TOCTOU gap lets a DNS-rebinding attack...
145
5,265
mlflow
mlflow/johnsnowlabs/__init__.py
.py
""" The ``mlflow.johnsnowlabs`` module provides an API for logging and loading Spark NLP and NLU models. This module exports the following flavors: Johnsnowlabs (native) format Allows models to be loaded as Spark Transformers for scoring in a Spark session. Models with this flavor can be loaded as NluPipelines...
892
34,834
mlflow
mlflow/spacy/__init__.py
.py
""" The ``mlflow.spacy`` module provides an API for logging and loading spaCy models. This module exports spacy models with the following flavors: spaCy (native) format This is the main flavor that can be loaded back into spaCy. :py:mod:`mlflow.pyfunc` Produced for use by generic pyfunc-based deployment tools ...
380
14,045
mlflow
mlflow/demo/__init__.py
.py
import logging import mlflow.demo.generators # noqa: F401 from mlflow.demo.base import DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX, BaseDemoGenerator, DemoResult from mlflow.demo.registry import demo_registry from mlflow.utils.workspace_context import WorkspaceContext, get_request_workspace _logger = logging.getLogger(...
49
1,799
mlflow
mlflow/demo/registry.py
.py
from __future__ import annotations from typing import TYPE_CHECKING from mlflow.demo.base import DemoFeature if TYPE_CHECKING: from mlflow.demo.base import BaseDemoGenerator class DemoRegistry: """Registry for demo data generators. Provides registration and lookup of BaseDemoGenerator subclasses by na...
44
1,447
mlflow
mlflow/demo/data.py
.py
from __future__ import annotations import base64 import functools import math import struct import zlib from dataclasses import dataclass, field from typing import Any from mlflow.demo.base import DEMO_PROMPT_PREFIX from mlflow.entities.issue import IssueSeverity from mlflow.entities.model_registry import PromptVersi...
1,234
49,213
mlflow
mlflow/demo/base.py
.py
import logging from abc import ABC, abstractmethod from dataclasses import dataclass from enum import Enum from mlflow.tracking._tracking_service.utils import _get_store _logger = logging.getLogger(__name__) DEMO_EXPERIMENT_NAME = "MLflow Demo" DEMO_PROMPT_PREFIX = "mlflow-demo" class DemoFeature(str, Enum): "...
136
4,746
mlflow
mlflow/demo/generators/judges.py
.py
from __future__ import annotations import logging from mlflow.demo.base import ( DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX, BaseDemoGenerator, DemoFeature, DemoResult, ) from mlflow.genai.scorers.registry import delete_scorer, list_scorers from mlflow.tracking._tracking_service.utils import _get_st...
145
5,916
mlflow
mlflow/demo/generators/evaluation.py
.py
from __future__ import annotations import contextlib import hashlib import io import logging import os from collections.abc import Callable from typing import TYPE_CHECKING, Literal import mlflow if TYPE_CHECKING: from mlflow.genai.datasets import EvaluationDataset from mlflow.demo.base import ( DEMO_EXPERI...
404
15,123
mlflow
mlflow/demo/generators/__init__.py
.py
from mlflow.demo.generators.evaluation import EvaluationDemoGenerator from mlflow.demo.generators.issues import IssuesDemoGenerator from mlflow.demo.generators.judges import JudgesDemoGenerator from mlflow.demo.generators.prompts import PromptsDemoGenerator from mlflow.demo.generators.review_queues import ReviewQueuesD...
29
1,277
mlflow
mlflow/demo/generators/issues.py
.py
from __future__ import annotations import logging from typing import Any import mlflow from mlflow import MlflowClient from mlflow.demo.base import ( DEMO_EXPERIMENT_NAME, BaseDemoGenerator, DemoFeature, DemoResult, ) from mlflow.demo.data import ASSESSMENT_TO_ISSUE, ROOT_CAUSE_EXPLANATIONS from mlflo...
233
9,592
mlflow
mlflow/demo/generators/review_queues.py
.py
from __future__ import annotations import logging from typing import Any import mlflow from mlflow.demo.base import ( DEMO_EXPERIMENT_NAME, BaseDemoGenerator, DemoFeature, DemoResult, ) from mlflow.exceptions import MlflowException from mlflow.genai.label_schemas import InputCategorical, InputPassFail...
190
7,827
mlflow
mlflow/demo/generators/traces.py
.py
from __future__ import annotations import copy import hashlib import json import logging import random import re from dataclasses import dataclass from datetime import datetime, timedelta, timezone from typing import Any, Literal import mlflow from mlflow.demo.base import ( DEMO_EXPERIMENT_NAME, DEMO_PROMPT_P...
894
33,742
mlflow
mlflow/demo/generators/prompts.py
.py
from __future__ import annotations import logging from mlflow.demo.base import ( DEMO_EXPERIMENT_NAME, DEMO_PROMPT_PREFIX, BaseDemoGenerator, DemoFeature, DemoResult, ) from mlflow.demo.data import DEMO_PROMPTS, DemoPromptDef from mlflow.genai.prompts import ( delete_prompt_alias, register...
132
4,401
mlflow
mlflow/gemini/__init__.py
.py
""" The ``mlflow.gemini`` module provides an API for tracing the interaction with Gemini models. """ from mlflow.gemini.autolog import ( async_patched_class_call, patched_class_call, patched_module_call, ) from mlflow.telemetry.events import AutologgingEvent from mlflow.telemetry.track import _record_event...
99
2,967
mlflow
mlflow/gemini/chat.py
.py
import json import logging from typing import TYPE_CHECKING from mlflow.types.chat import ( ChatTool, Function, FunctionParams, FunctionToolDefinition, ParamProperty, ToolCall, ) if TYPE_CHECKING: from google import genai _logger = logging.getLogger(__name__) def convert_gemini_func_to_...
113
3,462
mlflow
mlflow/gemini/autolog.py
.py
import inspect import logging from typing import Any import mlflow import mlflow.gemini from mlflow.entities import SpanType from mlflow.entities.span import LiveSpan from mlflow.gemini.chat import ( convert_gemini_func_to_mlflow_chat_tool, ) from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKey from...
328
11,809
mlflow
mlflow/gemini/genai_semconv_converter.py
.py
import json from typing import Any from mlflow.tracing.constant import GenAiSemconvKey from mlflow.tracing.export.genai_semconv.converter import GenAiSemconvConverter class GeminiConverter(GenAiSemconvConverter): def convert_inputs(self, inputs: dict[str, Any]) -> list[dict[str, Any]] | None: contents = ...
127
4,972
mlflow
mlflow/bedrock/utils.py
.py
import logging from typing import Any, Callable, Sequence from mlflow.bedrock import FLAVOR_NAME from mlflow.environment_variables import _MLFLOW_TESTING from mlflow.tracing.constant import TokenUsageKey from mlflow.utils.autologging_utils.config import AutoLoggingConfig _logger = logging.getLogger(__name__) # Token...
213
8,539
mlflow
mlflow/bedrock/__init__.py
.py
import logging from mlflow.telemetry.events import AutologgingEvent from mlflow.telemetry.track import _record_event from mlflow.utils.autologging_utils import autologging_integration, safe_patch _logger = logging.getLogger(__name__) FLAVOR_NAME = "bedrock" @autologging_integration(FLAVOR_NAME) def autolog( lo...
50
1,988
mlflow
mlflow/bedrock/chat.py
.py
from typing import Any from mlflow.types.chat import ChatTool, FunctionToolDefinition def convert_tool_to_mlflow_chat_tool(tool: dict[str, Any]) -> ChatTool: """ Convert Bedrock tool definition into MLflow's standard format (OpenAI compatible). Ref: https://docs.aws.amazon.com/bedrock/latest/APIReferenc...
27
810
mlflow
mlflow/bedrock/_autolog.py
.py
import io import json import logging from typing import Any from botocore.client import BaseClient from botocore.response import StreamingBody import mlflow from mlflow.bedrock import FLAVOR_NAME from mlflow.bedrock.chat import convert_tool_to_mlflow_chat_tool from mlflow.bedrock.stream import ConverseStreamWrapper, ...
240
9,147
mlflow
mlflow/bedrock/genai_semconv_converter.py
.py
""" Bedrock Converse API message converter for GenAI Semantic Convention export. Translates Bedrock's Converse API format (content blocks with text, toolUse, toolResult, image) into the GenAI semconv parts array format. """ import base64 import json from typing import Any from mlflow.tracing.constant import GenAiSem...
149
5,306
mlflow
mlflow/bedrock/stream.py
.py
import json import logging from typing import Any from botocore.eventstream import EventStream from mlflow.bedrock.utils import ( capture_exception, parse_complete_token_usage_from_response, parse_partial_token_usage_from_response, ) from mlflow.entities.span import LiveSpan from mlflow.entities.span_even...
217
7,875
mlflow
mlflow/strands/__init__.py
.py
import logging from mlflow.strands.autolog import setup_strands_tracing, teardown_strands_tracing from mlflow.telemetry.events import AutologgingEvent from mlflow.telemetry.track import _record_event from mlflow.utils.autologging_utils import autologging_integration FLAVOR_NAME = "strands" _logger = logging.getLogger...
42
1,440
mlflow
mlflow/strands/autolog.py
.py
import json import logging import threading from opentelemetry.context import Context from opentelemetry.sdk.trace import ( ReadableSpan as OTelReadableSpan, ) from opentelemetry.sdk.trace import ( Span as OTelSpan, ) from opentelemetry.sdk.trace import ( TracerProvider as SDKTracerProvider, ) from opentel...
180
7,137
mlflow
mlflow/diffusers/__init__.py
.py
""" The ``mlflow.diffusers`` module provides an API for logging and loading diffusion model LoRA adapters as MLflow Models. This module exports adapter models with the following flavors: :py:mod:`mlflow.diffusers` Adapter weights in safetensors format, with a reference to the base model. :py:mod:`mlflow.pyfunc` ...
541
20,534
mlflow
mlflow/diffusers/wrapper.py
.py
import io import logging import threading from types import MappingProxyType from typing import Any import pandas as pd from mlflow.diffusers import _detect_device from mlflow.exceptions import MlflowException _logger = logging.getLogger(__name__) class _DiffusersAdapterWrapper: def __init__( self, ...
152
5,659
mlflow
mlflow/tracing/provider.py
.py
""" This module provides a set of functions to manage the global tracer provider for MLflow tracing. Every tracing operation in MLflow *MUST* be managed through this module, instead of directly using the OpenTelemetry APIs. This is because MLflow needs to control the initialization of the tracer provider and ensure th...
1,107
44,109
mlflow
mlflow/tracing/destination.py
.py
""" Trace destination classes are DEPRECATED. Use mlflow.entities.trace_location.TraceLocation instead. """ from __future__ import annotations import logging from contextvars import ContextVar from dataclasses import dataclass import mlflow from mlflow.entities.trace_location import ( MlflowExperimentLocation, ...
164
6,247
mlflow
mlflow/tracing/analysis.py
.py
import math from dataclasses import dataclass from mlflow.entities._mlflow_object import _MlflowObject from mlflow.protos.service_pb2 import CalculateTraceFilterCorrelation @dataclass class TraceFilterCorrelationResult(_MlflowObject): """ Result of calculating correlation between two trace filter conditions....
89
3,376
mlflow
mlflow/tracing/databricks.py
.py
from mlflow.exceptions import MlflowException from mlflow.utils.uri import is_databricks_uri def set_databricks_monitoring_sql_warehouse_id( sql_warehouse_id: str, experiment_id: str | None = None ) -> None: """ Set the SQL warehouse ID used for Databricks production monitoring on traces logged to the giv...
43
1,629
mlflow
mlflow/tracing/trace_archival_config.py
.py
from __future__ import annotations import logging import threading import time from dataclasses import dataclass from pathlib import Path from typing import Any import yaml from mlflow.environment_variables import MLFLOW_TRACE_ARCHIVAL_CONFIG from mlflow.exceptions import MlflowException from mlflow.store.tracking.u...
258
8,675
mlflow
mlflow/tracing/trace_manager.py
.py
import contextlib import logging import threading from dataclasses import dataclass, field from typing import Generator, Sequence from mlflow.entities import LiveSpan, Trace, TraceData, TraceInfo from mlflow.entities.model_registry import PromptVersion from mlflow.environment_variables import MLFLOW_TRACE_TIMEOUT_SECO...
238
9,148
mlflow
mlflow/tracing/sampling.py
.py
import contextvars from opentelemetry.sdk.trace.sampling import ( Sampler, SamplingResult, TraceIdRatioBased, ) # Context variable to override the sampling ratio for a specific trace. # When set, the sampler uses this ratio instead of the default. _SAMPLING_RATIO_OVERRIDE = contextvars.ContextVar("samplin...
49
1,579
mlflow
mlflow/tracing/__init__.py
.py
from mlflow.tracing.config import configure from mlflow.tracing.context import context from mlflow.tracing.databricks import set_databricks_monitoring_sql_warehouse_id from mlflow.tracing.display import disable_notebook_display, enable_notebook_display from mlflow.tracing.distributed import ( get_tracing_context_he...
36
1,149
mlflow
mlflow/tracing/archival.py
.py
_ERROR_MSG = ( "The `databricks-agents` package is required to use databricks trace archival. " "Please install it with `pip install databricks-agents`." ) def enable_databricks_trace_archival( *, delta_table_fullname: str, experiment_id: str | None = None, ) -> None: """ Enable archiving ...
71
2,086
mlflow
mlflow/tracing/assessment.py
.py
from typing import Any from mlflow.entities.assessment import ( DEFAULT_FEEDBACK_NAME, Assessment, AssessmentError, Expectation, Feedback, FeedbackValueType, IssueReference, ) from mlflow.entities.assessment_source import AssessmentSource from mlflow.exceptions import MlflowException from m...
482
17,212
mlflow
mlflow/tracing/client.py
.py
import json import logging import time from collections import defaultdict from concurrent.futures import ThreadPoolExecutor from contextlib import nullcontext from typing import TYPE_CHECKING, Sequence import mlflow if TYPE_CHECKING: from mlflow.genai.label_schemas.label_schemas import ( InputCategorical...
1,104
44,937
mlflow
mlflow/tracing/context.py
.py
from __future__ import annotations import contextlib from contextvars import ContextVar from dataclasses import dataclass, field from typing import Generator from mlflow.tracing.constant import TraceMetadataKey @dataclass(frozen=True) class _UserTraceContext: """ Metadata and tags declared via ``mlflow.trac...
124
4,633
mlflow
mlflow/tracing/enablement.py
.py
""" Trace enablement functionality for MLflow to enable tracing to Databricks Storage. """ import logging import mlflow from mlflow.entities.trace_location import UCSchemaLocation from mlflow.exceptions import MlflowException from mlflow.utils.uri import is_databricks_uri from mlflow.version import IS_TRACING_SDK_ONL...
161
5,949
mlflow
mlflow/tracing/trace_archival_service.py
.py
from __future__ import annotations import logging import random import threading import time from contextlib import nullcontext from dataclasses import dataclass from mlflow.entities.workspace import TraceArchivalConfig from mlflow.environment_variables import ( MLFLOW_ENABLE_WORKSPACES, ) from mlflow.exceptions ...
213
8,102
mlflow
mlflow/tracing/locations.py
.py
from mlflow.entities.trace_location import UnityCatalog __all__ = ["UnityCatalog"]
4
84
mlflow
mlflow/tracing/constant.py
.py
from enum import Enum # NB: These keys are placeholders and subject to change class TraceMetadataKey: INPUTS = "mlflow.traceInputs" OUTPUTS = "mlflow.traceOutputs" SOURCE_RUN = "mlflow.sourceRun" MODEL_ID = "mlflow.modelId" # Trace size statistics including total size, number of spans, and max spa...
397
14,432
mlflow
mlflow/tracing/fluent.py
.py
from __future__ import annotations import contextlib import functools import importlib import inspect import json import logging import os import warnings from concurrent.futures import ThreadPoolExecutor from contextvars import ContextVar from typing import TYPE_CHECKING, Any, Callable, Generator, Literal, ParamSpec,...
1,975
77,248
mlflow
mlflow/tracing/config.py
.py
from dataclasses import dataclass, field, replace from typing import TYPE_CHECKING, Any, Callable from mlflow.tracing.utils.processor import validate_span_processors if TYPE_CHECKING: from mlflow.entities.span import LiveSpan @dataclass class TracingConfig: """Configuration for MLflow tracing behavior.""" ...
124
4,413
mlflow
mlflow/tracing/attachments.py
.py
import mimetypes import uuid from pathlib import Path from urllib.parse import parse_qs, urlencode, urlparse class Attachment: """ Represents a binary attachment (image, audio, PDF, etc.) that can be logged as part of a trace span's inputs or outputs. When an Attachment is set as a span input/output ...
74
2,437
mlflow
mlflow/tracing/export/inference_table.py
.py
import logging from typing import Any, Sequence from cachetools import TTLCache from opentelemetry.sdk.trace import ReadableSpan from opentelemetry.sdk.trace.export import SpanExporter from mlflow.entities.model_registry import PromptVersion from mlflow.entities.trace import Trace from mlflow.environment_variables im...
163
6,957
mlflow
mlflow/tracing/export/utils.py
.py
""" Utility functions for prompt linking in trace exporters. """ import logging import threading import uuid from typing import Sequence from mlflow.entities.model_registry import PromptVersion from mlflow.tracing.client import TracingClient _logger = logging.getLogger(__name__) def try_link_prompts_to_trace( ...
71
2,201
mlflow
mlflow/tracing/export/span_batcher.py
.py
import atexit import logging import threading from collections import defaultdict from queue import Queue from typing import Callable from mlflow.entities.span import Span from mlflow.environment_variables import ( MLFLOW_ASYNC_TRACE_LOGGING_MAX_INTERVAL_MILLIS, MLFLOW_ASYNC_TRACE_LOGGING_MAX_SPAN_BATCH_SIZE, ...
123
4,682
mlflow
mlflow/tracing/export/async_export_queue.py
.py
import atexit import logging import threading import time from concurrent.futures import FIRST_COMPLETED, ThreadPoolExecutor, wait from dataclasses import dataclass from queue import Empty, Queue from queue import Full as queue_Full from typing import Any, Callable, Sequence from mlflow.environment_variables import ( ...
188
6,851
mlflow
mlflow/tracing/export/uc_table.py
.py
import logging from typing import Sequence from opentelemetry.sdk.trace import ReadableSpan from mlflow.entities.span import Span from mlflow.entities.trace_info import TraceInfo from mlflow.environment_variables import MLFLOW_ENABLE_ASYNC_TRACE_LOGGING from mlflow.tracing.export.mlflow_v3 import MlflowV3SpanExporter...
76
2,863
mlflow
mlflow/tracing/export/mlflow_v3.py
.py
import logging import os import threading from collections import defaultdict from contextlib import nullcontext from typing import Sequence from opentelemetry.sdk.trace import ReadableSpan from opentelemetry.sdk.trace.export import SpanExporter from mlflow.entities.model_registry import PromptVersion from mlflow.ent...
425
19,908
mlflow
mlflow/tracing/export/genai_semconv/converter.py
.py
""" Abstract base class for format-specific message converters. Each LLM provider stores inputs/outputs in its own format (e.g. OpenAI, Anthropic). Converters translate these provider-specific formats into the GenAI Semantic Convention attributes: gen_ai.input.messages, gen_ai.output.messages, request params, and resp...
84
3,536
mlflow
mlflow/tracing/export/genai_semconv/translator.py
.py
""" Core translator for converting MLflow spans to OpenTelemetry GenAI Semantic Convention format. Phase 1: Universal attributes (model, provider, tokens, span type) normalized across all autologging integrations. Phase 2: Format-specific message content (gen_ai.input.messages, gen_ai.output.messages), request params,...
223
8,446
mlflow
mlflow/tracing/display/__init__.py
.py
from mlflow.tracing.display.display_handler import ( IPythonTraceDisplayHandler, get_notebook_iframe_html, is_using_tracking_server, ) __all__ = [ "IPythonTraceDisplayHandler", "get_display_handler", "is_using_tracking_server", "get_notebook_iframe_html", ] def get_display_handler() -> IP...
41
1,265
mlflow
mlflow/tracing/display/display_handler.py
.py
import html import json import logging from typing import TYPE_CHECKING from urllib.parse import urlencode, urljoin import mlflow from mlflow.environment_variables import ( MLFLOW_MAX_TRACES_TO_DISPLAY_IN_NOTEBOOK, MLFLOW_NOTEBOOK_TRACE_RENDERER_BASE_URL, ) from mlflow.tracing.constant import TRACE_RENDERER_AS...
213
7,242
mlflow
mlflow/tracing/distributed/__init__.py
.py
import logging from contextlib import contextmanager from opentelemetry.trace.propagation.tracecontext import TraceContextTextMapPropagator import mlflow from mlflow.entities.span import LiveSpan from mlflow.telemetry.events import TracingContextPropagation from mlflow.telemetry.track import record_usage_event from m...
191
7,442
mlflow
mlflow/tracing/otel/otel_archival.py
.py
""" Helpers for serializing archived trace spans as OTLP ``TracesData`` protobuf. """ from __future__ import annotations from typing import Any from google.protobuf.message import DecodeError from opentelemetry.proto.trace.v1.trace_pb2 import TracesData from mlflow.entities.span import Span from mlflow.exceptions i...
133
5,008
mlflow
mlflow/tracing/otel/translation/langfuse.py
.py
""" Translation utilities for Langfuse observation attributes. Maps ``langfuse.observation.*`` attributes to MLflow span semantics so that spans forwarded from Langfuse via the generic OTEL processor are stored with correct span types, inputs, and outputs. """ from mlflow.entities.span import SpanType from mlflow.tra...
30
965
mlflow
mlflow/tracing/otel/translation/gemini_cli.py
.py
""" Translator for Gemini CLI OTEL spans. Gemini CLI (google-gemini/gemini-cli) emits OTLP traces using `gen_ai.operation.name` for span kind (same key as the GenAI semantic conventions), but with its own operation names that don't match the standard GenAI values. This translator maps those Gemini-specific names to M...
157
6,446
mlflow
mlflow/tracing/otel/translation/genai_semconv.py
.py
""" Translation utilities for GenAI (Generic AI) semantic conventions. Reference: https://opentelemetry.io/docs/specs/semconv/registry/attributes/gen-ai/ """ import json from typing import Any from mlflow.entities.span import SpanType from mlflow.tracing.otel.translation.base import OtelSchemaTranslator class GenA...
133
5,079
mlflow
mlflow/tracing/otel/translation/livekit.py
.py
""" Translation utilities for LiveKit Agents semantic conventions. LiveKit Agents (Python SDK) provides real-time AI voice agents with built-in OpenTelemetry support. This translator maps LiveKit's span attributes to MLflow's semantic conventions for optimal visualization. Reference: - https://docs.livekit.io/agents/...
117
3,770
mlflow
mlflow/tracing/otel/translation/__init__.py
.py
""" Utilities for translating OTEL span attributes to MLflow span format. This module provides functions to translate span attributes from various OTEL semantic conventions (OpenInference, Traceloop, GenAI) to MLflow span types. It uses modular translator classes for each OTEL schema for better organization and perfor...
487
17,665
mlflow
mlflow/tracing/otel/translation/laminar.py
.py
from typing import Any from mlflow.entities.span import SpanType from mlflow.tracing.otel.translation.base import OtelSchemaTranslator class LaminarTranslator(OtelSchemaTranslator): SPAN_KIND_ATTRIBUTE_KEY = "lmnr.span.type" SPAN_KIND_TO_MLFLOW_TYPE = { "LLM": SpanType.LLM, "TOOL": SpanType....
39
1,224
mlflow
mlflow/tracing/otel/translation/traceloop.py
.py
""" Translation utilities for Traceloop/OpenLLMetry semantic conventions. Reference: https://github.com/traceloop/openllmetry/ """ import re from typing import Any from mlflow.entities.span import SpanType from mlflow.tracing.otel.translation.base import OtelSchemaTranslator class TraceloopTranslator(OtelSchemaTra...
83
3,733