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/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
mlflow
dev/proto_plugin.py
.py
import json import sys import textwrap from dataclasses import asdict, dataclass from dataclasses import field as dataclass_field from enum import Enum from google.protobuf import descriptor_pb2 from google.protobuf.compiler import plugin_pb2 from mlflow.protos import databricks_pb2 class Visibility(Enum): PUBL...
559
19,369
mlflow
dev/gen_rest_api.py
.py
# /// script # dependencies = ["texttable"] # /// """Generate RST documentation from protobuf JSON definitions.""" from __future__ import annotations import json import logging import re from enum import Enum from pathlib import Path from textwrap import dedent from typing import Any from texttable import Texttable ...
864
30,277
mlflow
dev/normalize_chars.py
.py
import sys from pathlib import Path # Mapping of characters to normalize. Start with quotes; extend as needed. CHAR_MAP = { "\u2018": "'", # left single quotation mark "\u2019": "'", # right single quotation mark "\u201c": '"', # left double quotation mark "\u201d": '"', # right double quotation ma...
44
1,073
mlflow
dev/build_docs.py
.py
"""Build MLflow release documentation and publish to mlflow-legacy-website.""" from __future__ import annotations import argparse import json import os import shutil import subprocess import uuid from datetime import datetime, timezone from pathlib import Path from packaging.version import InvalidVersion, Version #...
282
9,201
mlflow
dev/extract_deps.py
.py
import ast import re from pathlib import Path from typing import cast def parse_dependencies(content: str) -> list[str]: pattern = r"dependencies\s*=\s*(\[[\s\S]*?\])\n" match = re.search(pattern, content) if match is None: raise ValueError("Could not find dependencies in pyproject.toml") deps...
24
590
mlflow
dev/update_mlflow_versions.py
.py
import argparse import logging import re from pathlib import Path from packaging.version import Version _logger = logging.getLogger(__name__) _PYTHON_VERSION_FILES = [ Path("mlflow", "version.py"), ] _PYPROJECT_TOML_FILES = [ Path("pyproject.toml"), Path("pyproject.release.toml"), Path("libs/skinny/...
274
9,183
mlflow
dev/create_release_branch.py
.py
import argparse import os import subprocess from packaging.version import Version def main(new_version: str, remote: str, dry_run: bool = False) -> None: version = Version(new_version) release_branch = f"branch-{version.major}.{version.minor}" exists_on_remote = ( subprocess.check_output( ...
63
2,169
mlflow
dev/update_model_catalog.py
.py
"""Update the MLflow model catalog from upstream data sources. Usage: uv run python dev/update_model_catalog.py [--output-dir PATH] Fetches the LiteLLM model_prices_and_context_window.json from GitHub, transforms it into the MLflow-native schema, and merges the results into the per-provider catalog files in the o...
467
18,012
mlflow
dev/annotate_flaky_tests.py
.py
"""Insert @pytest.mark.flaky decorators for classifier-approved flaky tests. Third stage of the flaky-test pipeline (detect -> classify -> annotate). Reads the classifier output and, for every verdict with ``action == "annotate"``, adds a ``@pytest.mark.flaky(attempts=N)`` decorator above the corresponding test functi...
251
10,316
mlflow
dev/validate_release_version.py
.py
import argparse from packaging.version import Version def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument( "--version", help="Release version to validate, e.g., '1.2.3'", required=True ) return parser.parse_args() def main() -> None: args = par...
26
580
mlflow
dev/generate_protos.py
.py
import platform import subprocess import tempfile import textwrap import urllib.request import zipfile from pathlib import Path from typing import Literal SYSTEM = platform.system() MACHINE = platform.machine() CACHE_DIR = Path(".cache/protobuf_cache") MLFLOW_PROTOS_DIR = Path("mlflow/protos") TEST_PROTOS_DIR = Path("...
334
10,408
mlflow
dev/build.py
.py
import argparse import contextlib import shutil import subprocess import sys import zipfile from collections.abc import Generator from dataclasses import dataclass from pathlib import Path @dataclass(frozen=True) class Package: # name of the package on PyPI. pypi_name: str # type of the package, one of "d...
141
4,044
mlflow
dev/remove_experimental_decorators.py
.py
""" Script to automatically remove @experimental decorators from functions that have been experimental for more than a configurable cutoff period (default: 6 months). """ import argparse import ast import json import subprocess from dataclasses import dataclass from datetime import datetime, timedelta, timezone from p...
200
7,105
mlflow
dev/xtest_viz.py
.py
# /// script # dependencies = [ # "aiohttp", # ] # /// """ Script to visualize cross-version test results for MLflow autologging and models. This script fetches scheduled workflow run results from GitHub Actions and generates a markdown table showing the test status for different package versions across different ...
390
13,558
mlflow
dev/update_ml_package_versions.py
.py
""" Backward-compatibility entry point that delegates to `flavors update`. Internal jobs still invoke `python dev/update_ml_package_versions.py [--skip-yml]`. Prefer `uv run flavors update` for new callers. TODO: Delete this file once all internal jobs have migrated. """ import sys from flavors._cli import main if...
17
410
mlflow
dev/pypi/tests/test_client.py
.py
from __future__ import annotations import asyncio import json import threading from collections.abc import Iterator from contextlib import contextmanager from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from typing import Any from unittest import mock import pypi import pytest from packaging.versio...
159
5,081
mlflow
dev/pypi/tests/test_models.py
.py
from __future__ import annotations from typing import Any import pytest from packaging.specifiers import SpecifierSet from packaging.version import Version from pypi._models import Package _DEFAULT_UPLOAD = "2024-01-01T00:00:00Z" def _payload(releases: dict[str, list[dict[str, Any]]]) -> dict[str, Any]: # Inje...
153
5,177
mlflow
dev/pypi/tests/conftest.py
.py
from collections.abc import Iterator import pypi import pytest @pytest.fixture(autouse=True) def _clear_caches() -> Iterator[None]: pypi.clear_cache() yield pypi.clear_cache()
12
191
mlflow
dev/pypi/src/pypi/__init__.py
.py
from pypi._client import PyPIError, clear_cache, get_package, get_packages from pypi._models import Package, Release __all__ = [ "Package", "PyPIError", "Release", "clear_cache", "get_package", "get_packages", ]
12
237
mlflow
dev/pypi/src/pypi/_models.py
.py
from __future__ import annotations from dataclasses import dataclass from datetime import datetime from typing import Any from packaging.specifiers import InvalidSpecifier, SpecifierSet from packaging.version import InvalidVersion, Version def _parse_upload_time(value: str | None) -> datetime | None: if not val...
89
3,004
mlflow
dev/pypi/src/pypi/_client.py
.py
from __future__ import annotations import asyncio import json import os from collections.abc import Iterable from typing import Any, Literal, overload import aiohttp from pypi._models import Package _DEFAULT_PYPI_URL = "https://pypi.org" _TIMEOUT_SECONDS = 10.0 _RETRIES = 3 _BACKOFF_BASE = 0.5 # Transient HTTP sta...
110
3,669
mlflow
dev/flavors/tests/test_update.py
.py
from datetime import datetime, timedelta, timezone from pathlib import Path from unittest import mock import pytest from flavors import _update from flavors._update import VersionInfo from pypi import Package def _iso8601(dt: datetime) -> str: return (dt if dt.tzinfo else dt.replace(tzinfo=timezone.utc)).isoform...
238
5,712
mlflow
dev/flavors/tests/test_cli.py
.py
import subprocess import sys from unittest import mock import pytest from flavors import _cli def _run(*args: str) -> subprocess.CompletedProcess[str]: return subprocess.run( [sys.executable, "-m", "flavors._cli", *args], capture_output=True, text=True, check=False, ) @pytes...
46
1,339
mlflow
dev/flavors/tests/test_matrix.py
.py
import asyncio import functools import re import tempfile from collections.abc import Iterator from contextlib import contextmanager from pathlib import Path from typing import Any, Callable, ParamSpec, TypeVar from unittest import mock import pytest pytestmark = pytest.mark.skip( reason="Disabled by #21985: dev ...
175
5,585
mlflow
dev/flavors/src/flavors/_releases.py
.py
from __future__ import annotations from datetime import datetime, timedelta, timezone from pypi import Package from flavors._schema import Version RELEASE_CUTOFF_DAYS = 7 def get_released_versions(package: Package) -> list[Version]: cutoff = datetime.now(tz=timezone.utc) - timedelta(days=RELEASE_CUTOFF_DAYS) ...
22
663
mlflow
dev/flavors/src/flavors/_schema.py
.py
from __future__ import annotations from datetime import datetime, timezone from pathlib import Path from packaging.specifiers import SpecifierSet from packaging.version import Version as OriginalVersion from pydantic import BaseModel, ConfigDict, field_validator DEV_VERSION = "dev" # Treat "dev" as "newer than any e...
113
3,614
mlflow
dev/flavors/src/flavors/_cli.py
.py
from __future__ import annotations import argparse import asyncio from flavors import _matrix, _update def main() -> None: parser = argparse.ArgumentParser( prog="flavors", description="CLI for cooking mlflow/ml-package-versions.yml.", ) subparsers = parser.add_subparsers(dest="command",...
40
1,092
mlflow
dev/flavors/src/flavors/__init__.py
.py
from flavors._loader import VERSIONS_YAML_PATH, load, load_or_default, load_raw from flavors._releases import RELEASE_CUTOFF_DAYS, get_released_versions from flavors._schema import ( DEV_NUMERIC, DEV_VERSION, FlavorConfig, PackageInfo, TestConfig, Version, ) __all__ = [ "DEV_NUMERIC", "...
26
541
mlflow
dev/flavors/src/flavors/_update.py
.py
""" Update the maximum package versions in `mlflow/ml-package-versions.yml`. # Usage ``` flavors update flavors update --skip-yml ``` """ from __future__ import annotations import argparse import asyncio import json import os import re import urllib.error import urllib.request from dataclasses import dataclass from...
304
10,713
mlflow
dev/flavors/src/flavors/_loader.py
.py
from __future__ import annotations from pathlib import Path from typing import Any import yaml from flavors._schema import FlavorConfig VERSIONS_YAML_PATH = "mlflow/ml-package-versions.yml" def load(path: str | Path) -> dict[str, FlavorConfig]: with open(path) as f: raw = yaml.safe_load(f) return ...
35
867
mlflow
dev/flavors/src/flavors/_matrix.py
.py
""" Generate the cross-version test matrix from `mlflow/ml-package-versions.yml`. # Usage ``` # Test all items flavors matrix # Exclude items for dev versions flavors matrix --no-dev # Test items affected by config file updates flavors matrix --ref-versions-yaml /path/to/ref-versions.yml # Test items affected by f...
660
23,611
mlflow
dev/proto_to_graphql/parsing_utils.py
.py
from autogeneration_utils import get_method_name from google.protobuf.descriptor import FieldDescriptor from mlflow.protos import databricks_pb2 def get_method_type(method_descriptor): return method_descriptor.GetOptions().Extensions[databricks_pb2.rpc].endpoints[0].method def process_method(method_descriptor,...
68
2,768
mlflow
dev/proto_to_graphql/schema_autogeneration.py
.py
import ast from autogeneration_utils import ( DUMMY_FIELD, INDENT, INDENT2, SCHEMA_EXTENSION, SCHEMA_EXTENSION_MODULE, get_descriptor_full_pascal_name, get_method_name, method_descriptor_to_generated_pb2_file_name, ) from google.protobuf.descriptor import FieldDescriptor from string_uti...
226
8,889
mlflow
dev/proto_to_graphql/string_utils.py
.py
import re def camel_to_snake(string): return re.sub(r"(?<!^)(?=[A-Z])", "_", string).lower() def snake_to_camel(string): return "".join(x[0].upper() + x[1:] for x in string.split("_")) def snake_to_pascal(string): temp = snake_to_camel(string) return temp[0].upper() + temp[1:]
15
300
mlflow
dev/benchmarks/tracing/_data.py
.py
import json import random import time import uuid from opentelemetry import trace as trace_api from opentelemetry.sdk.resources import Resource as _OTelResource from opentelemetry.sdk.trace import ReadableSpan as OTelReadableSpan from opentelemetry.trace import SpanContext from mlflow.entities.span import Span, SpanT...
117
4,038
mlflow
dev/benchmarks/tracing/test_trace_perf.py
.py
import random from _data import generate_trace_data from pytest_benchmark.fixture import BenchmarkFixture import mlflow from mlflow.entities.span import SpanType from mlflow.store.tracking.sqlalchemy_store import SqlAlchemyStore DEFAULT_SPANS = 100 INGEST_ROUNDS = 20 INGEST_WARMUP = 3 def test_ingest(benchmark: Be...
132
3,923
mlflow
dev/benchmarks/tracing/conftest.py
.py
from collections.abc import Iterator from pathlib import Path import pytest from _data import SEED_SPANS_PER_TRACE, SEED_TRACES, seed_traces import mlflow from mlflow.store.tracking.sqlalchemy_store import SqlAlchemyStore @pytest.fixture(scope="session") def bench_dir(tmp_path_factory: pytest.TempPathFactory) -> Pa...
40
1,215
mlflow
dev/benchmarks/gateway/fake_server.py
.py
# /// script # requires-python = ">=3.10" # dependencies = ["fastapi>=0.115.0,<1", "uvicorn[standard]>=0.30.0,<1"] # /// """Fake OpenAI-compatible server for benchmarking. Returns synthetic responses after a configurable delay so benchmarks measure MLflow overhead rather than provider latency. Run standalone: uv ...
69
1,859
mlflow
dev/benchmarks/gateway/benchmark.py
.py
# /// script # requires-python = ">=3.10" # dependencies = ["aiohttp>=3.13.3,<4", "rich>=14.3.3,<15"] # /// """Async HTTP benchmark client for the MLflow AI Gateway. Can be imported by run.py or used standalone: uv run benchmark.py --url http://127.0.0.1:5731/gateway/benchmark-chat/mlflow/invocations uv run be...
363
11,726
mlflow
dev/benchmarks/gateway/run.py
.py
# /// script # requires-python = ">=3.10" # dependencies = ["aiohttp>=3.13.3,<4", "psycopg2-binary>=2.9,<3", "rich>=14.3.3,<15"] # /// """MLflow AI Gateway benchmark runner. Orchestrates fake OpenAI server, MLflow server(s), optional PostgreSQL and nginx (via Docker), then runs the async benchmark client. Usage: ...
794
27,232
mlflow
dev/clint/tests/test_config.py
.py
import subprocess from pathlib import Path from typing import Generator import pytest from clint.config import Config from clint.utils import get_repo_root @pytest.fixture(autouse=True) def clear_repo_root_cache() -> Generator[None, None, None]: """Clear the get_repo_root cache before each test to avoid cross-te...
128
3,516
mlflow
dev/clint/tests/test_ignore_map.py
.py
from clint.linter import DisableComment, parse_comments def _parse(code: str) -> list[DisableComment]: disables, _ = parse_comments(code) return disables def test_single_rule() -> None: code = """ x = 1 # clint: disable=rule-a y = 2 """ assert _parse(code) == [DisableComment("rule-a", 1, 9, 1)] d...
79
1,895
mlflow
dev/clint/tests/test_resolve_paths.py
.py
from __future__ import annotations import subprocess from pathlib import Path from unittest.mock import patch import pytest from clint.utils import ALLOWED_EXTS, _git_ls_files, resolve_paths @pytest.fixture def git_repo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: """Create and initialize a git rep...
280
9,184
mlflow
dev/clint/tests/test_index.py
.py
from pathlib import Path from unittest.mock import patch from clint.index import SymbolIndex def test_symbol_index_build_basic(tmp_path: Path) -> None: mlflow_dir = tmp_path / "mlflow" mlflow_dir.mkdir() test_file = mlflow_dir / "test.py" test_file.write_text("def test_function(): pass") mock_g...
43
1,401
mlflow
dev/clint/tests/rules/test_mock_patch_dict_environ.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.mock_patch_dict_environ import MockPatchDictEnviron def test_mock_patch_dict_environ_with_string_literal(index: SymbolIndex) -> None: code = """ import...
137
4,144
mlflow
dev/clint/tests/rules/test_redundant_test_docstring.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import lint_file from clint.rules.redundant_test_docstring import RedundantTestDocstring def test_redundant_docstrings_are_flagged(index: SymbolIndex) -> None: code = ''' def test_feature_a(): """ ...
230
6,049
mlflow
dev/clint/tests/rules/test_implicit_optional.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import ImplicitOptional def test_implicit_optional(index: SymbolIndex) -> None: code = """ from typing import Optional # Bad bad: int = None class Bad...
61
1,671
mlflow
dev/clint/tests/rules/test_no_shebang.py
.py
from pathlib import Path import pytest from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import NoShebang def test_no_shebang(index: SymbolIndex) -> None: config = Config(select={NoShebang.name}) # Test file with shebang ...
66
1,968
mlflow
dev/clint/tests/rules/test_test_name_typo.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.test_name_typo import TestNameTypo def test_test_name_typo(index: SymbolIndex) -> None: code = """import pytest # Bad - starts with 'test' but missing...
38
992
mlflow
dev/clint/tests/rules/test_unknown_mlflow_function.py
.py
from pathlib import Path import pytest from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.unknown_mlflow_function import UnknownMlflowFunction def test_unknown_mlflow_function(index: SymbolIndex) -> None: code = ''' def bad(): ...
69
1,507
mlflow
dev/clint/tests/rules/test_forbidden_set_active_model_usage.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.forbidden_set_active_model_usage import ForbiddenSetActiveModelUsage def test_forbidden_set_active_model_usage(index: SymbolIndex) -> None: code = """ ...
34
1,132
mlflow
dev/clint/tests/rules/test_empty_notebook_cell.py
.py
import json from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import lint_file from clint.rules.empty_notebook_cell import EmptyNotebookCell def test_empty_notebook_cell(index: SymbolIndex) -> None: notebook_content = { "cells": [ {...
48
1,494
mlflow
dev/clint/tests/rules/test_lazy_import.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import LazyImport def test_lazy_import(index: SymbolIndex) -> None: code = """ def f(): # Bad import sys import pandas as pd # Good import...
50
1,374
mlflow
dev/clint/tests/rules/test_unused_disable_comment.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import UnusedDisableComment def test_stale_disable_comment(index: SymbolIndex) -> None: code = """ import os # clint: disable=lazy-import """ conf...
90
3,032
mlflow
dev/clint/tests/rules/test_nested_mock_patch.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.nested_mock_patch import NestedMockPatch def test_nested_mock_patch_unittest_mock(index: SymbolIndex) -> None: code = """ import unittest.mock def tes...
203
6,175
mlflow
dev/clint/tests/rules/test_forbidden_top_level_import.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.forbidden_top_level_import import ForbiddenTopLevelImport def test_forbidden_top_level_import(index: SymbolIndex) -> None: code = """ # Bad import foo ...
46
1,352
mlflow
dev/clint/tests/rules/test_mock_patch_as_decorator.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.mock_patch_as_decorator import MockPatchAsDecorator def test_mock_patch_as_decorator_unittest_mock(index: SymbolIndex) -> None: code = """ import unitt...
110
3,387
mlflow
dev/clint/tests/rules/test_extraneous_docstring_param.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.extraneous_docstring_param import ExtraneousDocstringParam def test_extraneous_docstring_param(index: SymbolIndex) -> None: code = ''' def bad_function...
35
1,036
mlflow
dev/clint/tests/rules/test_unsafe_version_parse.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import lint_file from clint.rules.unsafe_version_parse import UnsafeVersionParse def test_unsafe_version_parse(index: SymbolIndex) -> None: code = """ import importlib.metadata import importlib_metadata...
71
2,362
mlflow
dev/clint/tests/rules/test_except_bool_op.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import ExceptBoolOp def test_except_bool_op(index: SymbolIndex) -> None: code = """ # Bad - or in except try: pass except ValueError or KeyError: ...
55
1,016
mlflow
dev/clint/tests/rules/test_invalid_experimental_decorator.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.invalid_experimental_decorator import InvalidExperimentalDecorator def test_invalid_experimental_decorator(index: SymbolIndex) -> None: code = """ from...
57
1,659
mlflow
dev/clint/tests/rules/test_unknown_mlflow_arguments.py
.py
from pathlib import Path import pytest from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.unknown_mlflow_arguments import UnknownMlflowArguments def test_unknown_mlflow_arguments(index: SymbolIndex) -> None: code = ''' def bad(...
68
1,586
mlflow
dev/clint/tests/rules/test_prefer_dict_union.py
.py
from pathlib import Path import pytest from clint.config import Config from clint.index import SymbolIndex from clint.linter import lint_file from clint.rules import PreferDictUnion @pytest.mark.parametrize( "code", [ pytest.param("{**dict1, **dict2}", id="two_dict_unpacks"), pytest.param("{*...
48
1,976
mlflow
dev/clint/tests/rules/test_forbidden_make_judge_in_builtin_scorers.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import lint_file from clint.rules.forbidden_make_judge_in_builtin_scorers import ( ForbiddenMakeJudgeInBuiltinScorers, ) def test_forbidden_make_judge_in_builtin_scorers(index: SymbolIndex) -> None: ...
87
2,954
mlflow
dev/clint/tests/rules/test_invalid_abstract_method.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.invalid_abstract_method import InvalidAbstractMethod def test_invalid_abstract_method(index: SymbolIndex) -> None: code = """ import abc class Abstrac...
41
1,223
mlflow
dev/clint/tests/rules/test_log_model_artifact_path.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.log_model_artifact_path import LogModelArtifactPath def test_log_model_artifact_path(index: SymbolIndex) -> None: code = """ import mlflow # Bad - usi...
35
1,214
mlflow
dev/clint/tests/rules/test_redundant_mock_return_value.py
.py
from pathlib import Path import pytest from clint.config import Config from clint.index import SymbolIndex from clint.linter import lint_file from clint.rules.redundant_mock_return_value import RedundantMockReturnValue CONFIG = Config(select={RedundantMockReturnValue.name}) TEST_FILE = Path("test_foo.py") @pytest.m...
120
2,614
mlflow
dev/clint/tests/rules/test_isinstance_union_syntax.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import IsinstanceUnionSyntax def test_isinstance_union_syntax(index: SymbolIndex) -> None: code = """ # Bad - basic union syntax isinstance(obj, str | ...
45
1,189
mlflow
dev/clint/tests/rules/test_os_environ_set_in_test.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.os_environ_set_in_test import OsEnvironSetInTest def test_os_environ_set_in_test(index: SymbolIndex) -> None: code = """ import os # Bad def test_func...
26
714
mlflow
dev/clint/tests/rules/test_use_sys_executable.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules import UseSysExecutable def test_use_sys_executable(index: SymbolIndex) -> None: code = """ import subprocess import sys # Bad subprocess.run(["mlflow...
28
818
mlflow
dev/clint/tests/rules/test_pytest_mark_repeat.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.pytest_mark_repeat import PytestMarkRepeat def test_pytest_mark_repeat(index: SymbolIndex) -> None: code = """ import pytest @pytest.mark.repeat(10) d...
22
655
mlflow
dev/clint/tests/rules/test_unparameterized_generic_type.py
.py
from pathlib import Path from clint.config import Config from clint.index import SymbolIndex from clint.linter import Position, Range, lint_file from clint.rules.unparameterized_generic_type import UnparameterizedGenericType def test_unparameterized_generic_type(index: SymbolIndex) -> None: code = """ from typin...
47
1,473