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/entities/model_registry/registered_model_search.py | .py | from mlflow.entities.model_registry import RegisteredModel
class RegisteredModelSearch(RegisteredModel):
def __init__(self, *args, **kwargs):
kwargs["tags"] = []
kwargs["aliases"] = []
super().__init__(*args, **kwargs)
def tags(self):
raise Exception(
"UC Registere... | 26 | 889 |
mlflow | mlflow/entities/model_registry/model_version_search.py | .py | from mlflow.entities.model_registry import ModelVersion
class ModelVersionSearch(ModelVersion):
def __init__(self, *args, **kwargs):
kwargs["tags"] = []
kwargs["aliases"] = []
super().__init__(*args, **kwargs)
def tags(self):
raise Exception(
"UC Model Versions gat... | 26 | 863 |
mlflow | mlflow/entities/model_registry/model_version_tag.py | .py | from mlflow.entities.model_registry._model_registry_entity import _ModelRegistryEntity
from mlflow.protos.model_registry_pb2 import ModelVersionTag as ProtoModelVersionTag
class ModelVersionTag(_ModelRegistryEntity):
"""Tag object associated with a model version."""
def __init__(self, key, value):
se... | 36 | 933 |
mlflow | mlflow/entities/model_registry/registered_model.py | .py | from mlflow.entities.model_registry._model_registry_entity import _ModelRegistryEntity
from mlflow.entities.model_registry.model_version import ModelVersion
from mlflow.entities.model_registry.prompt_version import IS_PROMPT_TAG_KEY
from mlflow.entities.model_registry.registered_model_alias import RegisteredModelAlias
... | 186 | 6,892 |
mlflow | mlflow/entities/model_registry/registered_model_tag.py | .py | from mlflow.entities.model_registry._model_registry_entity import _ModelRegistryEntity
from mlflow.protos.model_registry_pb2 import RegisteredModelTag as ProtoRegisteredModelTag
class RegisteredModelTag(_ModelRegistryEntity):
"""Tag object associated with a registered model."""
def __init__(self, key, value)... | 36 | 948 |
mlflow | mlflow/entities/model_registry/prompt.py | .py | """
Prompt entity for MLflow Model Registry.
This represents a prompt in the registry with its metadata, without version-specific
content like template text. For version-specific content, use PromptVersion.
"""
class Prompt:
"""
Entity representing a prompt in the MLflow Model Registry.
This contains pr... | 72 | 2,151 |
mlflow | mlflow/entities/model_registry/model_version_stages.py | .py | from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
STAGE_NONE = "None"
STAGE_STAGING = "Staging"
STAGE_PRODUCTION = "Production"
STAGE_ARCHIVED = "Archived"
STAGE_DELETED_INTERNAL = "Deleted_Internal"
ALL_STAGES = [STAGE_NONE, STAGE_STAGING, STAGE_PRODUCTIO... | 26 | 831 |
mlflow | mlflow/entities/model_registry/_model_registry_entity.py | .py | from abc import abstractmethod
from mlflow.entities._mlflow_object import _MlflowObject
class _ModelRegistryEntity(_MlflowObject):
@classmethod
@abstractmethod
def from_proto(cls, proto):
pass
def __eq__(self, other):
return dict(self) == dict(other)
| 14 | 287 |
mlflow | mlflow/pytorch/_lightning_autolog.py | .py | import functools
import logging
import os
import tempfile
import warnings
import torch
from packaging.version import Version
import mlflow.pytorch
from mlflow.exceptions import MlflowException
from mlflow.ml_package_versions import _ML_PACKAGE_VERSIONS
from mlflow.models import infer_signature
from mlflow.tracking.fl... | 710 | 29,845 |
mlflow | mlflow/pytorch/pickle_module.py | .py | """
This module imports contents from CloudPickle in a way that is compatible with the
``pickle_module`` parameter of PyTorch's model persistence function: ``torch.save``
(see https://github.com/pytorch/pytorch/blob/692898fe379c9092f5e380797c32305145cd06e1/torch/
serialization.py#L192). It is included as a distinct mod... | 36 | 1,994 |
mlflow | mlflow/pytorch/__init__.py | .py | """
The ``mlflow.pytorch`` module provides an API for logging and loading PyTorch models. This module
exports PyTorch models with the following flavors:
PyTorch (native) format
This is the main flavor that can be loaded back into PyTorch.
:py:mod:`mlflow.pyfunc`
Produced for use by generic pyfunc-based deploym... | 1,393 | 56,781 |
mlflow | mlflow/pytorch/_pytorch_autolog.py | .py | import time
import mlflow
from mlflow.entities import Metric, Param
from mlflow.tracking import MlflowClient
from mlflow.utils.autologging_utils.metrics_queue import (
add_to_metrics_queue,
flush_metrics_queue,
)
def patched_add_hparams(original, self, hparam_dict, metric_dict, *args, **kwargs):
"""use a... | 51 | 1,874 |
mlflow | mlflow/otel/__init__.py | .py | """
The ``mlflow.otel`` module provides generic OTEL-to-MLflow span forwarding.
When enabled, every span produced by any OpenTelemetry-instrumented library
(e.g. Langfuse, OpenInference / Arize Phoenix) is automatically forwarded
to the MLflow backend via the OTLP endpoint.
.. code-block:: python
import mlflow.o... | 184 | 6,695 |
mlflow | mlflow/server/asgi_utils.py | .py | from __future__ import annotations
import os
from starlette.requests import Request as StarletteRequest
def get_routed_asgi_path(request: StarletteRequest) -> str:
"""Return the routed ASGI path for a FastAPI request.
Prefer ``request.scope["path"]`` because Starlette reconstructs
``request.url.path`` ... | 33 | 1,208 |
mlflow | mlflow/server/otel_api.py | .py | """
OpenTelemetry REST API endpoints for MLflow FastAPI server.
This module implements the OpenTelemetry Protocol (OTLP) REST API for ingesting spans
according to the OTel specification:
https://opentelemetry.io/docs/specs/otlp/#otlphttp
Note: This is a minimal implementation that serves as a placeholder for the OTel... | 260 | 10,910 |
mlflow | mlflow/server/__init__.py | .py | import importlib
import logging
import os
import secrets
import shlex
import signal
import sys
import tempfile
import textwrap
import types
import warnings
from pathlib import Path
_logger = logging.getLogger("mlflow.server")
from flask import Flask, Response, send_from_directory
from packaging.version import Version... | 517 | 17,608 |
mlflow | mlflow/server/constants.py | .py | """
Constants used for internal server-to-worker communication.
These are internal environment variables (prefixed with _MLFLOW_SERVER_) used for
communication between the MLflow CLI and forked server processes (gunicorn/uvicorn workers).
They are set by the server and read by workers, and should not be set by end use... | 80 | 3,922 |
mlflow | mlflow/server/handlers.py | .py | # Define all the service endpoint handlers here.
import io
import json
import logging
import os
import pathlib
import posixpath
import re
import tempfile
import threading
import time
import unicodedata
import urllib
from collections.abc import Iterable
from functools import partial, wraps
from typing import Any, Callab... | 8,241 | 304,094 |
mlflow | mlflow/server/gateway_api.py | .py | """
Database-backed Gateway API endpoints for MLflow Server.
This module provides dynamic gateway endpoints that are configured from the database
rather than from a static YAML configuration file. It integrates the AI Gateway
functionality directly into the MLflow tracking server.
"""
import functools
import io
impor... | 1,588 | 63,389 |
mlflow | mlflow/server/security.py | .py | import logging
from http import HTTPStatus
from flask import Flask, Response, request
from flask_cors import CORS
from mlflow.environment_variables import (
MLFLOW_SERVER_DISABLE_SECURITY_MIDDLEWARE,
MLFLOW_SERVER_X_FRAME_OPTIONS,
)
from mlflow.server.security_utils import (
CORS_BLOCKED_MSG,
HEALTH_E... | 127 | 4,596 |
mlflow | mlflow/server/fastapi_app.py | .py | """
FastAPI application wrapper for MLflow server.
This module provides a FastAPI application that wraps the existing Flask application
using WSGIMiddleware to maintain 100% API compatibility while enabling future migration
to FastAPI endpoints.
"""
import inspect
import json
import os
import time
import typing
impo... | 261 | 11,028 |
mlflow | mlflow/server/fastapi_security.py | .py | import logging
from http import HTTPStatus
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from starlette.types import ASGIApp
from mlflow.environment_variables import (
MLFLOW_SERVER_DISABLE_SECURITY_MIDDLEWARE,
MLFLOW_SERVER_X_FRAME_OPTIONS,
)
from mlflow.server.security_utils... | 202 | 7,301 |
mlflow | mlflow/server/artifact_router.py | .py | """
Native FastAPI artifact upload and download endpoints.
When MLflow runs under uvicorn/FastAPI (the default), these endpoints handle
artifact upload and download requests directly via ASGI, bypassing the WSGI
bridge and avoiding full-body buffering. This enables true streaming for large
artifact transfers.
When ML... | 182 | 6,448 |
mlflow | mlflow/server/workspace_helpers.py | .py | from __future__ import annotations
import logging
import os
from flask import Response, request
from mlflow.entities import Workspace
from mlflow.environment_variables import (
MLFLOW_ENABLE_WORKSPACES,
MLFLOW_WORKSPACE_STORE_URI,
)
from mlflow.exceptions import MlflowException
from mlflow.protos import data... | 156 | 5,455 |
mlflow | mlflow/server/security_utils.py | .py | """
Shared security utilities for MLflow server middleware.
This module contains common functions used by both Flask and FastAPI
security implementations.
"""
import fnmatch
from urllib.parse import urlparse
from mlflow.environment_variables import (
MLFLOW_SERVER_ALLOWED_HOSTS,
MLFLOW_SERVER_CORS_ALLOWED_OR... | 171 | 5,294 |
mlflow | mlflow/server/prometheus_exporter.py | .py | from flask import request
from prometheus_flask_exporter.multiprocess import GunicornInternalPrometheusMetrics
from mlflow.version import VERSION
def activate_prometheus_exporter(app):
def mlflow_version(_: request):
return VERSION
return GunicornInternalPrometheusMetrics(
app,
expor... | 18 | 458 |
mlflow | mlflow/server/job_api.py | .py | """
Internal job APIs for UI invocation
"""
import json
from typing import Any
from fastapi import APIRouter, HTTPException
from pydantic import BaseModel
from mlflow.entities._job import Job as JobEntity
from mlflow.entities._job_status import JobStatus
from mlflow.exceptions import MlflowException
job_api_router ... | 136 | 3,657 |
mlflow | mlflow/server/validation.py | .py | from mlflow.exceptions import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
def _validate_content_type(flask_request, allowed_content_types: list[str]):
"""
Validates that the request content type is one of the allowed content types.
Args:
flask_request: Flask r... | 31 | 1,095 |
mlflow | mlflow/server/mcp_server_api.py | .py | from __future__ import annotations
import json
from typing import TYPE_CHECKING, Any, Literal
from fastapi import APIRouter, Query, Request
from fastapi.exceptions import RequestValidationError
from fastapi.responses import JSONResponse
from pydantic import (
BaseModel,
ConfigDict,
Field,
field_valida... | 914 | 31,934 |
mlflow | mlflow/server/graphql/graphql_custom_scalars.py | .py | import graphene
from graphql.language.ast import IntValueNode
class LongString(graphene.Scalar):
"""
LongString Scalar type to prevent truncation to max integer in JavaScript.
"""
description = "Long converted to string to prevent truncation to max integer in JavaScript"
@staticmethod
def se... | 25 | 579 |
mlflow | mlflow/server/graphql/autogenerated_graphql_schema.py | .py | # GENERATED FILE. PLEASE DON'T MODIFY.
# Run uv run ./dev/proto_to_graphql/code_generator.py to regenerate.
import graphene
import mlflow
from mlflow.server.graphql.graphql_custom_scalars import LongString
from mlflow.server.graphql.graphql_errors import ApiError
from mlflow.utils.proto_json_utils import parse_dict
c... | 356 | 11,751 |
mlflow | mlflow/server/graphql/graphql_errors.py | .py | import graphene
class ErrorDetail(graphene.ObjectType):
# NOTE: This is not an exhaustive list, might need to add more things in the future if needed.
field = graphene.String()
message = graphene.String()
class ApiError(graphene.ObjectType):
code = graphene.String()
message = graphene.String()
... | 16 | 432 |
mlflow | mlflow/server/graphql/graphql_no_batching.py | .py | from typing import NamedTuple
from graphql.error import GraphQLError
from graphql.execution import ExecutionResult
from graphql.language.ast import DocumentNode, FieldNode
from mlflow.environment_variables import (
MLFLOW_SERVER_GRAPHQL_MAX_ALIASES,
MLFLOW_SERVER_GRAPHQL_MAX_ROOT_FIELDS,
)
_MAX_DEPTH = 10
_M... | 90 | 2,959 |
mlflow | mlflow/server/auth/sqlalchemy_store.py | .py | import logging
import re
from collections.abc import Iterable
from urllib.parse import quote, unquote
from sqlalchemy import and_, or_, select, text
from sqlalchemy.exc import IntegrityError, MultipleResultsFound, NoResultFound
from sqlalchemy.orm import selectinload, sessionmaker
from werkzeug.security import check_p... | 2,240 | 96,889 |
mlflow | mlflow/server/auth/__main__.py | .py | from mlflow.server.auth.cli import commands
if __name__ == "__main__":
commands()
| 5 | 87 |
mlflow | mlflow/server/auth/__init__.py | .py | """
Usage
-----
.. code-block:: bash
mlflow server --app-name basic-auth
"""
from __future__ import annotations
import asyncio
import base64
import functools
import hmac
import importlib
import json
import logging
import os
import re
import secrets
import threading
from dataclasses import asdict, dataclass
from... | 5,774 | 220,958 |
mlflow | mlflow/server/auth/entities.py | .py | from mlflow.exceptions import MlflowException
from mlflow.server.auth.permissions import get_permission
from mlflow.utils.workspace_utils import DEFAULT_WORKSPACE_NAME, resolve_entity_workspace_name
class User:
def __init__(
self,
id_,
username,
password_hash,
is_admin,
... | 574 | 13,943 |
mlflow | mlflow/server/auth/client.py | .py | from mlflow.server.auth.entities import (
GetUserPermissionResult,
Role,
RolePermission,
User,
UserRoleAssignment,
)
from mlflow.server.auth.routes import (
ADD_ROLE_PERMISSION,
ASSIGN_ROLE,
CREATE_ROLE,
CREATE_USER,
DELETE_ROLE,
DELETE_USER,
GET_ROLE,
GET_USER,
G... | 395 | 12,956 |
mlflow | mlflow/server/auth/routes.py | .py | from mlflow.server.handlers import _add_static_prefix, _get_ajax_path, _get_rest_path
HOME = "/"
SIGNUP = "/signup"
CREATE_USER = _get_rest_path("/mlflow/users/create")
AJAX_CREATE_USER = _get_ajax_path("/mlflow/users/create")
CREATE_USER_UI = _get_rest_path("/mlflow/users/create-ui")
GET_USER = _get_rest_path("/mlflo... | 91 | 6,067 |
mlflow | mlflow/server/auth/permissions.py | .py | from dataclasses import dataclass
from mlflow import MlflowException
from mlflow.protos.databricks_pb2 import INVALID_PARAMETER_VALUE
@dataclass
class Permission:
name: str
can_read: bool
can_use: bool
can_update: bool
can_delete: bool
can_manage: bool
READ = Permission(
name="READ",
... | 186 | 6,063 |
mlflow | mlflow/server/auth/cli.py | .py | import click
from mlflow.server.auth.db import cli as db_cli
@click.group()
def commands():
pass
commands.add_command(db_cli.commands)
| 12 | 144 |
mlflow | mlflow/server/auth/config.py | .py | import configparser
from pathlib import Path
from typing import NamedTuple
from mlflow.environment_variables import MLFLOW_AUTH_CONFIG_PATH
DEFAULT_AUTHORIZATION_FUNCTION = "mlflow.server.auth:authenticate_request_basic_auth"
class AuthConfig(NamedTuple):
default_permission: str
database_uri: str
admin_... | 57 | 2,136 |
mlflow | mlflow/server/auth/logo.py | .py | # ruff: noqa: E501
MLFLOW_LOGO = """
<svg width="109" height="40" viewBox="0 0 109 40" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M0 31.0316V15.5024H3.54258V17.4699C4.43636 15.8756 6.38278 15.045 8.13589 15.045C10.178 15.045 11.9636 15.9713 12.7943 17.7895C14.0096 15.7474 15.8278 15.045 17.8373 15.045C20.... | 15 | 2,660 |
mlflow | mlflow/server/auth/db/utils.py | .py | from pathlib import Path
from alembic.command import stamp, upgrade
from alembic.config import Config
from alembic.migration import MigrationContext
from alembic.script import ScriptDirectory
from sqlalchemy import inspect
from sqlalchemy.engine.base import Engine
INITIAL_REVISION = "8606fa83a998"
def _get_alembic_... | 79 | 2,942 |
mlflow | mlflow/server/auth/db/models.py | .py | from sqlalchemy import (
Boolean,
Column,
ForeignKey,
Index,
Integer,
String,
UniqueConstraint,
)
from sqlalchemy.orm import declarative_base, relationship
from mlflow.server.auth.entities import (
Role,
RolePermission,
User,
UserRoleAssignment,
)
Base = declarative_base()
... | 120 | 3,845 |
mlflow | mlflow/server/auth/db/cli.py | .py | import click
import sqlalchemy
from mlflow.server.auth.db import utils
@click.group(name="db")
def commands():
pass
@commands.command()
@click.option("--url", required=True)
@click.option("--revision", default="head")
def upgrade(url: str, revision: str) -> None:
engine = sqlalchemy.create_engine(url)
... | 19 | 373 |
mlflow | mlflow/server/assistant/session.py | .py | import json
import os
import signal
import tempfile
import uuid
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any, Literal
from mlflow.assistant.types import Message
SESSION_DIR = Path(tempfile.gettempdir()) / "mlflow-assistant-sessions"
@dataclass
class Session:
"""Sessio... | 250 | 8,294 |
mlflow | mlflow/server/assistant/api.py | .py | import asyncio
import enum
import ipaddress
import uuid
from collections.abc import Awaitable, Callable
from pathlib import Path
from typing import Any, AsyncGenerator, Literal
from fastapi import APIRouter, Header, HTTPException, Request
from fastapi.responses import StreamingResponse
from fastapi.routing import APIR... | 828 | 30,925 |
mlflow | mlflow/server/jobs/progress.py | .py | """Job tracking for MLflow jobs."""
from typing import Any
_job_tracker: "JobTracker | NoOpTracker | None" = None
class JobTracker:
"""Tracks job execution by writing directly to database (internal use)."""
def __init__(self, job_id: str):
self.job_id = job_id
def update(self, status_details: ... | 46 | 1,227 |
mlflow | mlflow/server/jobs/utils.py | .py | import errno
import hashlib
import importlib
import inspect
import json
import logging
import os
import shutil
import signal
import subprocess
import sys
import tempfile
import threading
import time
from contextlib import nullcontext
from dataclasses import asdict, dataclass
from datetime import datetime
from pathlib i... | 812 | 29,422 |
mlflow | mlflow/server/jobs/_job_subproc_entry.py | .py | """
This module is used for launching subprocess to execute the job function.
If the job has timeout setting, or the job has pip requirements dependencies,
or the job has extra environment variables setting,
the job is executed as a subprocess.
"""
import importlib
import json
import logging
import os
import threadin... | 105 | 3,510 |
mlflow | mlflow/server/jobs/_job_runner.py | .py | """
This module is used for launching the job runner process.
The job runner will:
* enqueue all unfinished huey tasks when MLflow server is down last time.
* Watch the `_MLFLOW_HUEY_STORAGE_PATH` path,
if new files (named like `XXX.mlflow-huey-store`) are created,
it means a new Huey queue is created, then the jo... | 44 | 1,578 |
mlflow | mlflow/server/jobs/__init__.py | .py | import json
import logging
import os
from dataclasses import dataclass
from types import FunctionType
from typing import Any, Callable, ParamSpec, TypeVar
from mlflow.entities._job import Job as JobEntity
from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES
from mlflow.exceptions import MlflowException
fr... | 275 | 9,494 |
mlflow | mlflow/server/jobs/_huey_consumer.py | .py | """
This module is used for launching Huey consumer
the command is like:
```
export _MLFLOW_HUEY_STORAGE_PATH={huey_store_dir}
export _MLFLOW_HUEY_INSTANCE_KEY={huey_instance_key}
huey_consumer.py mlflow.server.jobs.huey_consumer.huey_instance -w {max_workers}
```
It launches the Huey consumer that polls tasks from ... | 39 | 1,142 |
mlflow | mlflow/server/jobs/_periodic_tasks_consumer.py | .py | """
This module is used for launching the periodic tasks Huey consumer.
This is a dedicated consumer that only runs periodic tasks (like the online scoring scheduler).
It is launched by the job runner and runs in a separate process from job execution consumers.
"""
import threading
from mlflow.server.jobs.logging_ut... | 33 | 1,056 |
mlflow | mlflow/server/jobs/logging_utils.py | .py | """Shared logging utilities for MLflow job consumers."""
import logging
from mlflow.utils.logging_utils import get_mlflow_log_level
def configure_logging_for_jobs() -> None:
"""Configure Python logging for job consumers to reduce noise for log levels above DEBUG."""
# Suppress noisy alembic and huey INFO lo... | 14 | 560 |
mlflow | mlflow/paddle/__init__.py | .py | """
The ``mlflow.paddle`` module provides an API for logging and loading paddle models.
This module exports paddle models with the following flavors:
Paddle (native) format
This is the main flavor that can be loaded back into paddle.
:py:mod:`mlflow.pyfunc`
Produced for use by generic pyfunc-based deployment ... | 618 | 21,898 |
mlflow | mlflow/paddle/_paddle_autolog.py | .py | import paddle
import mlflow
from mlflow.tracking.fluent import _initialize_logged_model
from mlflow.utils.autologging_utils import (
BatchMetricsLogger,
ExceptionSafeAbstractClass,
MlflowAutologgingQueueingClient,
get_autologging_config,
)
class __MlflowPaddleCallback(paddle.callbacks.Callback, metac... | 142 | 5,123 |
mlflow | mlflow/ag2/__init__.py | .py | from mlflow.telemetry.events import AutologgingEvent
from mlflow.telemetry.track import _record_event
from mlflow.utils.autologging_utils import autologging_integration
FLAVOR_NAME = "ag2"
def autolog(
log_traces: bool = True,
disable: bool = False,
silent: bool = False,
):
"""
Enables (or disabl... | 60 | 2,367 |
mlflow | mlflow/ag2/ag2_logger.py | .py | import functools
import logging
import time
import uuid
from dataclasses import dataclass, field
from datetime import datetime, timezone
from typing import Any
from autogen import Agent, ConversableAgent
from autogen.logger.base_logger import BaseLogger
from openai.types.chat import ChatCompletion
from mlflow.entitie... | 327 | 12,975 |
mlflow | mlflow/langchain/retriever_chain.py | .py | """Chain for wrapping a retriever."""
from __future__ import annotations
import json
from pathlib import Path
from typing import Any
import yaml
from pydantic import ConfigDict, Field
from mlflow.langchain._compat import (
import_async_callback_manager_for_chain_run,
import_base_retriever,
import_callba... | 167 | 5,649 |
mlflow | mlflow/langchain/databricks_dependencies.py | .py | import importlib
import inspect
import logging
import warnings
from typing import Any, Generator
from mlflow.models.resources import (
DatabricksFunction,
DatabricksServingEndpoint,
DatabricksSQLWarehouse,
DatabricksVectorSearchIndex,
Resource,
)
_logger = logging.getLogger(__name__)
def _get_em... | 439 | 17,896 |
mlflow | mlflow/langchain/api_request_parallel_processor.py | .py | # Based ons: https://github.com/openai/openai-cookbook/blob/6df6ceff470eeba26a56de131254e775292eac22/examples/api_request_parallel_processor.py
# Several changes were made to make it work with MLflow.
# Currently, only chat completion is supported.
"""
API REQUEST PARALLEL PROCESSOR
Using the LangChain API to process... | 334 | 13,118 |
mlflow | mlflow/langchain/runnables.py | .py | from __future__ import annotations
import os
import re
import warnings
from pathlib import Path
from typing import TYPE_CHECKING
import cloudpickle
import yaml
from mlflow.exceptions import MlflowException
from mlflow.langchain.utils.logging import (
_BASE_LOAD_KEY,
_CONFIG_LOAD_KEY,
_MODEL_DATA_FOLDER_N... | 544 | 20,194 |
mlflow | mlflow/langchain/_compat.py | .py | def import_base_retriever():
try:
from langchain.schema import BaseRetriever
return BaseRetriever
except ImportError:
from langchain_core.retrievers import BaseRetriever
return BaseRetriever
def import_document():
try:
from langchain.schema import Document
... | 223 | 5,073 |
mlflow | mlflow/langchain/langchain_tracer.py | .py | import ast
import logging
from contextvars import ContextVar
from typing import Any, Optional, Sequence
from uuid import UUID
import pydantic
from langchain_core.agents import AgentAction, AgentFinish
from langchain_core.callbacks.base import BaseCallbackHandler
from langchain_core.documents import Document
from langc... | 806 | 32,224 |
mlflow | mlflow/langchain/chat_agent_langgraph.py | .py | from __future__ import annotations
import json
from typing import Annotated, Any, TypedDict
from uuid import uuid4
from packaging.version import Version
from mlflow.utils import get_installed_version
try:
from langchain_core.messages import AnyMessage, BaseMessage, convert_to_messages
from langchain_core.ru... | 369 | 14,445 |
mlflow | mlflow/langchain/model.py | .py | """
The ``mlflow.langchain`` module provides an API for logging and loading LangChain models.
This module exports multivariate LangChain models in the langchain flavor and univariate
LangChain models in the pyfunc flavor:
LangChain (native) format
This is the main flavor that can be accessed with LangChain APIs.
:... | 949 | 40,562 |
mlflow | mlflow/langchain/__init__.py | .py | from mlflow.langchain.autolog import autolog
from mlflow.langchain.constants 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 installed.
... | 25 | 655 |
mlflow | mlflow/langchain/autolog.py | .py | import logging
from mlflow.langchain.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
from mlflow.utils.autologging_utils.config import AutoLoggingConfig
from mlflow.utils... | 163 | 6,507 |
mlflow | mlflow/langchain/output_parsers.py | .py | from dataclasses import asdict
from typing import Any, AsyncIterator, Iterator
from uuid import uuid4
from langchain_core.messages.base import BaseMessage
from langchain_core.output_parsers.transform import BaseTransformOutputParser
from mlflow.models.rag_signatures import (
ChainCompletionChoice,
Message,
... | 153 | 5,270 |
mlflow | mlflow/langchain/utils/logging.py | .py | """Utility functions for mlflow.langchain."""
import functools
import importlib
import json
import logging
import os
import shutil
import types
from functools import lru_cache
from importlib.util import find_spec
from typing import Any, Callable, NamedTuple
import cloudpickle
import yaml
from packaging.version import... | 635 | 21,745 |
mlflow | mlflow/langchain/utils/chat.py | .py | import json
import logging
import time
from collections import defaultdict
from collections.abc import Iterator
from typing import Any
import pydantic
from langchain_core.messages import (
AIMessage,
BaseMessage,
FunctionMessage,
HumanMessage,
SystemMessage,
ToolMessage,
)
from langchain_core.m... | 510 | 18,554 |
mlflow | mlflow/langchain/utils/serialization.py | .py | import inspect
from pydantic import BaseModel
def convert_to_serializable(response):
"""
Convert the response to a JSON serializable format.
LangChain response objects often contains Pydantic objects, which causes an serialization
error when the model is served behind REST endpoint.
"""
# La... | 27 | 879 |
mlflow | mlflow/store/workspace_rest_store_mixin.py | .py | from __future__ import annotations
from mlflow.exceptions import MlflowException
from mlflow.protos import databricks_pb2
from mlflow.utils.server_info import (
SERVER_INFO_ENDPOINT,
SERVER_INFO_WORKSPACES_ENABLED,
ServerInfoRequestError,
fetch_server_info,
)
from mlflow.utils.uri import is_databricks_... | 82 | 2,880 |
mlflow | mlflow/store/__init__.py | .py | from mlflow.store import _unity_catalog # noqa: F401
from mlflow.store.artifact import artifact_repo
from mlflow.store.tracking import abstract_store
__all__ = [
# tracking server meta-data stores
"abstract_store",
# artifact repository stores
"artifact_repo",
]
| 11 | 281 |
mlflow | mlflow/store/workspace_aware_mixin.py | .py | """
Mixin class providing common workspace functionality for stores.
"""
from __future__ import annotations
from mlflow.environment_variables import MLFLOW_ENABLE_WORKSPACES
from mlflow.exceptions import MlflowException
from mlflow.utils.workspace_context import get_request_workspace
from mlflow.utils.workspace_utils... | 64 | 2,174 |
mlflow | mlflow/store/_unity_catalog/registry/uc_native_rest_store.py | .py | """Unity Catalog model-registry store that talks to the native /api/2.1/unity-catalog/* surface.
``UcNativeModelRegistryStore`` subclasses :class:`UcModelRegistryStore` and overrides the
model-registry operations that have a native Unity Catalog equivalent so they issue requests
against the native ``UnityCatalogServic... | 668 | 28,709 |
mlflow | mlflow/store/_unity_catalog/registry/uc_oss_rest_store.py | .py | import functools
import os
import shutil
from contextlib import contextmanager
import mlflow
from mlflow.exceptions import MlflowException
from mlflow.protos.unity_catalog_messages_pb2 import (
READ_WRITE_MODEL_VERSION,
CreateModelVersion,
CreateRegisteredModel,
DeleteModelVersion,
DeleteRegistered... | 505 | 20,110 |
mlflow | mlflow/store/_unity_catalog/registry/prompt_info.py | .py | """
Internal PromptInfo entity for Unity Catalog prompt operations.
This is an implementation detail for the Unity Catalog store and should not be
considered part of the public MLflow API.
"""
class PromptInfo:
"""
Internal entity for prompt information from Unity Catalog. This represents
prompt metadata... | 74 | 2,198 |
mlflow | mlflow/store/_unity_catalog/registry/utils.py | .py | """
Utility functions for converting between Unity Catalog proto and MLflow entities.
"""
import json
from mlflow.entities.model_registry.prompt import Prompt
from mlflow.entities.model_registry.prompt_version import PromptVersion
from mlflow.prompt.constants import PROMPT_MODEL_CONFIG_TAG_KEY, RESPONSE_FORMAT_TAG_KE... | 159 | 5,557 |
mlflow | mlflow/store/_unity_catalog/registry/rest_store.py | .py | import base64
import functools
import json
import logging
import os
import re
import shutil
from contextlib import contextmanager
from dataclasses import dataclass
from typing import Any
import google.protobuf.empty_pb2
from pydantic import BaseModel
import mlflow
from mlflow.entities import Run
from mlflow.entities.... | 1,903 | 78,511 |
mlflow | mlflow/store/_unity_catalog/registry/__init__.py | .py | from mlflow.store._unity_catalog.registry import (
rest_store as rest_store,
)
from mlflow.store._unity_catalog.registry import (
uc_oss_rest_store as uc_oss_rest_store,
)
| 7 | 180 |
mlflow | mlflow/store/_unity_catalog/lineage/constants.py | .py | _DATABRICKS_ORG_ID_HEADER = "x-databricks-org-id"
_DATABRICKS_LINEAGE_ID_HEADER = "X-Databricks-Lineage-Identifier"
| 3 | 116 |
mlflow | mlflow/store/workspace/utils.py | .py | from __future__ import annotations
import logging
from mlflow.entities import Workspace
from mlflow.protos import databricks_pb2
_INVALID_PARAMETER_VALUE_CODE = databricks_pb2.INVALID_PARAMETER_VALUE
_INVALID_PARAMETER_VALUE_NAME = databricks_pb2.ErrorCode.Name(_INVALID_PARAMETER_VALUE_CODE)
_logger = logging.getL... | 44 | 1,340 |
mlflow | mlflow/store/workspace/sqlalchemy_store.py | .py | from __future__ import annotations
import logging
from threading import Lock
from typing import Iterable
from cachetools import TTLCache
from sqlalchemy.exc import IntegrityError
from sqlalchemy.orm import sessionmaker
from mlflow.entities.workspace import TraceArchivalConfig, Workspace, WorkspaceDeletionMode
from m... | 373 | 16,288 |
mlflow | mlflow/store/workspace/rest_store.py | .py | from __future__ import annotations
from urllib.parse import quote
from mlflow.entities import Workspace
from mlflow.entities.workspace import WorkspaceDeletionMode
from mlflow.exceptions import MlflowException, RestException
from mlflow.protos import databricks_pb2
from mlflow.protos.databricks_pb2 import INVALID_STA... | 135 | 5,618 |
mlflow | mlflow/store/workspace/__init__.py | .py | """Public workspace store facade and re-exports."""
from mlflow.entities.workspace import Workspace
from mlflow.store.workspace.abstract_store import AbstractStore
from mlflow.store.workspace.rest_store import RestWorkspaceStore
__all__ = [
"Workspace",
"AbstractStore",
"RestWorkspaceStore",
]
| 12 | 309 |
mlflow | mlflow/store/workspace/abstract_store.py | .py | from __future__ import annotations
import re
from abc import ABC, abstractmethod
from dataclasses import dataclass
from typing import Iterable
from mlflow.entities import Workspace
from mlflow.entities.workspace import TraceArchivalConfig, WorkspaceDeletionMode
from mlflow.exceptions import MlflowException
@datacla... | 181 | 6,732 |
mlflow | mlflow/store/workspace/dbmodels/models.py | .py | from __future__ import annotations
import sqlalchemy as sa
from sqlalchemy import Column, String, Text
from mlflow.entities.workspace import Workspace
from mlflow.store.db.base_sql_model import Base
class SqlWorkspace(Base):
__tablename__ = "workspaces"
# Workspace-aware tables intentionally do not declare... | 37 | 1,402 |
mlflow | mlflow/store/workspace/dbmodels/__init__.py | .py | from mlflow.store.workspace.dbmodels.models import SqlWorkspace
__all__ = ["SqlWorkspace"]
| 4 | 92 |
mlflow | mlflow/store/entities/paged_list.py | .py | from typing import TypeVar
T = TypeVar("T")
class PagedList(list[T]):
"""
Wrapper class around the base Python `List` type. Contains an additional `token` string
attribute that can be passed to the pagination API that returned this list to fetch additional
elements, if any are available
"""
... | 19 | 473 |
mlflow | mlflow/store/entities/__init__.py | .py | from mlflow.store.entities.paged_list import PagedList
__all__ = ["PagedList"]
| 4 | 80 |
mlflow | mlflow/store/fs2db/_utils.py | .py | import logging
from collections.abc import Iterator
from dataclasses import dataclass, fields
from pathlib import Path
from typing import Any
import yaml
from mlflow.store.tracking.file_store import FileStore
_logger = logging.getLogger(__name__)
@dataclass
class MigrationStats:
experiments: int = 0
experi... | 136 | 4,051 |
mlflow | mlflow/store/fs2db/_tracking.py | .py | """
Migrate tracking store entities from FileStore to DB.
FileStore layout:
<mlruns>/
βββ <experiment_id>/
β βββ meta.yaml -> experiments
β βββ tags/<key> -> experiment_tags
β βββ <run_uuid>/
β β βββ meta.yaml -> runs
β β ββ... | 712 | 24,290 |
mlflow | mlflow/store/fs2db/__init__.py | .py | # ruff: noqa: T201
import warnings
from functools import partial
from pathlib import Path
from mlflow.exceptions import MlflowException
def _log(progress: bool, msg: str) -> None:
if progress:
print(msg)
def _resolve_mlruns(source: Path) -> Path:
mlruns = source / "mlruns"
if mlruns.is_dir():
... | 166 | 6,220 |
mlflow | mlflow/store/fs2db/cli.py | .py | from pathlib import Path
import click
from mlflow.store.fs2db import migrate
from mlflow.utils.uri import get_uri_scheme
@click.command("migrate-filestore")
@click.option(
"--source",
required=True,
type=click.Path(exists=True, file_okay=False, resolve_path=True),
help="Root directory containing mlr... | 46 | 1,383 |
mlflow | mlflow/store/fs2db/_registry.py | .py | """
Migrate model registry entities from FileStore to DB.
FileStore layout:
<mlruns>/models/
βββ <model_name>/
βββ meta.yaml -> registered_models
βββ tags/<key> -> registered_model_tags
βββ aliases/<alias_name> -> registered_model_aliases
βββ version-... | 135 | 4,228 |
mlflow | mlflow/store/tracking/databricks_rest_store.py | .py | import base64
import logging
import time
from collections import defaultdict
from datetime import datetime
from typing import Any
from urllib.parse import quote, urlencode
from opentelemetry.proto.collector.trace.v1.trace_service_pb2 import ExportTraceServiceRequest
from pydantic import BaseModel
from mlflow.entities... | 1,230 | 48,287 |
mlflow | mlflow/store/tracking/sqlalchemy_store.py | .py | from __future__ import annotations
import base64
import hashlib
import json
import logging
import math
import random
import threading
import time
import uuid
from collections import defaultdict
from dataclasses import dataclass, field
from functools import lru_cache, reduce
from pathlib import PurePath
from typing imp... | 10,289 | 440,265 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.