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
mlflow/prophet/__init__.py
.py
""" The ``mlflow.prophet`` module provides an API for logging and loading Prophet models. This module exports univariate Prophet models in the following flavors: Prophet (native) format This is the main flavor that can be accessed with Prophet APIs. :py:mod:`mlflow.pyfunc` Produced for use by generic pyfunc-ba...
405
14,768
mlflow
mlflow/agno/utils.py
.py
import importlib import logging import pkgutil from agno.models.base import Model from agno.storage.base import Storage _logger = logging.getLogger(__name__) def discover_storage_backends(): # 1. Import all storage modules import agno.storage as pkg for _, modname, _ in pkgutil.iter_modules(pkg.__path_...
52
1,455
mlflow
mlflow/agno/__init__.py
.py
import inspect import logging from mlflow.telemetry.events import AutologgingEvent from mlflow.telemetry.track import _record_event from mlflow.utils.annotations import experimental as experimental from mlflow.utils.autologging_utils import autologging_integration, safe_patch FLAVOR_NAME = "agno" _logger = logging.ge...
113
4,117
mlflow
mlflow/agno/autolog_v2.py
.py
""" Autologging logic for Agno V2 (>= 2.0.0) using OpenTelemetry instrumentation. """ import importlib.metadata as _meta import logging from opentelemetry import trace from opentelemetry.context import Context from opentelemetry.trace import Tracer, TracerProvider from mlflow.exceptions import MlflowException from m...
127
4,527
mlflow
mlflow/agno/autolog_v1.py
.py
""" Autologging logic for Agno V1 using MLflow's tracing API. """ import logging from typing import Any import mlflow from mlflow.entities import SpanType from mlflow.entities.span import LiveSpan from mlflow.tracing.constant import SpanAttributeKey, TokenUsageKey from mlflow.tracing.utils import construct_full_input...
194
6,385
mlflow
mlflow/onnx/__init__.py
.py
""" The ``mlflow.onnx`` module provides APIs for logging and loading ONNX models in the MLflow Model format. This module exports MLflow Models with the following flavors: ONNX (native) format This is the main flavor that can be loaded back as an ONNX model object. :py:mod:`mlflow.pyfunc` Produced for use by ge...
613
25,827
mlflow
mlflow/models/wheeled_model.py
.py
import os import platform import shutil import subprocess import sys import yaml import mlflow from mlflow import MlflowClient from mlflow.environment_variables import MLFLOW_WHEELED_MODEL_PIP_DOWNLOAD_OPTIONS from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import BAD_REQUEST from mlfl...
318
13,312
mlflow
mlflow/models/flavor_backend.py
.py
from abc import ABCMeta, abstractmethod from mlflow.utils.annotations import developer_stable @developer_stable class FlavorBackend: """ Abstract class for Flavor Backend. This class defines the API interface for local model deployment of MLflow model flavors. """ __metaclass__ = ABCMeta de...
104
3,321
mlflow
mlflow/models/utils.py
.py
import base64 import datetime as dt import decimal import importlib import json import logging import os import re import shutil import sys import tempfile import uuid from contextlib import contextmanager from copy import deepcopy from pathlib import Path from typing import Any, Dict, List, Union import numpy as np i...
2,077
84,552
mlflow
mlflow/models/model_config.py
.py
import os from typing import Any import yaml from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE __mlflow_model_config__ = None class ModelConfig: """ ModelConfig used in code to read a YAML configuration file or a dictionary. Args: de...
151
5,072
mlflow
mlflow/models/python_api.py
.py
import logging import os import shutil from io import StringIO from typing import ForwardRef, get_args, get_origin from mlflow.exceptions import MlflowException from mlflow.models.flavor_backend_registry import get_flavor_backend from mlflow.utils import env_manager as _EnvManager from mlflow.utils.databricks_utils im...
379
16,191
mlflow
mlflow/models/model.py
.py
import json import logging import os import shutil import uuid from datetime import datetime, timezone from pathlib import Path from pprint import pformat from typing import Any, Callable, Literal, NamedTuple from urllib.parse import urlparse import yaml from packaging.requirements import InvalidRequirement, Requireme...
1,661
68,804
mlflow
mlflow/models/dependencies_schemas.py
.py
import json import logging import warnings from abc import ABC, abstractmethod from contextlib import contextmanager from dataclasses import dataclass, field from enum import Enum from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from mlflow.models.model import Model _logger = logging.getLogger(__name__) ...
298
10,208
mlflow
mlflow/models/flavor_backend_registry.py
.py
""" Registry of supported flavor backends. Contains a mapping of flavors to flavor backends. This mapping is used to select suitable flavor when deploying generic MLflow models. Flavor backend can deploy particular flavor locally to generate predictions, deploy as a local REST api endpoint, or build a docker image for...
54
2,094
mlflow
mlflow/models/docker_utils.py
.py
import logging import os import subprocess from subprocess import Popen from typing import Literal from urllib.parse import urlparse from packaging.version import Version from mlflow.environment_variables import MLFLOW_DOCKER_OPENJDK_VERSION from mlflow.utils import env_manager as em from mlflow.utils.file_utils impo...
230
8,519
mlflow
mlflow/models/__init__.py
.py
""" The ``mlflow.models`` module provides an API for saving machine learning models in "flavors" that can be understood by different downstream tools. The built-in flavors are: - :py:mod:`mlflow.catboost` - :py:mod:`mlflow.dspy` - :py:mod:`mlflow.h2o` - :py:mod:`mlflow.langchain` - :py:mod:`mlflow.lightgbm` - :py:mod...
97
2,702
mlflow
mlflow/models/signature.py
.py
""" The :py:mod:`mlflow.models.signature` module provides an API for specification of model signature. Model signature defines schema of model input and output. See :py:class:`mlflow.types.schema.Schema` for more details on Schema and data types. """ import inspect import logging import re import warnings from copy i...
650
25,444
mlflow
mlflow/models/auth_policy.py
.py
from mlflow.models.resources import Resource, _ResourceBuilder class UserAuthPolicy: """ A minimal list of scopes that the user should have access to in order to invoke this model Note: This is only compatible with Databricks Environment currently. TODO: Add Databricks Documentation for User Auth...
80
2,305
mlflow
mlflow/models/rag_signatures.py
.py
from dataclasses import dataclass, field from mlflow.models import ModelSignature from mlflow.types.schema import ( Array, ColSpec, DataType, Object, Property, Schema, ) from mlflow.utils.annotations import deprecated @deprecated("mlflow.types.llm.ChatMessage") @dataclass class Message: r...
118
3,091
mlflow
mlflow/models/display_utils.py
.py
import html from pathlib import Path from mlflow.models.model import ModelInfo from mlflow.models.signature import ModelSignature from mlflow.types import schema from mlflow.utils import databricks_utils def _is_input_string(inputs: schema.Schema) -> bool: return ( not inputs.has_input_names() an...
159
5,346
mlflow
mlflow/models/cli.py
.py
import logging import click from mlflow.mcp.decorator import mlflow_mcp from mlflow.models import python_api from mlflow.models.flavor_backend_registry import get_flavor_backend from mlflow.models.model import update_model_requirements from mlflow.utils import cli_args from mlflow.utils import env_manager as _EnvMana...
354
12,849
mlflow
mlflow/models/resources.py
.py
import os from abc import ABC, abstractmethod from enum import Enum from typing import Any import yaml DEFAULT_API_VERSION = "1" class ResourceType(Enum): """ Enum to define the different types of resources needed to serve a model. """ UC_CONNECTION = "uc_connection" VECTOR_SEARCH_INDEX = "vect...
342
12,220
mlflow
mlflow/models/notebook_resources/eval_with_dataset_example.py
.py
# ruff: noqa: F821, I001 {{pipInstall}} import pandas as pd import mlflow evals = [ { "request": { "messages": [ {"role": "user", "content": "How do I convert a Spark DataFrame to Pandas?"} ], }, # Optional, needed for judging correctness. "e...
23
574
mlflow
mlflow/models/notebook_resources/eval_with_synthetic_example.py
.py
# ruff: noqa: F821, I001 {{pipInstall}} from databricks.agents.evals import generate_evals_df import mlflow agent_description = "A chatbot that answers questions about Databricks." question_guidelines = """ # User personas - A developer new to the Databricks platform # Example questions - What API lets me parallelize...
23
730
mlflow
mlflow/models/container/__init__.py
.py
""" Initialize the environment and start model serving in a Docker container. To be executed only during the model deployment. """ import logging import multiprocessing import os import shlex import shutil import signal import sys from pathlib import Path from subprocess import Popen, check_call import mlflow from ...
256
9,006
mlflow
mlflow/models/evaluation/default_evaluator.py
.py
import copy import inspect import json import logging import pathlib import pickle import shutil import tempfile import traceback from abc import abstractmethod from typing import Any, Callable, NamedTuple, Optional import numpy as np import pandas as pd import mlflow from mlflow import MlflowClient, MlflowException ...
984
41,785
mlflow
mlflow/models/evaluation/evaluator_registry.py
.py
import warnings from mlflow.exceptions import MlflowException from mlflow.utils.import_hooks import register_post_import_hook from mlflow.utils.plugins import get_entry_points class ModelEvaluatorRegistry: """ Scheme-based registry for model evaluator implementations """ def __init__(self): ...
81
3,014
mlflow
mlflow/models/evaluation/__init__.py
.py
from mlflow.data.evaluation_dataset import EvaluationDataset from mlflow.models.evaluation.base import ( EvaluationArtifact, EvaluationMetric, EvaluationResult, ModelEvaluator, evaluate, list_evaluators, make_metric, ) from mlflow.models.evaluation.validation import MetricThreshold __all__ ...
24
528
mlflow
mlflow/models/evaluation/lift_curve.py
.py
import matplotlib.pyplot as plt import numpy as np def _cumulative_gain_curve(y_true, y_score, pos_label=None): """ This method is copied from scikit-plot package. See https://github.com/reiinakano/scikit-plot/blob/2dd3e6a76df77edcbd724c4db25575f70abb57cb/scikitplot/helpers.py#L157 This function gene...
179
6,165
mlflow
mlflow/models/evaluation/calibration_curve.py
.py
import matplotlib.pyplot as plt import numpy as np from matplotlib.figure import Figure from sklearn.calibration import CalibrationDisplay, calibration_curve def make_multi_class_calibration_plot( n_classes, y_true, y_probs, calibration_config, label_list ) -> Figure: """Generate one calibration plot for all ...
113
4,277
mlflow
mlflow/models/evaluation/artifacts.py
.py
import json import pathlib import pickle from json import JSONDecodeError from typing import NamedTuple import matplotlib.pyplot as plt import numpy as np import pandas as pd from mlflow.environment_variables import MLFLOW_ALLOW_PICKLE_DESERIALIZATION from mlflow.exceptions import MlflowException from mlflow.models.e...
204
7,197
mlflow
mlflow/models/evaluation/deprecated.py
.py
import functools import warnings from mlflow.models.evaluation import evaluate as model_evaluate @functools.wraps(model_evaluate) def evaluate(*args, **kwargs): warnings.warn( "The `mlflow.evaluate` API has been deprecated as of MLflow 3.0.0. " "Please use these new alternatives:\n\n" " -...
20
767
mlflow
mlflow/models/evaluation/base.py
.py
import inspect import json import keyword import logging import os import pathlib import signal import urllib.parse from abc import ABCMeta, abstractmethod from contextlib import contextmanager, nullcontext from dataclasses import dataclass from inspect import Parameter, Signature from types import FunctionType from ty...
1,812
81,237
mlflow
mlflow/models/evaluation/_shap_patch.py
.py
import pickle import shap from shap._serializable import Deserializer, Serializable, Serializer class _PatchedKernelExplainer(shap.KernelExplainer): def save(self, out_file, model_saver=None, masker_saver=None): """ This patched `save` method fix `KernelExplainer.save`. Issues in original...
52
2,548
mlflow
mlflow/models/evaluation/validation.py
.py
import logging import operator import os from decimal import Decimal from mlflow.exceptions import MlflowException from mlflow.models.evaluation import EvaluationResult from mlflow.protos.databricks_pb2 import BAD_REQUEST, INVALID_PARAMETER_VALUE _logger = logging.getLogger(__name__) class MetricThreshold: """ ...
434
18,147
mlflow
mlflow/models/evaluation/evaluators/default.py
.py
import logging import os import time from typing import Optional import numpy as np import pandas as pd import mlflow from mlflow.entities.metric import Metric from mlflow.exceptions import MlflowException from mlflow.metrics import ( MetricValue, ari_grade_level, exact_match, flesch_kincaid_grade_lev...
237
8,493
mlflow
mlflow/models/evaluation/evaluators/classifier.py
.py
import logging import math from contextlib import contextmanager from typing import Any, Callable, NamedTuple, Optional import numpy as np import pandas as pd from sklearn import metrics as sk_metrics import mlflow from mlflow import MlflowException from mlflow.environment_variables import _MLFLOW_EVALUATE_SUPPRESS_C...
712
26,949
mlflow
mlflow/models/evaluation/evaluators/regressor.py
.py
from typing import Optional import numpy as np from sklearn import metrics as sk_metrics import mlflow from mlflow.models.evaluation.base import EvaluationMetric, EvaluationResult, _ModelType from mlflow.models.evaluation.default_evaluator import ( BuiltInEvaluator, _extract_output_and_other_columns, _ext...
97
3,342
mlflow
mlflow/models/evaluation/evaluators/shap.py
.py
import functools import logging from typing import Optional import numpy as np from packaging.version import Version from sklearn.pipeline import Pipeline as sk_Pipeline import mlflow from mlflow import MlflowException from mlflow.models.evaluation.base import EvaluationMetric, EvaluationResult, _ModelType from mlflo...
292
11,879
mlflow
mlflow/models/evaluation/utils/metric.py
.py
import logging from dataclasses import dataclass from typing import Any, Callable import numpy as np from mlflow.metrics.base import MetricValue from mlflow.models.evaluation.base import EvaluationMetric _logger = logging.getLogger(__name__) @dataclass class MetricDefinition: """ A dataclass representing a...
129
4,532
mlflow
mlflow/models/evaluation/utils/trace.py
.py
import contextlib import inspect import logging from typing import Any, Callable from mlflow.ml_package_versions import FLAVOR_TO_MODULE_NAME from mlflow.utils.autologging_utils import ( AUTOLOGGING_INTEGRATIONS, autologging_conf_lock, get_autolog_function, is_autolog_supported, ) from mlflow.utils.aut...
180
8,278
mlflow
mlflow/azure/client.py
.py
""" This module provides utilities for performing Azure Blob Storage operations without requiring the heavyweight azure-storage-blob library dependency """ import logging import urllib from copy import deepcopy from mlflow.utils import rest_utils from mlflow.utils.file_utils import read_chunk _logger = logging.getLo...
320
11,509
mlflow
mlflow/projects/env_type.py
.py
DOCKER = "docker_env" PYTHON = "python_env" CONDA = "conda_env" ALL = [DOCKER, PYTHON, CONDA]
5
94
mlflow
mlflow/projects/utils.py
.py
import logging import os import pathlib import re import shutil import tempfile import urllib.parse import zipfile from io import BytesIO from mlflow import tracking from mlflow.entities import Param, SourceType from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID, MLFLOW_RUN_ID, MLFLOW_TRACKING_URI from mlfl...
351
12,649
mlflow
mlflow/projects/databricks.py
.py
import hashlib import json import logging import os import posixpath import re import tempfile import textwrap import time import uuid from pathlib import Path from shlex import quote from mlflow import tracking from mlflow.entities import RunStatus from mlflow.environment_variables import MLFLOW_EXPERIMENT_ID, MLFLOW...
612
24,796
mlflow
mlflow/projects/_project_spec.py
.py
"""Internal utilities for parsing MLproject YAML files.""" import os import yaml from mlflow.exceptions import ExecutionException, MlflowException from mlflow.projects import env_type from mlflow.tracking import artifact_utils from mlflow.utils import data_utils from mlflow.utils.environment import _PYTHON_ENV_FILE_...
374
15,108
mlflow
mlflow/projects/submitted_run.py
.py
import logging import os import signal from abc import abstractmethod from mlflow.entities import RunStatus from mlflow.utils.annotations import developer_stable _logger = logging.getLogger(__name__) @developer_stable class SubmittedRun: """ Wrapper around an MLflow project run (e.g. a subprocess running an...
107
3,529
mlflow
mlflow/projects/kubernetes.py
.py
import logging import os import time from datetime import datetime from shlex import quote, split from threading import RLock import docker import kubernetes from kubernetes.config.config_exception import ConfigException from mlflow.entities import RunStatus from mlflow.exceptions import ExecutionException from mlflo...
166
6,363
mlflow
mlflow/projects/__init__.py
.py
""" The ``mlflow.projects`` module provides an API for running MLflow projects locally or remotely. """ import json import logging import os import yaml import mlflow.projects.databricks from mlflow import tracking from mlflow.entities import RunStatus from mlflow.exceptions import ExecutionException, MlflowExceptio...
448
17,350
mlflow
mlflow/projects/docker.py
.py
import logging import os import posixpath import shutil import subprocess import tempfile import urllib.parse import urllib.request import docker from mlflow import tracking from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.exceptions import ExecutionException from mlflow.projects.utils import ...
168
6,305
mlflow
mlflow/projects/backend/abstract_backend.py
.py
from abc import ABCMeta, abstractmethod from mlflow.utils.annotations import developer_stable @developer_stable class AbstractBackend: """ Abstract plugin class defining the interface needed to execute MLflow projects. You can define subclasses of ``AbstractBackend`` and expose them as third-party plugin...
51
2,113
mlflow
mlflow/projects/backend/__init__.py
.py
""" This module defines developer APIs for defining pluggable execution backends for MLflow projects. See `MLflow Plugins <../../plugins.html>`_ for more information. """ from mlflow.projects.backend.abstract_backend import AbstractBackend __all__ = ["AbstractBackend"]
9
272
mlflow
mlflow/projects/backend/loader.py
.py
import logging from mlflow.projects.backend.local import LocalBackend from mlflow.utils.plugins import get_entry_points ENTRYPOINT_GROUP_NAME = "mlflow.project_backend" _logger = logging.getLogger(__name__) # Statically register backend defined in mlflow MLFLOW_BACKENDS = { "local": LocalBackend, } def load_...
36
932
mlflow
mlflow/projects/backend/local.py
.py
import logging import os import platform import posixpath import subprocess import sys from pathlib import Path import mlflow from mlflow import tracking from mlflow.environment_variables import ( MLFLOW_KERBEROS_TICKET_CACHE, MLFLOW_KERBEROS_USER, MLFLOW_PYARROW_EXTRA_CONF, ) from mlflow.exceptions import...
429
17,192
mlflow
mlflow/types/utils.py
.py
import logging import warnings from collections import defaultdict from copy import deepcopy from typing import Any, Dict, List import numpy as np import pandas as pd import pydantic from mlflow.exceptions import MlflowException from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE from mlflow.types import...
742
27,468
mlflow
mlflow/types/responses.py
.py
import json from collections.abc import Sequence from itertools import tee from typing import Any, Generator, Iterator from uuid import uuid4 from pydantic import BaseModel, ConfigDict, model_validator from mlflow.types.agent import ChatContext from mlflow.types.responses_helpers import ( BaseRequestPayload, ...
567
21,457
mlflow
mlflow/types/__init__.py
.py
""" The :py:mod:`mlflow.types` module defines data types and utilities to be used by other mlflow components to describe interface independent of other frameworks or languages. """ from mlflow.version import IS_TRACING_SDK_ONLY if not IS_TRACING_SDK_ONLY: try: import numpy as _np # noqa: F401 _H...
38
949
mlflow
mlflow/types/chat.py
.py
from __future__ import annotations import warnings from typing import Annotated, Any, Literal from uuid import uuid4 from pydantic import BaseModel, ConfigDict, Field, model_serializer class TextContentPart(BaseModel): type: Literal["text"] text: str class ImageUrl(BaseModel): """ Represents an im...
369
11,530
mlflow
mlflow/types/llm.py
.py
from __future__ import annotations import time import uuid from dataclasses import asdict, dataclass, field, fields from typing import Any, Literal from mlflow.types.schema import AnyType, Array, ColSpec, DataType, Map, Object, Property, Schema # TODO: Switch to pydantic in a future version of MLflow. # For no...
952
37,735
mlflow
mlflow/types/type_hints.py
.py
import base64 import logging from datetime import datetime from functools import lru_cache from types import UnionType from typing import Any, NamedTuple, Optional, TypeVar, Union, get_args, get_origin import pydantic import pydantic.fields from mlflow.environment_variables import _MLFLOW_IS_IN_SERVING_ENVIRONMENT fr...
633
24,613
mlflow
mlflow/types/schema.py
.py
from __future__ import annotations import builtins import datetime as dt import json import string from abc import ABC, abstractmethod from copy import deepcopy from dataclasses import is_dataclass from enum import Enum from types import UnionType from typing import Any, TypedDict, Union, get_args, get_origin import ...
1,518
56,238
mlflow
mlflow/types/agent.py
.py
from typing import Any from pydantic import ConfigDict, model_validator from mlflow.types.chat import BaseModel, ChatUsage, ToolCall from mlflow.types.llm import ( _custom_inputs_col_spec, _custom_outputs_col_spec, _token_usage_stats_col_spec, ) from mlflow.types.schema import ( Array, ColSpec, ...
236
9,118
mlflow
mlflow/types/responses_helpers.py
.py
import warnings from typing import Any from pydantic import BaseModel, ConfigDict, Field, model_validator """ Classes are inspired by classes for Response and ResponseStreamEvent in openai-python https://github.com/openai/openai-python/blob/ed53107e10e6c86754866b48f8bd862659134ca8/src/openai/types/responses/response...
430
12,574
mlflow
mlflow/claude_code/__init__.py
.py
"""Claude Code integration for MLflow. This module provides automatic tracing of Claude Code conversations to MLflow. Usage: mlflow autolog claude [directory] [options] After setup, use the regular 'claude' command and traces will be automatically captured. To enable tracing for the Claude Agent SDK, use `mlflo...
27
644
mlflow
mlflow/claude_code/hooks.py
.py
"""Legacy compatibility helpers for the retired Python Claude hook runtime.""" import json import sys from mlflow.claude_code.tracing import get_hook_response def stop_hook_handler() -> None: """No-op shim for repositories still wired to the old Python hook.""" print(json.dumps(get_hook_response())) # noqa...
17
531
mlflow
mlflow/claude_code/tracing.py
.py
"""MLflow tracing integration for Claude Code interactions.""" import dataclasses import json import logging import os import sys from datetime import datetime from pathlib import Path from typing import Any import dateutil.parser import mlflow from mlflow.claude_code.config import ( MLFLOW_TRACING_ENABLED, ...
882
32,646
mlflow
mlflow/claude_code/cli.py
.py
"""MLflow CLI commands for Claude Code integration.""" import os import sys from pathlib import Path import click from mlflow.claude_code.config import get_tracing_status, setup_environment_config from mlflow.claude_code.hooks import stop_hook_handler from mlflow.claude_code.plugin import ( disable_tracing_plugi...
353
11,286
mlflow
mlflow/claude_code/config.py
.py
"""Configuration management for Claude Code integration with MLflow.""" import json import os from dataclasses import dataclass from pathlib import Path from typing import Any from mlflow.environment_variables import ( MLFLOW_EXPERIMENT_ID, MLFLOW_EXPERIMENT_NAME, MLFLOW_TRACKING_URI, ) # Configuration f...
193
6,366
mlflow
mlflow/claude_code/plugin.py
.py
"""Plugin bootstrap helpers for Claude Code tracing.""" from __future__ import annotations import shutil import subprocess from pathlib import Path from typing import Any import click from mlflow.claude_code.config import ( ENVIRONMENT_FIELD, MLFLOW_EXPERIMENT_ID, MLFLOW_EXPERIMENT_NAME, MLFLOW_TRAC...
109
2,768
mlflow
mlflow/pmdarima/__init__.py
.py
""" The ``mlflow.pmdarima`` module provides an API for logging and loading ``pmdarima`` models. This module exports univariate ``pmdarima`` models in the following formats: Pmdarima format Serialized instance of a ``pmdarima`` model using pickle. :py:mod:`mlflow.pyfunc` Produced for use by generic pyfunc-based...
651
23,878
mlflow
mlflow/crewai/__init__.py
.py
""" The ``mlflow.crewai`` module provides an API for tracing CrewAI AI agents. """ import importlib import logging from packaging.version import Version from mlflow.crewai.autolog import ( patched_class_call, patched_native_tool_call, patched_standalone_call, ) from mlflow.telemetry.events import Autolog...
126
4,681
mlflow
mlflow/crewai/autolog.py
.py
import inspect import json import logging import warnings from contextlib import contextmanager, nullcontext from typing import Any from packaging.version import Version import mlflow from mlflow.entities import SpanType from mlflow.entities.span import LiveSpan from mlflow.tracing.constant import SpanAttributeKey, T...
481
16,629
mlflow
mlflow/agent/agents.py
.py
"""Registry of coding agent CLIs supported by ``mlflow agent setup``. To support a new agent, append an :class:`AgentTool` entry to :data:`AGENTS`. That is the only place per-agent variation lives. """ from __future__ import annotations import shutil from dataclasses import dataclass from typing import Literal Agen...
62
1,618
mlflow
mlflow/agent/cli.py
.py
"""`mlflow agent` CLI group. Wires per-subcommand modules under :mod:`mlflow.agent`. To add a new subcommand, drop a package under ``mlflow/agent/<name>/`` and register it here with ``commands.add_command``. """ from __future__ import annotations import click from mlflow.agent.setup.cli import setup @click.group(...
21
435
mlflow
mlflow/agent/setup/select.py
.py
from __future__ import annotations import os import select import sys import click if sys.platform != "win32": import termios import tty def _read_key() -> str: """Read a single keystroke (or escape sequence) from stdin in raw mode.""" fd = sys.stdin.fileno() old = termios.tcgetattr(fd) try...
95
3,034
mlflow
mlflow/agent/setup/prompt.py
.py
from __future__ import annotations import re from importlib import resources from pathlib import Path import mlflow.assistant.skills as _skills_pkg from mlflow.agent.agents import AgentTool _PLACEHOLDER = re.compile(r"\{\{\s*(\w+)\s*\}\}") def _read_template(filename: str) -> str: return resources.files("mlflo...
113
4,022
mlflow
mlflow/agent/setup/cli.py
.py
from __future__ import annotations import socket import subprocess import sys from dataclasses import dataclass from pathlib import Path from typing import Any from urllib.parse import urlparse import click from mlflow.agent.agents import AGENTS, AgentName, AgentTool, detect_installed, get_agent from mlflow.agent.se...
365
13,229
mlflow
mlflow/shap/__init__.py
.py
import os import tempfile import types import warnings from contextlib import contextmanager from typing import Any import numpy as np import yaml import mlflow import mlflow.utils.autologging_utils from mlflow import pyfunc from mlflow.models import Model, ModelInputExample, ModelSignature from mlflow.models.model i...
692
25,527
mlflow
mlflow/llama_index/pyfunc_wrapper.py
.py
import asyncio import threading import uuid from typing import TYPE_CHECKING, Any if TYPE_CHECKING: from llama_index.core import QueryBundle from mlflow.models.utils import _convert_llm_input_data CHAT_ENGINE_NAME = "chat" QUERY_ENGINE_NAME = "query" RETRIEVER_ENGINE_NAME = "retriever" SUPPORTED_ENGINES = {CHAT_...
331
12,676
mlflow
mlflow/llama_index/tracer.py
.py
import inspect import json import logging from functools import singledispatchmethod from typing import Any, Generator import llama_index.core import pydantic from llama_index.core.base.base_retriever import BaseRetriever from llama_index.core.base.embeddings.base import BaseEmbedding from llama_index.core.base.llms.b...
749
32,309
mlflow
mlflow/llama_index/model.py
.py
import logging import os import tempfile from typing import Any import yaml import mlflow from mlflow import pyfunc from mlflow.entities.model_registry.prompt import Prompt from mlflow.exceptions import MlflowException from mlflow.llama_index.constant import FLAVOR_NAME from mlflow.llama_index.pyfunc_wrapper import c...
574
23,901
mlflow
mlflow/llama_index/__init__.py
.py
from mlflow.llama_index.autolog import autolog from mlflow.llama_index.constant import FLAVOR_NAME from mlflow.version import IS_TRACING_SDK_ONLY __all__ = ["autolog", "FLAVOR_NAME"] # Import model logging APIs only if mlflow skinny or full package is installed, # i.e., skip if only mlflow-tracing package is installe...
23
594
mlflow
mlflow/llama_index/autolog.py
.py
from mlflow.llama_index.constant import FLAVOR_NAME from mlflow.telemetry.events import AutologgingEvent from mlflow.telemetry.track import _record_event from mlflow.utils.autologging_utils import autologging_integration def autolog( log_traces: bool = True, disable: bool = False, silent: bool = False, ):...
59
2,196
mlflow
mlflow/llama_index/serialize_objects.py
.py
import importlib import inspect import json import logging from typing import Any, Callable from llama_index.core import PromptTemplate from llama_index.core.base.embeddings.base import BaseEmbedding from llama_index.core.callbacks.base import CallbackManager from llama_index.core.schema import BaseComponent _logger ...
193
7,152
mlflow
fs2db/src/generate_synthetic_data.py
.py
# ruff: noqa: T201 """ Generate synthetic MLflow FileStore data for testing the fs2db migration tool. Usage: uv run --with mlflow==3.6.0 --no-project python -I \ fs2db/src/generate_synthetic_data.py --output /tmp/fs2db/v3.6.0/ --size small This script uses the MLflow public API to create realistic on-disk...
435
14,337
mlflow
dev/check_actions.py
.py
"""Validate GitHub Actions workflow and action files. Complements `.github/policy.rego` with checks that need cross-file or remote context. """ import json import re import subprocess import sys from collections import defaultdict from collections.abc import Iterator from dataclasses import dataclass from pathlib imp...
281
8,951
mlflow
dev/run_dev_server.py
.py
"""Launch the MLflow dev backend and the React dev server for local development. Cleans up child process groups on exit/SIGINT/SIGTERM so we don't leave zombies. """ from __future__ import annotations import argparse import atexit import os import shlex import shutil import signal import socket import subprocess imp...
183
6,450
mlflow
dev/check_function_signatures.py
.py
from __future__ import annotations import argparse import ast import os import subprocess import sys from dataclasses import dataclass from pathlib import Path def is_github_actions() -> bool: return os.environ.get("GITHUB_ACTIONS") == "true" @dataclass class Error: file_path: Path line: int column...
383
13,140
mlflow
dev/format.py
.py
import os import re import subprocess import sys RUFF_FORMAT = [sys.executable, "-m", "ruff", "format"] MESSAGE_REGEX = re.compile(r"^Would reformat: (.+)$") def transform(stdout: str, is_maintainer: bool) -> str: if not stdout: return stdout transformed = [] for line in stdout.splitlines(): ...
56
1,621
mlflow
dev/check_init_py.py
.py
""" Pre-commit hook to check for missing `__init__.py` files in mlflow and tests directories. This script ensures that all directories under the mlflow package and tests directory that contain Python files also have an `__init__.py` file. This prevents `setuptools` from excluding these directories during package build...
55
1,989
mlflow
dev/check_skills.py
.py
import re import sys from pathlib import Path from typing import Any import yaml # https://agentskills.io/specification#frontmatter NAME_RE = re.compile(r"^[a-z0-9]+(-[a-z0-9]+)*$") NAME_MAX = 64 DESCRIPTION_MAX = 1024 def parse_frontmatter(text: str) -> dict[str, Any] | None: if not text.startswith("---\n"): ...
69
2,015
mlflow
dev/show_package_release_dates.py
.py
import asyncio import json import re import subprocess import sys from collections.abc import Sequence from datetime import datetime, timedelta, timezone from pathlib import Path from pypi import Package, get_packages def get_cooldown_days() -> int: pyproject = Path(__file__).resolve().parent.parent / "pyproject...
72
2,619
mlflow
dev/check_patch_prs.py
.py
import argparse import concurrent.futures import itertools import os import re import subprocess import sys import tempfile from dataclasses import dataclass from datetime import datetime, timedelta, timezone from pathlib import Path from typing import Any import requests from packaging.version import Version MAX_COM...
291
9,832
mlflow
dev/update_requirements.py
.py
""" This script updates the `max_major_version` attribute of each package in a YAML dependencies specification (e.g. requirements/core-requirements.yaml) to the maximum available version on PyPI. """ import asyncio import os import re import urllib.error import urllib.request from datetime import datetime, timedelta, ...
109
3,973
mlflow
dev/check_whitespace_only.py
.py
""" Detect files where all changes are whitespace-only. This helps avoid unnecessary commit history noise from whitespace-only changes. """ import argparse import json import os import sys import time import urllib.error import urllib.request from typing import cast BYPASS_LABEL = "allow-whitespace-only" _MAX_ATTEM...
149
4,404
mlflow
dev/ruff.py
.py
import os import re import subprocess import sys RUFF = [sys.executable, "-m", "ruff", "check", "--output-format=concise"] MESSAGE_REGEX = re.compile(r"^.+:\d+:\d+: ([A-Z0-9]+) (\[\*\] )?.+$") def transform(stdout: str, is_maintainer: bool) -> str: transformed = [] for line in stdout.splitlines(): if...
57
1,691
mlflow
dev/classify_flaky_tests.py
.py
"""Classify detected flaky tests and decide which to annotate @pytest.mark.flaky. Second stage of the flaky-test pipeline. `detect_flaky_tests.py` produces the *deterministic* signal (a test that failed on one run attempt and passed on the next attempt of the same commit). This stage adds *judgment*: given each test's...
200
8,014
mlflow
dev/update_changelog.py
.py
import argparse import os import re import subprocess from collections import defaultdict from datetime import datetime from pathlib import Path from typing import Any, NamedTuple import requests from packaging.version import Version def get_header_for_version(version: str) -> str: return "## {} ({})".format(ver...
281
8,573
mlflow
dev/detect_flaky_tests.py
.py
"""Detect flaky tests from user-triggered CI re-runs. Ground-truth flake signal: a job that **failed on one run attempt and passed on the next attempt of the same commit** flaked by definition (same code, different outcome), and a human already judged it worth re-running by hitting "Re-run failed jobs". This script m...
260
10,892
mlflow
dev/create_release_tag.py
.py
""" How to test this script ----------------------- # Ensure origin points to your fork git remote -v | grep origin # Pretend we're releasing MLflow 9.0.0 git checkout -b branch-9.0 # First, test the dry run mode python dev/create_release_tag.py --new-version 9.0.0 --dry-run git tag -d v9.0.0 # Open https://github.c...
59
1,806