repo
stringclasses
454 values
file_path
stringlengths
5
201
extension
stringclasses
1 value
content
stringlengths
8
509k
num_lines
int64
3
16.9k
size_bytes
int64
8
511k
mlflow
tests/langgraph/test_chat_agent_langgraph.py
.py
import json import pytest from langchain_core.messages import AIMessage, ToolMessage import mlflow from mlflow.langchain.chat_agent_langgraph import parse_message from mlflow.types.agent import ChatAgentMessage LC_TOOL_CALL_MSG = AIMessage(**{ "content": "", "additional_kwargs": { "tool_calls": [ ...
283
10,125
mlflow
tests/langgraph/conftest.py
.py
import importlib import openai import pytest from tests.helper_functions import start_mock_openai_server from tests.tracing.helper import reset_autolog_state # noqa: F401 @pytest.fixture(autouse=True) def set_envs(monkeypatch, mock_openai): monkeypatch.setenv("OPENAI_API_KEY", "test") monkeypatch.setenv("O...
28
722
mlflow
tests/langgraph/sample_code/langgraph_chat_agent_custom_inputs.py
.py
import json import os from typing import Any, Generator, Sequence from uuid import uuid4 from langchain_core.language_models import LanguageModelLike from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.runnables import RunnableConfig...
194
6,299
mlflow
tests/langgraph/sample_code/langgraph_with_custom_span.py
.py
from typing import Literal from langchain_core.messages import AIMessage, ToolCall from langchain_core.output_parsers import StrOutputParser from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.prompts import PromptTemplate from langchain_core.tools import tool from langchain_openai import...
60
1,817
mlflow
tests/langgraph/sample_code/langgraph_chat_agent.py
.py
import json import os from typing import Any, Generator, Sequence from langchain_core.language_models import LanguageModelLike from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.runnables import RunnableConfig, RunnableLambda from l...
152
4,670
mlflow
tests/langgraph/sample_code/langgraph_with_autolog.py
.py
from dataclasses import dataclass from langchain.tools import tool from langgraph.graph import END, StateGraph import mlflow mlflow.langchain.autolog() @dataclass class OverallState: name: str = "LangChain" # add whatever fields you need @tool def my_tool(): """ Called as the very first node. Si...
34
778
mlflow
tests/langgraph/sample_code/langgraph_diy.py
.py
# Sample code that contains custom python nodes from typing import Annotated, Sequence, TypedDict from langchain_core.messages import BaseMessage from langchain_openai import ChatOpenAI from langgraph.graph import END, START, StateGraph from langgraph.graph.message import add_messages import mlflow def generate(sta...
47
1,104
mlflow
tests/langgraph/sample_code/langgraph_prebuilt.py
.py
import itertools from typing import Literal from langchain_core.messages import AIMessage, ToolCall from langchain_core.outputs import ChatGeneration, ChatResult from langchain_core.tools import tool from langchain_openai import ChatOpenAI from langgraph.prebuilt import create_react_agent import mlflow class FakeOp...
50
1,556
mlflow
tests/transformers/test_transformers_autolog.py
.py
import random import numpy as np import optuna import pytest import sklearn.cluster import sklearn.datasets import torch import transformers from datasets import load_dataset from packaging.version import Version from transformers import ( DistilBertForSequenceClassification, DistilBertTokenizerFast, Train...
578
18,175
mlflow
tests/transformers/test_transformers_signature.py
.py
import json import time from unittest import mock import pytest from mlflow.models.signature import ModelSignature from mlflow.transformers import _try_import_conversational_pipeline from mlflow.transformers.signature import ( _TEXT2TEXT_SIGNATURE, format_input_example_for_special_cases, infer_or_get_defa...
199
7,509
mlflow
tests/transformers/test_transformers_llm_inference_utils.py
.py
import uuid from typing import Any, NamedTuple from unittest import mock import pandas as pd import pytest import torch from mlflow.exceptions import MlflowException from mlflow.models import infer_signature from mlflow.transformers.llm_inference_utils import ( _get_default_task_for_llm_inference_task, _get_f...
314
10,571
mlflow
tests/transformers/version.py
.py
import transformers from packaging.version import Version transformers_version = Version(transformers.__version__) IS_NEW_FEATURE_EXTRACTION_API = transformers_version >= Version("4.27.0") IS_TRANSFORMERS_V5_OR_LATER = transformers_version.major >= 5
7
252
mlflow
tests/transformers/test_transformers_model_export.py
.py
import base64 import gc import importlib.util import json import logging import math import os import pathlib import re import shutil import textwrap from contextlib import contextmanager from pathlib import Path from unittest import mock import huggingface_hub import librosa import numpy as np import pandas as pd imp...
3,980
150,812
mlflow
tests/transformers/test_transformers_peft_model.py
.py
import importlib import os import re import pytest import transformers import mlflow from mlflow.exceptions import MlflowException from mlflow.models import Model from mlflow.transformers.flavor_config import FlavorKey from mlflow.transformers.peft import get_peft_base_model, is_peft_model from mlflow.utils.logging_u...
272
9,252
mlflow
tests/transformers/helper.py
.py
import inspect import logging import sys import transformers from packaging.version import Version from mlflow.transformers import _PEFT_PIPELINE_ERROR_MSG, _try_import_conversational_pipeline from mlflow.utils.logging_utils import suppress_logs from tests.helper_functions import flaky from tests.transformers.versio...
341
11,836
mlflow
tests/transformers/test_transformers_prompt_templating.py
.py
from unittest.mock import MagicMock import pytest import transformers import yaml from packaging.version import Version import mlflow from mlflow.exceptions import MlflowException from mlflow.models.model import MLMODEL_FILE_NAME from mlflow.transformers import _SUPPORTED_PROMPT_TEMPLATING_TASK_TYPES, _validate_promp...
241
8,463
mlflow
tests/transformers/test_flavor_configs.py
.py
from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.transformers import _build_pipeline_from_model_input from mlflow.transformers.flavor_config import ( build_flavor_config, update_flavor_conf_to_persist_pretrained_model, ) from mlflow.transformers.torch_utils imp...
187
7,225
mlflow
tests/transformers/conftest.py
.py
import pytest from packaging.version import Version from tests.transformers.helper import ( IS_TRANSFORMERS_V5_OR_LATER, load_audio_classification_pipeline, load_component_multi_modal, load_conversational_pipeline, load_custom_code_pipeline, load_custom_components_pipeline, load_feature_ext...
183
4,842
mlflow
tests/prophet/test_prophet_model_export.py
.py
import json import os from datetime import date, datetime, timedelta from pathlib import Path from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import prophet import pytest import yaml from packaging.version import Version from prophet import Prophet import mlflow imp...
509
18,892
mlflow
tests/agno/test_agno_tracing.py
.py
import sys from unittest.mock import MagicMock, patch import agno import pytest from agno.agent import Agent from agno.exceptions import ModelProviderError from agno.models.anthropic import Claude from agno.tools.function import Function, FunctionCall from anthropic.types import Message, TextBlock, Usage from opentele...
422
15,467
mlflow
tests/agno/conftest.py
.py
import pytest import mlflow @pytest.fixture(autouse=True) def _reset_mlflow(): from mlflow.utils.autologging_utils import AUTOLOGGING_INTEGRATIONS for integ in AUTOLOGGING_INTEGRATIONS.values(): integ.clear() mlflow.utils.import_hooks._post_import_hooks = {} @pytest.fixture(autouse=True) def m...
18
396
mlflow
tests/onnx/test_onnx_model_export.py
.py
import logging import os from pathlib import Path from unittest import mock import numpy as np import onnx import onnxruntime as ort import pandas as pd import pytest import torch import torch.onnx import yaml from packaging.version import Version from sklearn import datasets from torch import nn from torch.utils.data...
946
36,592
mlflow
tests/models/test_container.py
.py
import os from unittest import mock import pytest import yaml from mlflow.models.container import _install_model_dependencies_to_env from mlflow.utils import env_manager as em def _create_model_artifact(model_path, dependencies, build_dependencies=None): """Helper to create a minimal model artifact for testing....
228
7,408
mlflow
tests/models/test_python_api.py
.py
import datetime import json import os import sys from unittest import mock import numpy as np import pandas as pd import pytest import scipy.sparse import mlflow from mlflow.exceptions import MlflowException from mlflow.models.python_api import ( _CONTENT_TYPE_CSV, _CONTENT_TYPE_JSON, _serialize_input_dat...
401
12,834
mlflow
tests/models/test_model_config.py
.py
import os from unittest import mock import pytest from mlflow.exceptions import MlflowException from mlflow.models import ModelConfig dir_path = os.path.dirname(os.path.abspath(__file__)) VALID_CONFIG_PATH = os.path.join(dir_path, "configs/config.yaml") VALID_CONFIG_PATH_2 = os.path.join(dir_path, "configs/config_2....
93
3,666
mlflow
tests/models/test_resources.py
.py
import pytest from mlflow.models.resources import ( DEFAULT_API_VERSION, DatabricksApp, DatabricksFunction, DatabricksGenieSpace, DatabricksLakebase, DatabricksServingEndpoint, DatabricksSQLWarehouse, DatabricksTable, DatabricksUCConnection, DatabricksVectorSearchIndex, _Res...
363
13,623
mlflow
tests/models/test_artifacts.py
.py
import json import pathlib import pickle import numpy as np import pandas as pd import pytest from matplotlib.figure import Figure from mlflow.exceptions import MlflowException from mlflow.models.evaluation.artifacts import ( CsvEvaluationArtifact, ImageEvaluationArtifact, JsonEvaluationArtifact, Nump...
132
4,935
mlflow
tests/models/test_signature.py
.py
import json from dataclasses import asdict, dataclass import numpy as np import pandas as pd import pydantic import pyspark import pytest from sklearn.ensemble import RandomForestRegressor import mlflow from mlflow.exceptions import MlflowException from mlflow.models import Model, ModelSignature, infer_signature, rag...
387
13,706
mlflow
tests/models/test_pyfunc.py
.py
MLFLOW_VERSION = "1.0.0" # we expect this model to be bound to this mlflow version. class PyFuncTestModel: def __init__(self, check_version=True): self._check_version = check_version def predict(self, df): from mlflow.version import VERSION if self._check_version: assert...
19
473
mlflow
tests/models/test_model_input_examples.py
.py
import json import math from io import StringIO from unittest import mock import numpy as np import pandas as pd import pytest import sklearn.linear_model as logreg_module from scipy.sparse import csc_matrix, csr_matrix from sklearn import datasets from sklearn.base import BaseEstimator, ClassifierMixin import mlflow...
454
16,754
mlflow
tests/models/test_display_utils.py
.py
from pathlib import Path from unittest import mock import pytest from mlflow.models import infer_signature from mlflow.models.display_utils import ( _generate_agent_eval_recipe, _should_render_agent_eval_template, ) from mlflow.models.rag_signatures import StringResponse from mlflow.types.llm import ( Cha...
100
3,391
mlflow
tests/models/test_cli.py
.py
import json import os import re import shutil import subprocess import sys import warnings from dataclasses import dataclass from io import BytesIO, StringIO from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pytest import sklearn import sklearn.datasets import sklearn.lin...
1,045
35,512
mlflow
tests/models/test_model.py
.py
import json import os import pathlib import time import uuid from datetime import date from unittest import mock import numpy as np import pandas as pd import pydantic import pytest import sklearn.datasets import sklearn.linear_model from packaging.version import Version from scipy.sparse import csc_matrix import mlf...
787
29,835
mlflow
tests/models/test_utils.py
.py
import os import random from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import pytest import sklearn.linear_model as logreg_module from sklearn import datasets import mlflow from mlflow import MlflowClient from mlflow.entities.model_registry import ModelVersion from...
658
23,191
mlflow
tests/models/test_auth_policy.py
.py
from mlflow.models.auth_policy import AuthPolicy, SystemAuthPolicy, UserAuthPolicy from mlflow.models.resources import ( DatabricksFunction, DatabricksServingEndpoint, DatabricksUCConnection, DatabricksVectorSearchIndex, ) def test_complete_auth_policy(): system_auth_policy = SystemAuthPolicy( ...
121
4,075
mlflow
tests/models/test_wheeled_model.py
.py
import os import random import re from io import BytesIO from typing import Any, NamedTuple from unittest import mock import numpy as np import pandas as pd import pytest import sklearn.linear_model as logreg_module import yaml from sklearn import datasets import mlflow import mlflow.pyfunc.scoring_server as pyfunc_s...
509
18,751
mlflow
tests/models/test_dependencies_schema.py
.py
from unittest import mock from mlflow.models import dependencies_schemas from mlflow.models.dependencies_schemas import ( DependenciesSchemas, DependenciesSchemasType, RetrieverSchema, _get_dependencies_schemas, _get_retriever_schema, set_retriever_schema, ) def test_retriever_creation(): ...
287
9,199
mlflow
tests/projects/test_entry_point.py
.py
import os from shlex import quote from unittest import mock import pytest from mlflow.exceptions import ExecutionException from mlflow.projects._project_spec import EntryPoint from mlflow.utils.file_utils import TempDir, path_to_local_file_uri from tests.projects.utils import TEST_PROJECT_DIR, load_project def tes...
263
10,751
mlflow
tests/projects/test_kubernetes.py
.py
from unittest import mock import kubernetes import pytest import yaml from kubernetes.config.config_exception import ConfigException from mlflow.entities import RunStatus from mlflow.exceptions import ExecutionException from mlflow.projects import kubernetes as kb def test_run_command_creation(): command = [ ...
359
13,313
mlflow
tests/projects/utils.py
.py
import filecmp import logging import os import shutil import pytest from mlflow.entities import RunStatus from mlflow.projects import _project_spec from mlflow.utils.file_utils import TempDir, _copy_project TEST_DIR = "tests" TEST_PROJECT_DIR = os.path.abspath(os.path.join(TEST_DIR, "resources", "example_project")) ...
81
2,853
mlflow
tests/projects/test_project_spec.py
.py
import os import textwrap import pytest from mlflow.exceptions import ExecutionException from mlflow.projects import _project_spec from tests.projects.utils import load_project def test_project_get_entry_point(): project = load_project() entry_point = project.get_entry_point("greeter") assert entry_poi...
128
4,450
mlflow
tests/projects/test_databricks.py
.py
import filecmp import json import os import shutil from unittest import mock import pytest import mlflow from mlflow import MlflowClient, cli from mlflow.entities import RunStatus from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.exceptions import MlflowException from mlflow.legacy_databricks_c...
499
18,404
mlflow
tests/projects/test_projects_cli.py
.py
import hashlib import json import logging import os import shutil from pathlib import Path from unittest import mock import pytest from click.testing import CliRunner from mlflow import MlflowClient, cli from mlflow.utils import process from mlflow.utils.environment import _PythonEnv from mlflow.utils.virtualenv impo...
245
8,369
mlflow
tests/projects/test_projects.py
.py
import json import os import shutil import subprocess import uuid from unittest import mock import git import pytest import yaml import mlflow from mlflow import MlflowClient from mlflow.entities import RunStatus, SourceType, ViewType from mlflow.environment_variables import MLFLOW_CONDA_CREATE_ENV_CMD, MLFLOW_CONDA_...
549
19,035
mlflow
tests/projects/test_virtualenv_projects.py
.py
import os from unittest import mock import pytest import mlflow from mlflow.exceptions import MlflowException from mlflow.utils.virtualenv import _create_virtualenv from mlflow.utils.yaml_utils import read_yaml, write_yaml from tests.projects.utils import ( TEST_VIRTUALENV_CONDA_PROJECT_DIR, TEST_VIRTUALENV_...
148
4,827
mlflow
tests/projects/test_docker_projects.py
.py
import os from unittest import mock import docker import pytest import mlflow from mlflow import MlflowClient from mlflow.entities import ViewType from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.exceptions import MlflowException from mlflow.legacy_databricks_cli.configure.provider import Data...
331
11,600
mlflow
tests/projects/test_utils.py
.py
import os import tempfile import threading import zipfile from http.server import BaseHTTPRequestHandler, HTTPServer from typing import Generator from unittest import mock import git import pytest import mlflow from mlflow.exceptions import ExecutionException, MlflowException from mlflow.projects import _project_spec...
276
10,245
mlflow
tests/projects/conftest.py
.py
import os import shutil import git import pytest from tests.projects.utils import GIT_PROJECT_BRANCH, TEST_PROJECT_DIR @pytest.fixture def local_git_repo(tmp_path): local_git = str(tmp_path.joinpath("git_repo")) repo = git.Repo.init(local_git) shutil.copytree(src=TEST_PROJECT_DIR, dst=local_git, dirs_ex...
25
657
mlflow
tests/projects/backend/test_loader.py
.py
from mlflow.projects.backend import loader def test_plugin_backend(): backend = loader.load_backend("dummy-backend") assert backend is not None def test_plugin_does_not_exist(): backend = loader.load_backend("my_plugin") assert backend is None
12
264
mlflow
tests/projects/backend/test_local.py
.py
import os from unittest import mock from mlflow.projects.backend.local import _get_docker_artifact_storage_cmd_and_envs def test_docker_s3_artifact_cmd_and_envs_from_env(monkeypatch): mock_env = { "AWS_SECRET_ACCESS_KEY": "mock_secret", "AWS_ACCESS_KEY_ID": "mock_access_key", "MLFLOW_S3_E...
91
3,355
mlflow
tests/db/test_workspace_migration.py
.py
import os import re from contextlib import contextmanager import pytest import sqlalchemy as sa from alembic import command from mlflow.store.db.utils import _get_alembic_config from mlflow.store.tracking.dbmodels.initial_models import Base as InitialBase _LEGACY_REGISTERED_MODEL_TAGS = sa.table( "registered_mod...
1,228
36,303
mlflow
tests/db/test_workspace_move.py
.py
import uuid from pathlib import Path from unittest import mock import pytest import sqlalchemy as sa from mlflow.entities import ExperimentTag, TraceInfo from mlflow.entities.model_registry import ModelVersionTag, RegisteredModelTag from mlflow.entities.trace_location import TraceLocation from mlflow.entities.trace_s...
762
28,803
mlflow
tests/db/test_tracking_operations.py
.py
import sqlite3 import uuid from unittest import mock import pytest import sqlalchemy.dialects.sqlite.pysqlite import mlflow from mlflow import MlflowClient from mlflow.environment_variables import MLFLOW_TRACKING_URI pytestmark = pytest.mark.notrackingurimock class Model(mlflow.pyfunc.PythonModel): def load_co...
155
5,909
mlflow
tests/db/test_mcp_server_registry.py
.py
from pathlib import Path import pytest from mlflow.entities.mcp_server import MCPStatus from mlflow.environment_variables import MLFLOW_TRACKING_URI from mlflow.store.tracking.sqlalchemy_store import SqlAlchemyStore pytestmark = pytest.mark.notrackingurimock @pytest.fixture def store(tmp_path: Path): artifact_...
161
5,343
mlflow
tests/db/test_schema.py
.py
import difflib import logging import re from pathlib import Path from typing import NamedTuple import pytest from sqlalchemy import create_engine, inspect from sqlalchemy.schema import CreateTable, MetaData, UniqueConstraint _logger = logging.getLogger(__name__) _DIALECT_REFLECTED_UNIQUE_CONSTRAINTS = { "mysql":...
257
8,207
mlflow
tests/db/check_migration.py
.py
""" Usage ----- export MLFLOW_TRACKING_URI=sqlite:///mlruns.db # pre migration python tests/db/check_migration.py pre-migration # post migration python tests/db/check_migration.py post-migration """ import os import uuid from pathlib import Path import click import pandas as pd import sqlalchemy as sa import mlflo...
188
5,490
mlflow
tests/db/conftest.py
.py
import pytest from mlflow.environment_variables import MLFLOW_TRACKING_URI @pytest.fixture(autouse=True) def use_sqlite_if_tracking_uri_env_var_is_not_set(tmp_path, monkeypatch): if not MLFLOW_TRACKING_URI.defined: sqlite_file = tmp_path / "mlruns.sqlite" monkeypatch.setenv(MLFLOW_TRACKING_URI.na...
11
352
mlflow
tests/types/test_type_hints.py
.py
import datetime from typing import Any, Dict, List, Optional, Union, get_args from unittest import mock import numpy as np import pandas as pd import pydantic import pytest from scipy.sparse import csc_matrix, csr_matrix from mlflow.exceptions import MlflowException from mlflow.models.utils import PyFuncOutput, _enfo...
510
18,021
mlflow
tests/types/test_genai_types.py
.py
import pytest from pydantic import ValidationError from mlflow.types.chat import ChatCompletionResponse def test_instantiation_chat_completion(): response_structure = { "id": "1", "object": "1", "created": 1, "model": "model", "choices": [ { "in...
91
3,043
mlflow
tests/types/test_schema.py
.py
import datetime import json import math import re from dataclasses import dataclass, field from typing import Optional import numpy as np import pandas as pd import pyspark import pyspark.sql.types as T import pytest from scipy.sparse import csc_matrix, csr_matrix from mlflow.exceptions import MlflowException from ml...
2,007
71,028
mlflow
tests/helpers/db_mocks.py
.py
from __future__ import annotations from contextlib import contextmanager from unittest import mock def mock_get_managed_session_maker(*args, **kwargs): @contextmanager def _manager(): session = mock.MagicMock() def _mock_query(*q_args, **q_kwargs): query = mock.MagicMock() ...
25
661
mlflow
tests/claude_code/test_config.py
.py
import json import pytest from mlflow.claude_code.config import ( MLFLOW_TRACING_ENABLED, get_env_var, get_tracing_status, load_claude_config, save_claude_config, setup_environment_config, ) @pytest.fixture def temp_settings_path(tmp_path): """Provide a temporary settings.json path for t...
334
11,671
mlflow
tests/claude_code/test_tracing.py
.py
import importlib import json import logging from pathlib import Path import pytest from claude_agent_sdk.types import ( AssistantMessage, ResultMessage, TextBlock, ToolResultBlock, ToolUseBlock, UserMessage, ) import mlflow import mlflow.claude_code.tracing as tracing_module from mlflow.claude...
906
30,720
mlflow
tests/claude_code/test_autolog.py
.py
import sys from unittest.mock import MagicMock, patch import pytest from claude_agent_sdk.types import AssistantMessage, ResultMessage, TextBlock, UserMessage import mlflow.anthropic from mlflow.anthropic.autolog import patched_claude_sdk_init def test_anthropic_autolog_without_claude_sdk(): sys.modules.pop("cl...
138
4,426
mlflow
tests/claude_code/test_plugin.py
.py
import json import subprocess from unittest import mock import click import pytest from mlflow.claude_code.plugin import disable_tracing_plugin, ensure_plugin_installed def test_disable_tracing_plugin_removes_env_only(tmp_path): settings_path = tmp_path / ".claude" / "settings.json" settings_path.parent.mkd...
50
1,753
mlflow
tests/claude_code/test_cli.py
.py
import json from pathlib import Path from unittest import mock import pytest from click.testing import CliRunner from mlflow.claude_code.cli import commands @pytest.fixture def runner(): return CliRunner() @pytest.fixture(autouse=True) def _clear_mlflow_env(monkeypatch): for name in ( "MLFLOW_TRAC...
225
8,108
mlflow
tests/pmdarima/test_pmdarima_model_export.py
.py
import json import os from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pmdarima import pytest import yaml import mlflow.pmdarima import mlflow.pyfunc.scoring_server as pyfunc_scoring_server from mlflow import pyfunc from mlflow.exceptions import MlflowException from mlf...
484
19,484
mlflow
tests/crewai/test_crewai_autolog.py
.py
import json from unittest.mock import ANY, Mock, patch import crewai import pytest from crewai import Agent, Crew, Task from crewai.flow.flow import Flow, start from crewai.tools import BaseTool from packaging.version import Version import mlflow from mlflow.crewai.autolog import patched_class_call, patched_standalon...
724
22,567
mlflow
tests/agent/test_prompt.py
.py
from __future__ import annotations from pathlib import Path import pytest from mlflow.agent.agents import AGENTS from mlflow.agent.setup.prompt import _render, build_prompt def test_render_substitutes_placeholder(): assert _render("hello {{ name }}", name="world") == "hello world" def test_render_accepts_no_...
114
3,798
mlflow
tests/agent/test_cli.py
.py
from __future__ import annotations import json import subprocess from pathlib import Path from unittest import mock import click import pytest from click.testing import CliRunner from mlflow.agent.agents import AGENTS from mlflow.agent.setup.cli import _git_root, _is_localhost_tracking_uri, setup from mlflow.telemet...
564
22,807
mlflow
tests/shap/test_log.py
.py
import json from pathlib import Path from unittest import mock import numpy as np import pandas as pd import pytest import shap import sklearn from numba import njit from packaging.version import Version from sklearn.datasets import load_diabetes import mlflow import mlflow.pyfunc.scoring_server as pyfunc_scoring_ser...
515
18,036
mlflow
tests/shap/test_shap.py
.py
import os from typing import Any, NamedTuple import matplotlib.pyplot as plt import numpy as np import pandas as pd import pytest import shap from sklearn.datasets import load_diabetes, load_iris from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor import mlflow from mlflow import MlflowClient f...
265
9,075
mlflow
tests/autologging/test_autologging_safety_unit.py
.py
import abc import copy import inspect from contextlib import nullcontext as does_not_raise from typing import Any, NamedTuple from unittest import mock import pytest import mlflow from mlflow import MlflowClient from mlflow.entities import RunStatus from mlflow.utils import autologging_utils from mlflow.utils.autolog...
1,686
56,729
mlflow
tests/autologging/test_autologging_behaviors_unit.py
.py
import logging import sys import threading import time import warnings from concurrent.futures import ThreadPoolExecutor from io import StringIO import numpy as np import pytest import mlflow from mlflow.utils.autologging_utils import autologging_integration, safe_patch from mlflow.utils.logging_utils import eprint ...
352
13,139
mlflow
tests/autologging/fixtures.py
.py
import os import sys import pytest from mlflow.environment_variables import _MLFLOW_AUTOLOGGING_TESTING from mlflow.utils import logging_utils from mlflow.utils.autologging_utils import is_testing PATCH_DESTINATION_FN_DEFAULT_RESULT = "original_result" # Fixture to run the test case with and without async logging ...
118
3,324
mlflow
tests/autologging/test_training_session.py
.py
import pytest from mlflow.utils.autologging_utils import _get_new_training_session_class _TrainingSession = _get_new_training_session_class() class Parent: pass class Child: pass class Grandchild: pass PARENT = Parent() CHILD = Child() GRAND_CHILD = Grandchild() @pytest.fixture(autouse=True) def...
122
3,630
mlflow
tests/autologging/async_helper.py
.py
import asyncio import inspect from concurrent.futures import ThreadPoolExecutor from mlflow.utils.autologging_utils.safety import update_wrapper_extended def asyncify(is_async): """ Decorator that converts a function to an async function if `is_async` is True. This is useful for testing purposes, where w...
45
1,696
mlflow
tests/autologging/test_autologging_behaviors_integration.py
.py
import importlib import logging import sys import warnings from concurrent.futures import ThreadPoolExecutor from io import StringIO from itertools import permutations from unittest import mock import pytest import mlflow from mlflow import MlflowClient from mlflow.utils import gorilla from mlflow.utils.autologging_u...
335
11,961
mlflow
tests/autologging/test_autologging_client.py
.py
import time from unittest import mock import pytest import mlflow from mlflow import MlflowClient from mlflow.exceptions import MlflowException from mlflow.utils import _truncate_dict from mlflow.utils.autologging_utils import MlflowAutologgingQueueingClient from mlflow.utils.validation import ( MAX_ENTITY_KEY_LE...
272
10,603
mlflow
tests/autologging/test_autologging_utils.py
.py
import importlib import inspect import sys import time from typing import Any, NamedTuple from unittest import mock import pytest import mlflow from mlflow import MlflowClient from mlflow.ml_package_versions import FLAVOR_TO_MODULE_NAME from mlflow.utils import gorilla from mlflow.utils.autologging_utils import ( ...
945
34,883
mlflow
tests/llama_index/test_llama_index_autolog.py
.py
from importlib import metadata from unittest import mock import pytest from llama_index.core.chat_engine.types import ChatMode from llama_index.core.instrumentation import get_dispatcher from llama_index.core.instrumentation.event_handlers.base import BaseEventHandler from llama_index.core.instrumentation.span_handler...
388
12,937
mlflow
tests/llama_index/test_llama_index_pyfunc_wrapper.py
.py
import llama_index.core import numpy as np import pandas as pd import pytest from llama_index.core import QueryBundle from llama_index.core.llms import ChatMessage from packaging.version import Version import mlflow from mlflow.llama_index.pyfunc_wrapper import ( _CHAT_MESSAGE_HISTORY_PARAMETER_NAME, CHAT_ENGI...
324
10,712
mlflow
tests/llama_index/test_llama_index_node_conversion.py
.py
from llama_index.core.schema import NodeWithScore, TextNode from mlflow.entities import Document def test_from_llama_index_node_with_score(): text_node = TextNode(text="Hello", metadata={"key": "value"}) node_with_score = NodeWithScore(node=text_node, score=0.5) document = Document.from_llama_index_node_...
13
505
mlflow
tests/llama_index/test_llama_index_evaluate.py
.py
import pandas as pd import pytest import mlflow from mlflow.metrics import latency from mlflow.tracing.constant import TraceMetadataKey from tests.openai.test_openai_evaluate import purge_traces from tests.tracing.helper import get_traces, reset_autolog_state # noqa: F401 _EVAL_DATA = pd.DataFrame({ "inputs": [...
113
3,552
mlflow
tests/llama_index/test_llama_index_serialization.py
.py
import json from collections import Counter, deque from unittest import mock import pytest from llama_index.core import PromptTemplate, Settings from llama_index.embeddings.openai import OpenAIEmbedding from llama_index.llms.openai import OpenAI from mlflow.llama_index.serialize_objects import ( _construct_prompt...
151
5,419
mlflow
tests/llama_index/test_llama_index_model_export.py
.py
import json import os from pathlib import Path from typing import Any from unittest import mock import llama_index.core import numpy as np import pandas as pd import pytest from llama_index.core import QueryBundle, Settings, VectorStoreIndex from llama_index.core.base.base_query_engine import BaseQueryEngine from llam...
603
21,559
mlflow
tests/llama_index/test_llama_index_tracer.py
.py
import asyncio import base64 import inspect import random from dataclasses import asdict from importlib import metadata from pathlib import Path from typing import Any from unittest.mock import ANY import llama_index.core import openai import pytest from llama_index.core import Settings from llama_index.core.base.resp...
911
32,719
mlflow
tests/llama_index/conftest.py
.py
import os import re import shutil import sys import pytest from llama_index.core import ( Document, KnowledgeGraphIndex, PromptTemplate, Settings, VectorStoreIndex, ) from llama_index.core.callbacks import CallbackManager, LlamaDebugHandler from llama_index.core.node_parser import SentenceSplitter ...
120
3,315
mlflow
tests/llama_index/sample_code/with_model_config.py
.py
""" Sample code to define a chat engine and save it with model config (dictionary). """ from llama_index.core import Document, VectorStoreIndex from llama_index.core.chat_engine.types import ChatMode from llama_index.llms.openai import OpenAI import mlflow model_config = mlflow.models.ModelConfig() model_name = mode...
21
698
mlflow
tests/llama_index/sample_code/query_engine_with_reranker.py
.py
""" Sample code to define a query engine with post processors and save it with model-from-code logging. Ref: https://qdrant.tech/documentation/quickstart/ """ from llama_index.core import Document, QueryBundle, VectorStoreIndex from llama_index.core.postprocessor import LLMRerank from llama_index.core.postprocessor.t...
42
1,093
mlflow
tests/llama_index/sample_code/basic_retriever.py
.py
from llama_index.core import Document, VectorStoreIndex import mlflow index = VectorStoreIndex.from_documents(documents=[Document.example()]) retriever = index.as_retriever() mlflow.models.set_model(retriever)
9
213
mlflow
tests/llama_index/sample_code/external_vector_store.py
.py
""" Sample code to define an index using an external vector store (Faiss) for model-from-code logging. Ref: https://qdrant.tech/documentation/quickstart/ """ from llama_index.core import VectorStoreIndex from llama_index.vector_stores.qdrant import QdrantVectorStore from qdrant_client import QdrantClient from qdrant_...
37
1,078
mlflow
tests/llama_index/sample_code/basic_vector_store.py
.py
from llama_index.core import Document, VectorStoreIndex import mlflow index = VectorStoreIndex.from_documents(documents=[Document.example()]) mlflow.models.set_model(index)
8
176
mlflow
tests/llama_index/sample_code/basic_chat_engine.py
.py
""" Sample code to define a chat engine and save it with model-from-code logging. Ref: https://qdrant.tech/documentation/quickstart/ """ from llama_index.core import Document, VectorStoreIndex from llama_index.core.chat_engine.types import ChatMode import mlflow index = VectorStoreIndex.from_documents(documents=[Do...
17
506
mlflow
tests/llama_index/sample_code/with_model_config_yaml_file.py
.py
""" Sample code to define a chat engine and save it with model config (YAML file). """ from llama_index.core import Document, VectorStoreIndex from llama_index.core.chat_engine.types import ChatMode from llama_index.llms.openai import OpenAI import mlflow model_config = mlflow.models.ModelConfig(development_config="...
22
768
mlflow
tests/llama_index/sample_code/simple_workflow.py
.py
from llama_index.core.workflow import ( Event, StartEvent, StopEvent, Workflow, step, ) from llama_index.llms.openai import OpenAI import mlflow class JokeEvent(Event): joke: str class JokeFlow(Workflow): llm = OpenAI() @step async def generate_joke(self, ev: StartEvent) -> Jok...
38
860
mlflow
examples/johnsnowlabs/export.py
.py
import json import os import pandas as pd from johnsnowlabs import nlp import mlflow from mlflow.pyfunc import spark_udf # 1) Write your raw license.json string into the 'JOHNSNOWLABS_LICENSE_JSON' env variable for MLflow creds = { "AWS_ACCESS_KEY_ID": "...", "AWS_SECRET_ACCESS_KEY": "...", "SPARK_NLP_LI...
53
1,596
mlflow
examples/spark_udf/structs_and_arrays.py
.py
from pyspark.sql import SparkSession from pyspark.sql import types as T import mlflow class MyModel(mlflow.pyfunc.PythonModel): def predict(self, context, model_input): return [str(" | ".join(map(str, row))) for _, row in model_input.iterrows()] def main(): with SparkSession.builder.getOrCreate() a...
68
1,868
mlflow
examples/spark_udf/spark_udf_datetime.py
.py
import datetime import random from pyspark.sql import SparkSession from sklearn.compose import ColumnTransformer from sklearn.datasets import load_iris from sklearn.neighbors import KNeighborsClassifier from sklearn.pipeline import Pipeline from sklearn.preprocessing import FunctionTransformer import mlflow def pri...
68
2,221
mlflow
examples/spark_udf/spark_udf.py
.py
from pyspark.sql import SparkSession from sklearn import datasets from sklearn.neighbors import KNeighborsClassifier import mlflow from mlflow.models import infer_signature with SparkSession.builder.getOrCreate() as spark: X, y = datasets.load_iris(as_frame=True, return_X_y=True) model = KNeighborsClassifier(...
24
792