sample_id stringlengths 21 196 | text stringlengths 105 936k | metadata dict | category stringclasses 6
values |
|---|---|---|---|
PrefectHQ/prefect:src/prefect/client/attribution.py | """
Attribution context for API requests.
This module provides functions to gather attribution headers that identify
the source of API requests (flow runs, deployments, workers) for usage tracking
and rate limit debugging.
"""
from __future__ import annotations
import os
from typing import TYPE_CHECKING
if TYPE_CHE... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/client/attribution.py",
"license": "Apache License 2.0",
"lines": 54,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/client/test_attribution.py | """
Tests for attribution headers functionality.
"""
import os
from unittest import mock
from uuid import uuid4
import httpx
from httpx import Request, Response
from prefect._internal.compatibility.starlette import status
from prefect.client.attribution import get_attribution_headers
from prefect.client.base import ... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/client/test_attribution.py",
"license": "Apache License 2.0",
"lines": 240,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/workers/test_worker_attribution.py | """
Tests for worker attribution environment variables.
"""
from unittest import mock
from uuid import uuid4
from prefect.workers.base import BaseJobConfiguration
class TestBaseAttributionEnvironment:
"""Tests for the _base_attribution_environment method."""
def test_returns_empty_dict_when_no_info(self):
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/workers/test_worker_attribution.py",
"license": "Apache License 2.0",
"lines": 154,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_experimental/bundles/_file_collector.py | """
File collection utilities for bundles.
This module provides the FileCollector class for collecting files matching
user-provided patterns from a base directory. Handles single files, directory
patterns, glob patterns, and negation patterns with gitignore-style matching.
"""
from __future__ import annotations
impo... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_experimental/bundles/_file_collector.py",
"license": "Apache License 2.0",
"lines": 498,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_experimental/bundles/_ignore_filter.py | """
Ignore filtering utilities for bundles.
This module provides the IgnoreFilter class for filtering collected files
through cascading .prefectignore patterns. It supports gitignore-style
pattern syntax and cascades patterns from project root and flow directory.
Key features:
- Cascading .prefectignore loading (proj... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_experimental/bundles/_ignore_filter.py",
"license": "Apache License 2.0",
"lines": 260,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/_experimental/bundles/_path_resolver.py | """
Path resolution and validation utilities for bundles.
This module provides functions for validating user-provided paths
before resolution and collection. Includes input validation (no filesystem
access) and symlink resolution with security checks.
"""
from __future__ import annotations
import errno
from dataclas... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_experimental/bundles/_path_resolver.py",
"license": "Apache License 2.0",
"lines": 467,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_experimental/bundles/_zip_builder.py | """
Zip archive builder for file bundles.
This module provides the ZipBuilder class for packaging collected files into a
sidecar zip archive with content-addressed storage key derivation using SHA256
hashes.
"""
from __future__ import annotations
import hashlib
import logging
import shutil
import tempfile
import zip... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_experimental/bundles/_zip_builder.py",
"license": "Apache License 2.0",
"lines": 150,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/_experimental/bundles/_zip_extractor.py | """
Zip archive extractor for file bundles.
This module provides the ZipExtractor class for extracting files from a
sidecar zip archive to the working directory before flow execution.
"""
from __future__ import annotations
__all__ = [
"ZipExtractor",
]
import logging
import zipfile
from pathlib import Path
log... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_experimental/bundles/_zip_extractor.py",
"license": "Apache License 2.0",
"lines": 113,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/_experimental/bundles/test_bundles.py | """Tests for SerializedBundle TypedDict with files_key field."""
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
class TestSerializedBundleFilesKey:
"""Tests for SerializedBundle files_key field."""
def test_serialized_bundle_accepts_files_key_none(self):
"""Serial... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_experimental/bundles/test_bundles.py",
"license": "Apache License 2.0",
"lines": 211,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_experimental/bundles/test_file_collector.py | """
Tests for FileCollector single file collection.
This module tests the FileCollector class's ability to collect single files
by pattern. Tests cover:
- Collecting existing single files
- Handling non-existent files (warning, no error)
- Directory traversal protection
- CollectionResult dataclass behavior
"""
from ... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_experimental/bundles/test_file_collector.py",
"license": "Apache License 2.0",
"lines": 1166,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_experimental/bundles/test_ignore_filter.py | """
Tests for IgnoreFilter class with .prefectignore support.
This module tests the IgnoreFilter class's ability to filter collected files
through cascading .prefectignore patterns. Tests cover:
- Basic pattern filtering (exclude matching files, preserve non-matching)
- Cascading .prefectignore from project root and f... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_experimental/bundles/test_ignore_filter.py",
"license": "Apache License 2.0",
"lines": 629,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_experimental/bundles/test_include_files_integration.py | """
End-to-end integration tests for include_files feature.
These tests verify the complete flow from @ecs(include_files=[...]) decorator
through bundle creation, upload, download, extraction, and flow execution.
"""
from __future__ import annotations
import json
import zipfile
from pathlib import Path
import pytes... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_experimental/bundles/test_include_files_integration.py",
"license": "Apache License 2.0",
"lines": 684,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_experimental/bundles/test_path_resolver.py | """
Tests for path resolution input validation and symlink handling.
This module tests the path validation functions in path_resolver.py.
Includes tests for input validation (no filesystem access) and
symlink resolution tests (uses tmp_path for filesystem operations).
"""
from __future__ import annotations
import pl... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_experimental/bundles/test_path_resolver.py",
"license": "Apache License 2.0",
"lines": 807,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_experimental/bundles/test_zip_builder.py | """
Tests for ZipBuilder class.
ZipBuilder packages collected files into a sidecar zip archive with
content-addressed storage key derivation using SHA256 hashes.
"""
from __future__ import annotations
import hashlib
import zipfile
from pathlib import Path
from unittest.mock import patch
import pytest
class TestZi... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_experimental/bundles/test_zip_builder.py",
"license": "Apache License 2.0",
"lines": 406,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_experimental/bundles/test_zip_extractor.py | """
Tests for ZipExtractor class.
ZipExtractor extracts files from a zip archive to the working directory,
preserving relative paths and handling overwrites with warnings.
"""
from __future__ import annotations
import zipfile
from pathlib import Path
import pytest
class TestZipExtractorImports:
"""Tests for m... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_experimental/bundles/test_zip_extractor.py",
"license": "Apache License 2.0",
"lines": 599,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-dbt/prefect_dbt/core/_manifest.py | """
Data structures and parser for dbt manifest.json files.
This module provides:
- DbtNode: Immutable representation of a dbt node
- ExecutionWave: A group of nodes that can execute in parallel
- ManifestParser: Parser for dbt manifest.json with dependency resolution
- resolve_selection: Resolve dbt selectors to node... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-dbt/prefect_dbt/core/_manifest.py",
"license": "Apache License 2.0",
"lines": 471,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/integrations/prefect-dbt/tests/core/test_manifest.py | """
Tests for DbtNode, ExecutionWave, and ManifestParser.
"""
import json
from pathlib import Path
from typing import Any
from unittest.mock import MagicMock, patch
import pytest
from dbt.artifacts.resources.types import NodeType
from prefect_dbt.core._manifest import (
DbtLsError,
DbtNode,
ExecutionWave,... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-dbt/tests/core/test_manifest.py",
"license": "Apache License 2.0",
"lines": 1026,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/cli/cloud/asset.py | """Manage Prefect Cloud assets."""
from __future__ import annotations
from typing import Annotated
import cyclopts
from rich.table import Table
import prefect.cli._app as _cli
from prefect.cli._cloud_utils import confirm_logged_in
from prefect.cli._utilities import (
exit_with_error,
exit_with_success,
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/cli/cloud/asset.py",
"license": "Apache License 2.0",
"lines": 122,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/cli/cloud/test_asset.py | import uuid
import httpx
import pytest
import readchar
import respx
from starlette import status
from tests.cli.cloud.test_cloud import gen_test_workspace
from prefect.client.schemas import Workspace
from prefect.context import use_profile
from prefect.settings import (
PREFECT_API_KEY,
PREFECT_API_URL,
P... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/cli/cloud/test_asset.py",
"license": "Apache License 2.0",
"lines": 252,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-gcp/tests/test_cloud_storage_async_dispatch.py | """Tests for async_dispatch migration in prefect-gcp cloud_storage.
These tests verify the critical behavior from issue #15008 where
@sync_compatible would incorrectly return coroutines in sync context.
"""
from io import BytesIO
from typing import Coroutine
import pytest
from prefect_gcp.cloud_storage import (
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-gcp/tests/test_cloud_storage_async_dispatch.py",
"license": "Apache License 2.0",
"lines": 458,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-gcp/tests/test_bigquery_async_dispatch.py | """Tests for async_dispatch migration in prefect-gcp bigquery.
These tests verify the critical behavior from issue #15008 where
@sync_compatible would incorrectly return coroutines in sync context.
"""
from typing import Coroutine
from unittest.mock import MagicMock
import pytest
from prefect_gcp.bigquery import (
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-gcp/tests/test_bigquery_async_dispatch.py",
"license": "Apache License 2.0",
"lines": 299,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-sqlalchemy/tests/test_async_dispatch.py | """Tests for the SqlAlchemyConnector class split.
These tests verify that SqlAlchemyConnector (sync) and AsyncSqlAlchemyConnector (async)
work correctly with their respective driver types.
"""
from typing import Coroutine
import pytest
from prefect_sqlalchemy.credentials import (
AsyncDriver,
ConnectionCompo... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-sqlalchemy/tests/test_async_dispatch.py",
"license": "Apache License 2.0",
"lines": 324,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-gcp/tests/test_secret_manager_async_dispatch.py | """Tests for async_dispatch migration in prefect-gcp secret_manager.
These tests verify the critical behavior from issue #15008 where
@sync_compatible would incorrectly return coroutines in sync context.
"""
from typing import Coroutine
import pytest
from prefect_gcp.secret_manager import (
GcpSecret,
acreat... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-gcp/tests/test_secret_manager_async_dispatch.py",
"license": "Apache License 2.0",
"lines": 208,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/server/orchestration/api/test_bulk_operations.py | """
Comprehensive tests for bulk operation endpoints.
These tests cover:
- Basic bulk operations
- Validation errors (limit bounds)
- Filter edge cases
- Verification of actual deletion
- Cascading deletes
- Mixed results for state changes
- Parameter validation
"""
from datetime import datetime, timedelta, timezone
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/server/orchestration/api/test_bulk_operations.py",
"license": "Apache License 2.0",
"lines": 1104,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_internal/analytics/ci_detection.py | """
CI environment detection for SDK telemetry.
Telemetry is automatically disabled in CI environments.
"""
import os
# Common CI environment variables
CI_ENV_VARS = frozenset(
{
"CI",
"GITHUB_ACTIONS",
"GITLAB_CI",
"JENKINS_URL",
"TRAVIS",
"CIRCLECI",
"BUI... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/ci_detection.py",
"license": "Apache License 2.0",
"lines": 33,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:src/prefect/_internal/analytics/client.py | """
Amplitude client wrapper for SDK telemetry.
Provides fire-and-forget event tracking with silent failure handling.
"""
import atexit
import logging
import platform
from typing import Any
from amplitude import Amplitude, BaseEvent, Config
import prefect
# Amplitude API key for SDK telemetry
# This is a write-onl... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/client.py",
"license": "Apache License 2.0",
"lines": 102,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_internal/analytics/device_id.py | """
Device ID generation and persistence for SDK telemetry.
The device ID is an anonymous identifier used to correlate events
from the same installation without identifying the user.
"""
import os
from pathlib import Path
from uuid import uuid4
from prefect.settings import get_current_settings
def _get_device_id_p... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/device_id.py",
"license": "Apache License 2.0",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:src/prefect/_internal/analytics/emit.py | """
Event emission for SDK analytics.
"""
import sys
from typing import Any
from prefect._internal.analytics.device_id import get_or_create_device_id
from prefect._internal.analytics.events import SDKEvent
from prefect._internal.analytics.service import AnalyticsEvent, AnalyticsService
def _is_interactive_terminal(... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/emit.py",
"license": "Apache License 2.0",
"lines": 73,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_internal/analytics/enabled.py | """
Telemetry enabled check for SDK analytics.
"""
import os
from prefect._internal.analytics.ci_detection import is_ci_environment
def is_telemetry_enabled() -> bool:
"""
Quick non-blocking check of local telemetry settings.
Telemetry is disabled if:
- DO_NOT_TRACK environment variable is set (cli... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/enabled.py",
"license": "Apache License 2.0",
"lines": 24,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/_internal/analytics/events.py | """
Event type definitions for SDK telemetry.
"""
from typing import Literal
# Quick Start Funnel events
SDKEvent = Literal[
"first_sdk_import",
"first_flow_defined",
"first_flow_run",
"first_deployment_created",
"first_schedule_created",
]
| {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/events.py",
"license": "Apache License 2.0",
"lines": 12,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:src/prefect/_internal/analytics/milestones.py | """
Milestone tracking for SDK telemetry.
Tracks first-* events to avoid duplicate telemetry.
Milestones are stored in $PREFECT_HOME/.sdk_telemetry/milestones.json
For existing users (detected by presence of Prefect artifacts), all milestones
are pre-marked as reached to avoid emitting onboarding events on upgrade.
"... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/milestones.py",
"license": "Apache License 2.0",
"lines": 133,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_internal/analytics/notice.py | """
First-run telemetry notice for SDK telemetry.
Displays a notice to users the first time telemetry is enabled,
but only in interactive terminal sessions.
"""
import sys
from pathlib import Path
from prefect._internal.analytics.emit import _is_interactive_terminal
from prefect.settings import get_current_settings
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/notice.py",
"license": "Apache License 2.0",
"lines": 45,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/_internal/analytics/service.py | """
Background analytics service for non-blocking event processing.
This module provides a singleton service that receives analytics events via a queue
and processes them in a background thread. The server analytics check is performed
once per process, off the main thread.
"""
import atexit
import os
import queue
imp... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/analytics/service.py",
"license": "Apache License 2.0",
"lines": 193,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/_internal/analytics/test_ci_detection.py | """
Tests for CI environment detection.
"""
import pytest
class TestCIDetection:
"""Test CI environment detection."""
def test_not_ci_by_default(self, monkeypatch: pytest.MonkeyPatch):
"""Should not detect CI when no CI variables are set."""
# Clear all known CI variables
from prefec... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/analytics/test_ci_detection.py",
"license": "Apache License 2.0",
"lines": 56,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_internal/analytics/test_client.py | """
Tests for Amplitude client wrapper.
"""
from pathlib import Path
from unittest.mock import MagicMock, patch
class TestAmplitudeClient:
"""Test Amplitude client behavior."""
def test_event_properties_include_version(self, clean_telemetry_state: Path):
"""Event properties should include Prefect ve... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/analytics/test_client.py",
"license": "Apache License 2.0",
"lines": 97,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_internal/analytics/test_device_id.py | """
Tests for device ID generation and persistence.
"""
import uuid
from pathlib import Path
import pytest
class TestDeviceID:
"""Test device ID generation and persistence."""
def test_generates_uuid(self, clean_telemetry_state: Path):
"""Should generate a valid UUID."""
from prefect._inter... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/analytics/test_device_id.py",
"license": "Apache License 2.0",
"lines": 48,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_internal/analytics/test_events.py | """
Tests for SDK analytics event emission.
"""
from pathlib import Path
from unittest.mock import MagicMock, patch
import pytest
from prefect._internal.analytics import emit_integration_event
from prefect._internal.analytics.service import AnalyticsEvent
class TestEventEmission:
"""Test event emission via emi... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/analytics/test_events.py",
"license": "Apache License 2.0",
"lines": 270,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_internal/analytics/test_milestones.py | """
Tests for milestone tracking.
"""
import json
from pathlib import Path
from unittest.mock import patch
class TestMilestones:
"""Test milestone tracking."""
def test_milestone_not_reached_initially(self, clean_telemetry_state: Path):
"""Milestones should not be reached initially."""
from ... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/analytics/test_milestones.py",
"license": "Apache License 2.0",
"lines": 162,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_internal/analytics/test_notice.py | """
Tests for telemetry notice display.
"""
from pathlib import Path
from unittest.mock import patch
class TestTelemetryNotice:
"""Test telemetry notice display."""
def test_notice_shown_in_tty(self, clean_telemetry_state: Path, capsys):
"""Notice should be shown in TTY."""
with patch("sys.s... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/analytics/test_notice.py",
"license": "Apache License 2.0",
"lines": 52,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_internal/analytics/test_service.py | """
Tests for the background analytics service.
"""
import time
from pathlib import Path
from unittest.mock import patch
import pytest
from prefect._internal.analytics.service import AnalyticsEvent, AnalyticsService
class TestAnalyticsService:
"""Test AnalyticsService behavior."""
def test_singleton_insta... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/analytics/test_service.py",
"license": "Apache License 2.0",
"lines": 345,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-kubernetes/tests/test_async_dispatch.py | """Tests for async_dispatch migration in prefect-kubernetes.
These tests verify the critical behavior from issue #15008 where
@sync_compatible would incorrectly return coroutines in sync context.
"""
from typing import Coroutine
import pytest
from prefect_kubernetes.jobs import KubernetesJob, KubernetesJobRun
from ... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-kubernetes/tests/test_async_dispatch.py",
"license": "Apache License 2.0",
"lines": 137,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-shell/tests/test_async_dispatch.py | """Tests for async_dispatch migration in prefect-shell.
These tests verify the critical behavior from issue #15008 where
@sync_compatible would incorrectly return coroutines in sync context.
"""
import sys
from typing import Coroutine
import pytest
from prefect_shell.commands import ShellOperation, ShellProcess
fro... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-shell/tests/test_async_dispatch.py",
"license": "Apache License 2.0",
"lines": 158,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_internal/compatibility/backports.py | """Functionality we want to use from later Python versions."""
try:
import tomllib # 3.11+
except ImportError:
import toml as tomllib # fallback on Python <3.11
tomllib.TOMLDecodeError = tomllib.TomlDecodeError
__all__ = ["tomllib"]
| {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/compatibility/backports.py",
"license": "Apache License 2.0",
"lines": 7,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:tests/_internal/compatibility/test_backports.py | import sys
import pytest
from prefect._internal.compatibility.backports import tomllib
min_python_version = (3, 11)
@pytest.fixture(scope="session")
def toml1_0_content() -> str:
return """\
[dependency-groups]
dev = [
"dummy-dependency~=1.2.0",
{include-group = "dummy-group-name"},
]
"""
@pytest.mar... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/compatibility/test_backports.py",
"license": "Apache License 2.0",
"lines": 26,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_internal/urls.py | from urllib.parse import urlparse, urlunparse
def strip_auth_from_url(url: str) -> str:
"""
Remove authentication credentials (username/password) from a URL.
Useful for sanitizing URLs before including them in error messages
or logs to avoid leaking secrets.
"""
parsed = urlparse(url)
if... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/urls.py",
"license": "Apache License 2.0",
"lines": 23,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:tests/_internal/test_urls.py | import pytest
from prefect._internal.urls import strip_auth_from_url
@pytest.mark.parametrize(
"url,expected",
[
# URL with username and password
(
"https://user:pass@github.com/org/repo.git",
"https://github.com/org/repo.git",
),
# URL with only token ... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/test_urls.py",
"license": "Apache License 2.0",
"lines": 47,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/testing/test_fixtures.py | """
Tests for prefect.testing.fixtures module.
"""
import subprocess
from contextlib import asynccontextmanager
from unittest import mock
import pytest
from prefect.testing import fixtures
class TestHostedApiServerWindowsProcessHandling:
"""Tests for Windows-specific process handling in hosted_api_server fixtu... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/testing/test_fixtures.py",
"license": "Apache License 2.0",
"lines": 123,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/client/schemas/test_deployments.py | from __future__ import annotations
from prefect.client.schemas.objects import DeploymentStatus
from prefect.client.schemas.responses import DeploymentResponse
def test_deployment_response_accepts_disabled_status():
"""DeploymentResponse accepts DISABLED status for Cloud compatibility."""
response = Deploymen... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/client/schemas/test_deployments.py",
"license": "Apache License 2.0",
"lines": 14,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/cli/sdk.py | """
SDK command — native cyclopts implementation.
Generate typed Python SDK from workspace deployments.
"""
from pathlib import Path
from typing import Annotated, Optional
import cyclopts
import prefect.cli._app as _cli
from prefect.cli._utilities import (
exit_with_error,
exit_with_success,
with_cli_ex... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/cli/sdk.py",
"license": "Apache License 2.0",
"lines": 130,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/cli/test_sdk.py | """Tests for the SDK CLI command."""
from __future__ import annotations
import ast
from pathlib import Path
from typing import Any
from unittest.mock import AsyncMock, MagicMock, patch
from uuid import uuid4
# Eagerly import modules that are mock.patch targets. Without this, the
# autouse reset_sys_modules fixture c... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/cli/test_sdk.py",
"license": "Apache License 2.0",
"lines": 491,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/server/api/test_docket_task_keys.py | """
Tests for docket task keys in API handlers.
These tests verify that API handlers use consistent, deterministic task keys when
scheduling background docket tasks. Task keys ensure at-most-once execution semantics,
preventing duplicate task execution when multiple API servers process the same request.
See: https://... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/server/api/test_docket_task_keys.py",
"license": "Apache License 2.0",
"lines": 328,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_sdk/fetcher.py | """
SDK data fetcher module.
This module is responsible for fetching deployment and work pool data from the
Prefect API and converting it to the internal data models used by the SDK generator.
"""
from __future__ import annotations
import asyncio
from dataclasses import dataclass, field
from datetime import datetime... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/fetcher.py",
"license": "Apache License 2.0",
"lines": 381,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_sdk/generator.py | """
SDK generator module.
This module orchestrates the SDK generation process, combining data fetching
from the Prefect API with template rendering to produce the final SDK file.
"""
from __future__ import annotations
from dataclasses import dataclass, field
from pathlib import Path
from typing import TYPE_CHECKING
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/generator.py",
"license": "Apache License 2.0",
"lines": 116,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:tests/_sdk/test_fetcher.py | """Tests for the SDK fetcher module."""
from __future__ import annotations
from typing import Any
from unittest.mock import AsyncMock, MagicMock
from uuid import UUID, uuid4
import pytest
from prefect._sdk.fetcher import (
APIConnectionError,
AuthenticationError,
FetchResult,
NoDeploymentsError,
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_fetcher.py",
"license": "Apache License 2.0",
"lines": 462,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_generator.py | """Tests for the SDK generator module."""
from __future__ import annotations
import ast
from pathlib import Path
from typing import Any
from unittest.mock import AsyncMock, MagicMock
from uuid import uuid4
import pytest
from prefect._sdk.generator import (
APIConnectionError,
AuthenticationError,
Genera... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_generator.py",
"license": "Apache License 2.0",
"lines": 321,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_sdk/renderer.py | """
SDK renderer module.
This module is responsible for converting SDKData into template-friendly
context and rendering the Jinja2 template to produce the final SDK file.
"""
import importlib.resources
from dataclasses import dataclass, field
from pathlib import Path
from typing import Any
import jinja2
from prefec... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/renderer.py",
"license": "Apache License 2.0",
"lines": 396,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/_sdk/test_renderer.py | """Tests for the SDK renderer module."""
import ast
import tempfile
from pathlib import Path
from prefect._sdk.models import (
DeploymentInfo,
FlowInfo,
SDKData,
SDKGenerationMetadata,
WorkPoolInfo,
)
from prefect._sdk.renderer import (
JobVariableContext,
RenderResult,
WorkPoolContext... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_renderer.py",
"license": "Apache License 2.0",
"lines": 703,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_sdk/models.py | """
Data models for SDK generation.
This module contains the internal data models used to represent workspace data
fetched from the Prefect API, which are then passed to the template renderer.
Note: These models are internal to SDK generation and not part of the public API.
"""
from dataclasses import dataclass, fie... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/models.py",
"license": "Apache License 2.0",
"lines": 107,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/_sdk/naming.py | """
Naming utilities for SDK generation.
This module converts arbitrary names (deployment names, flow names, work pool names)
to valid Python identifiers and class names.
Conversion rules for identifiers:
1. Normalize Unicode to ASCII where possible (é -> e via NFKD decomposition)
2. Treat Unicode separators/punctuat... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/naming.py",
"license": "Apache License 2.0",
"lines": 290,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:tests/_sdk/test_models.py | """Tests for SDK generation data models."""
from prefect._sdk.models import (
DeploymentInfo,
FlowInfo,
SDKData,
SDKGenerationMetadata,
WorkPoolInfo,
)
class TestWorkPoolInfo:
"""Test WorkPoolInfo data model."""
def test_basic_creation(self):
wp = WorkPoolInfo(
name="... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_models.py",
"license": "Apache License 2.0",
"lines": 354,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_naming.py | """Tests for naming utilities."""
from prefect._sdk.naming import (
PYTHON_KEYWORDS,
RESERVED_DEPLOYMENT_IDENTIFIERS,
RESERVED_FLOW_IDENTIFIERS,
get_reserved_names,
make_unique_class_name,
make_unique_identifier,
safe_class_name,
safe_identifier,
to_class_name,
to_identifier,
)
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_naming.py",
"license": "Apache License 2.0",
"lines": 372,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_sdk/schema_converter.py | """
JSON Schema to Python type conversion for SDK generation.
This module converts JSON Schema definitions (like those from Pydantic models)
to Python type annotation strings suitable for TypedDict field definitions.
Limitations:
- allOf: Returns the first $ref or non-Any type. Intersection semantics
(combi... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/schema_converter.py",
"license": "Apache License 2.0",
"lines": 351,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_sdk/types.py | """
Core types for SDK generation.
This module contains the data classes and exceptions used across the SDK
generation modules.
"""
from dataclasses import dataclass, field
from typing import Any
@dataclass
class ConversionContext:
"""Context for schema conversion, tracking definitions and visited refs."""
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/types.py",
"license": "Apache License 2.0",
"lines": 34,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/_sdk/unions.py | """
Union type utilities for SDK generation.
This module provides bracket and quote-aware union type handling.
"""
def split_union_top_level(type_str: str) -> list[str]:
"""
Split a union type string on " | " only at the top level.
This is bracket and quote-aware, so it won't split inside:
- Bracket... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_sdk/unions.py",
"license": "Apache License 2.0",
"lines": 102,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/_sdk/test_schema_converter_complex.py | """Tests for complex schemas, unknown types, and edge cases."""
from prefect._sdk.schema_converter import (
ConversionContext,
json_schema_to_python_type,
)
class TestComplexSchemas:
"""Test complex real-world schema patterns."""
def test_pydantic_v2_optional_pattern(self):
"""Pydantic v2 op... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_schema_converter_complex.py",
"license": "Apache License 2.0",
"lines": 73,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_schema_converter_enums.py | """Tests for enum and tuple type conversion in JSON Schema."""
from prefect._sdk.schema_converter import json_schema_to_python_type
class TestEnumTypes:
"""Test conversion of enum types to Literal."""
def test_string_enum(self):
schema = {"enum": ["A", "B", "C"], "type": "string"}
assert jso... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_schema_converter_enums.py",
"license": "Apache License 2.0",
"lines": 84,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_schema_converter_fields.py | """Tests for extracting field information from JSON Schema."""
from prefect._sdk.schema_converter import extract_fields_from_schema
class TestExtractFieldsFromSchema:
"""Test extracting field information from schemas."""
def test_simple_fields(self):
schema = {
"type": "object",
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_schema_converter_fields.py",
"license": "Apache License 2.0",
"lines": 103,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_schema_converter_primitives.py | """Tests for primitive and basic JSON Schema type conversion."""
from prefect._sdk.schema_converter import json_schema_to_python_type
class TestPrimitiveTypes:
"""Test conversion of primitive JSON Schema types."""
def test_string(self):
assert json_schema_to_python_type({"type": "string"}) == "str"
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_schema_converter_primitives.py",
"license": "Apache License 2.0",
"lines": 86,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_schema_converter_refs.py | """Tests for $ref resolution and allOf handling in JSON Schema."""
import pytest
from prefect._sdk.schema_converter import (
CircularReferenceError,
ConversionContext,
json_schema_to_python_type,
)
class TestReferenceResolution:
"""Test $ref resolution."""
def test_simple_ref(self):
con... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_schema_converter_refs.py",
"license": "Apache License 2.0",
"lines": 120,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_schema_converter_unions.py | """Tests for union type conversion in JSON Schema."""
from prefect._sdk.schema_converter import json_schema_to_python_type
class TestNullableTypes:
"""Test conversion of nullable (anyOf with null) types."""
def test_nullable_string(self):
schema = {"anyOf": [{"type": "string"}, {"type": "null"}]}
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_schema_converter_unions.py",
"license": "Apache License 2.0",
"lines": 159,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_sdk/test_union_utils.py | """Tests for union utility functions."""
from prefect._sdk.unions import split_union_top_level
class TestSplitUnionTopLevel:
"""Test the split_union_top_level helper function directly."""
def test_simple_union(self):
"""Simple union should split correctly."""
assert split_union_top_level("st... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_sdk/test_union_utils.py",
"license": "Apache License 2.0",
"lines": 49,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:examples/resume_flow_run_on_pr_merge.py | # ---
# title: Resume Flow Run on PR Merge
# description: Automatically resume failed flow runs when a hotfix PR is merged in GitHub.
# icon: github
# keywords: ["github", "webhooks", "automations", "ci-cd", "retry", "resume"]
# ---
#
# <Note>
# This example uses [webhooks](/v3/automate/events/webhooks), which are only... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "examples/resume_flow_run_on_pr_merge.py",
"license": "Apache License 2.0",
"lines": 114,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:tests/events/jinja_filters/test_flow_run_id.py | from prefect.server.events.jinja_filters import flow_run_id
def test_flow_run_id_extraction():
url = "https://app.prefect.cloud/account/abc/workspace/xyz/runs/flow-run/12345678-1234-5678-1234-567812345678"
body = f"Fixes {url}"
assert flow_run_id(body) == "12345678-1234-5678-1234-567812345678"
def test_... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/events/jinja_filters/test_flow_run_id.py",
"license": "Apache License 2.0",
"lines": 10,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/client/test_state_serialization.py | """
Tests for state serialization, specifically around the defer_build=True
behavior in PrefectBaseModel that can cause MockValSer errors.
Regression test for: TypeError: 'MockValSer' object cannot be converted to 'SchemaSerializer'
Root cause: PrefectBaseModel has defer_build=True, and when FlowRun.model_validate()
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/client/test_state_serialization.py",
"license": "Apache License 2.0",
"lines": 129,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_internal/send_entrypoint_logs.py | """
Internal utility for sending error logs to Prefect from the entrypoint.
Usage:
python -m prefect._internal.send_entrypoint_logs < /tmp/output.log
python -m prefect._internal.send_entrypoint_logs /tmp/output.log
Reads PREFECT__FLOW_RUN_ID from environment. Exits silently on failure.
"""
import logging
imp... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/send_entrypoint_logs.py",
"license": "Apache License 2.0",
"lines": 47,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:tests/_internal/test_send_entrypoint_logs.py | import logging
import subprocess
import sys
from unittest.mock import MagicMock, patch
from uuid import UUID
from prefect._internal.send_entrypoint_logs import _send, main
class TestSend:
def test_creates_error_log_with_flow_run_id(self):
mock_client = MagicMock()
flow_run_id = UUID("12345678-123... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/test_send_entrypoint_logs.py",
"license": "Apache License 2.0",
"lines": 103,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:scripts/generate_prefect_yaml_schema.py | import json
from pydantic.json_schema import GenerateJsonSchema
from prefect import __development_base_path__
from prefect.cli.deploy._models import PrefectYamlModel
class PrefectYamlGenerateJsonSchema(GenerateJsonSchema):
def generate(self, schema, mode="validation"):
json_schema = super().generate(sch... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "scripts/generate_prefect_yaml_schema.py",
"license": "Apache License 2.0",
"lines": 26,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:tests/cli/deploy/test_prefect_yaml_schema.py | """Tests for the prefect.yaml JSON schema generation."""
import json
import uuid
import pytest
from jsonschema import Draft202012Validator, ValidationError, validate
from prefect import __development_base_path__
from prefect.cli.deploy._models import PrefectYamlModel
@pytest.fixture
def schema():
"""Load the g... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/cli/deploy/test_prefect_yaml_schema.py",
"license": "Apache License 2.0",
"lines": 100,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/integrations/prefect-aws/prefect_aws/assume_role_parameters.py | """Module handling Assume Role parameters"""
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
from prefect_aws.utilities import hash_collection
class AssumeRoleParameters(BaseModel):
"""
Model used to manage parameters for the AWS STS assume_role call.
Refer to the
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-aws/prefect_aws/assume_role_parameters.py",
"license": "Apache License 2.0",
"lines": 142,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/integrations/prefect-aws/tests/test_assume_role_parameters.py | from typing import Any, Dict
import pytest
from prefect_aws.assume_role_parameters import AssumeRoleParameters
class TestAssumeRoleParameters:
@pytest.mark.parametrize(
"params,result",
[
(AssumeRoleParameters(), {}),
(
AssumeRoleParameters(
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-aws/tests/test_assume_role_parameters.py",
"license": "Apache License 2.0",
"lines": 220,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/server/orchestration/test_validate_deployment_concurrency_at_running.py | """
Tests for the ValidateDeploymentConcurrencyAtRunning orchestration rule.
"""
import contextlib
import datetime
from uuid import UUID, uuid4
from sqlalchemy.ext.asyncio import AsyncSession
import prefect.server.models as models
import prefect.server.schemas as schemas
from prefect.server.concurrency.lease_storage... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/server/orchestration/test_validate_deployment_concurrency_at_running.py",
"license": "Apache License 2.0",
"lines": 536,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
... | test |
PrefectHQ/prefect:src/integrations/prefect-aws/prefect_aws/plugins.py | from __future__ import annotations
import ssl
from typing import Any, Mapping
import boto3
import sqlalchemy as sa
from prefect._experimental.plugins import register_hook
from prefect_aws.settings import AwsSettings
@register_hook
def set_database_connection_params(
connection_url: str, settings: Any
) -> Mapp... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-aws/prefect_aws/plugins.py",
"license": "Apache License 2.0",
"lines": 33,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:src/integrations/prefect-aws/tests/test_plugins.py | import ssl
from unittest.mock import MagicMock
import pytest
from prefect_aws.plugins import set_database_connection_params
@pytest.fixture
def mock_boto3_session(monkeypatch):
mock_session = MagicMock()
monkeypatch.setattr("boto3.Session", MagicMock(return_value=mock_session))
return mock_session
@pyt... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/integrations/prefect-aws/tests/test_plugins.py",
"license": "Apache License 2.0",
"lines": 80,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/server/services/perpetual_services.py | """
Perpetual services are background services that run on a periodic schedule using docket.
This module provides the registry and scheduling logic for perpetual services,
using docket's Perpetual dependency for distributed, HA-aware task scheduling.
"""
from __future__ import annotations
import logging
from datacla... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/server/services/perpetual_services.py",
"license": "Apache License 2.0",
"lines": 132,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/server/services/test_perpetual_services.py | """Tests for the perpetual services registry and scheduling."""
from prefect.server.services.perpetual_services import (
_PERPETUAL_SERVICES,
get_enabled_perpetual_services,
get_perpetual_services,
)
def test_db_vacuum_service_registered():
"""Test that db vacuum perpetual service is registered."""
... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/server/services/test_perpetual_services.py",
"license": "Apache License 2.0",
"lines": 162,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/client/schemas/test_concurrency.py | """Tests for concurrency schema validation."""
import pytest
from pydantic import ValidationError
from prefect.client.schemas.objects import ConcurrencyLimitConfig, ConcurrencyOptions
class TestConcurrencyOptionsValidation:
"""Tests for ConcurrencyOptions grace_period_seconds validation."""
def test_grace_... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/client/schemas/test_concurrency.py",
"license": "Apache License 2.0",
"lines": 94,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_states.py | """
Private module containing sync versions of state functions.
These functions are used internally by the sync task engine to avoid
run_coro_as_sync overhead on Windows.
"""
from __future__ import annotations
import datetime
import sys
import uuid
from types import GeneratorType
from typing import TYPE_CHECKING, An... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_states.py",
"license": "Apache License 2.0",
"lines": 263,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:examples/per_worker_task_concurrency.py | # ---
# title: Per-worker task concurrency
# description: Use Global Concurrency Limits to control how many tasks can use a worker's local resources simultaneously.
# icon: layer-group
# dependencies: ["prefect"]
# keywords: ["concurrency", "workers", "advanced"]
# draft: false
# ---
#
# When a worker runs multiple flo... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "examples/per_worker_task_concurrency.py",
"license": "Apache License 2.0",
"lines": 179,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:examples/ai_database_cleanup_with_approval.py | # ---
# title: Database Cleanup with Human or AI Approval
# description: Build database cleanup workflows that evolve from human oversight to AI autonomy.
# icon: database
# keywords: ["ai", "agents", "pydantic-ai", "database-maintenance", "cleanup", "automation", "approval-workflow", "mcp"]
# github_url: https://githu... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "examples/ai_database_cleanup_with_approval.py",
"license": "Apache License 2.0",
"lines": 235,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:tests/concurrency/test_concurrency_slot_acquisition_with_lease_service.py | """Tests for ConcurrencySlotAcquisitionWithLeaseService."""
import asyncio
from concurrent.futures import Future
from typing import Any
from unittest import mock
from uuid import uuid4
import pytest
from httpx import HTTPStatusError, Request, Response
from prefect.client.orchestration import PrefectClient, get_clien... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/concurrency/test_concurrency_slot_acquisition_with_lease_service.py",
"license": "Apache License 2.0",
"lines": 401,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/client/orchestration/_events/client.py | from typing import TYPE_CHECKING
from prefect.client.orchestration.base import BaseAsyncClient, BaseClient
from prefect.client.schemas.events import EventPage
if TYPE_CHECKING:
from prefect.events.filters import EventFilter
class EventClient(BaseClient):
def read_events(
self,
filter: "Event... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/client/orchestration/_events/client.py",
"license": "Apache License 2.0",
"lines": 73,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/client/schemas/events.py | from typing import TYPE_CHECKING
from pydantic import AnyHttpUrl, Field
from prefect._internal.schemas.bases import PrefectBaseModel
from prefect.events.schemas.events import ReceivedEvent
if TYPE_CHECKING:
from prefect.client.orchestration import PrefectClient, SyncPrefectClient
class EventPage(PrefectBaseMod... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/client/schemas/events.py",
"license": "Apache License 2.0",
"lines": 35,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:tests/client/test_events_client.py | from datetime import timedelta
from typing import TYPE_CHECKING
import prefect.types._datetime
from prefect.client.orchestration import get_client
from prefect.events.filters import EventFilter, EventOccurredFilter
if TYPE_CHECKING:
from prefect.testing.utilities import PrefectTestHarness
class TestReadEventsAs... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/client/test_events_client.py",
"license": "Apache License 2.0",
"lines": 145,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:src/prefect/_internal/observability.py | """
internal module for configuring observability tooling (logfire, etc.)
"""
from typing import Any
from pydantic import Field
from pydantic_settings import BaseSettings, SettingsConfigDict
class LogfireSettings(BaseSettings):
"""
configuration for logfire observability integration.
"""
model_conf... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/observability.py",
"license": "Apache License 2.0",
"lines": 77,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_complex |
PrefectHQ/prefect:src/prefect/_internal/testing.py | """Testing utilities for internal use."""
import asyncio
from typing import Any, AsyncIterator
from typing_extensions import Self
class AssertionRetryAttempt:
"""Context manager for capturing exceptions during retry attempts."""
def __init__(self, attempt_number: int):
self.attempt_number = attempt... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/testing.py",
"license": "Apache License 2.0",
"lines": 52,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:src/prefect/server/api/background_workers.py | import asyncio
from contextlib import asynccontextmanager
from logging import Logger
from typing import Any, AsyncGenerator, Callable
from docket import Docket, Worker
from prefect.logging import get_logger
from prefect.server.api.flow_runs import delete_flow_run_logs
from prefect.server.api.task_runs import delete_t... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/server/api/background_workers.py",
"license": "Apache License 2.0",
"lines": 76,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:src/prefect/settings/models/server/docket.py | from typing import ClassVar
from pydantic import Field
from pydantic_settings import SettingsConfigDict
from prefect.settings.base import PrefectBaseSettings, build_settings_config
class ServerDocketSettings(PrefectBaseSettings):
"""
Settings for controlling Docket behavior
"""
model_config: ClassV... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/settings/models/server/docket.py",
"license": "Apache License 2.0",
"lines": 19,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | function_simple |
PrefectHQ/prefect:src/prefect/_internal/lazy.py | """Utilities for lazy-loading module-level objects."""
from typing import Callable, Generic, TypeVar
K = TypeVar("K")
V = TypeVar("V")
class LazyDict(Generic[K, V]):
"""
A dictionary-like object that defers loading its contents until first access.
Useful for module-level registries that import heavy de... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "src/prefect/_internal/lazy.py",
"license": "Apache License 2.0",
"lines": 36,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | documentation |
PrefectHQ/prefect:tests/_internal/test_lazy.py | import pytest
from prefect._internal.lazy import LazyDict
def test_lazy_dict_defers_loading():
"""LazyDict should not call loader function on initialization."""
call_count = 0
def loader() -> dict[str, int]:
nonlocal call_count
call_count += 1
return {"a": 1, "b": 2}
_lazy =... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/test_lazy.py",
"license": "Apache License 2.0",
"lines": 42,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
PrefectHQ/prefect:tests/_internal/schemas/test_v2_schema.py | import inspect
from pydantic import Field
from pydantic_core import PydanticUndefined
from prefect._internal.pydantic.v2_schema import process_v2_params
class TestProcessV2Params:
"""Test the process_v2_params functions with and without FieldInfo."""
def test_process_v2_params_with_existing_fieldinfo(self)... | {
"repo_id": "PrefectHQ/prefect",
"file_path": "tests/_internal/schemas/test_v2_schema.py",
"license": "Apache License 2.0",
"lines": 91,
"canary_id": -1,
"canary_value": "",
"pii_type": "",
"provider": "",
"regex_pattern": "",
"repetition": -1,
"template": ""
} | test |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.