feat(resource): add deferred physical resource types
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 19s
CI / build (pull_request) Successful in 28s
CI / quality (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 42s
CI / security (pull_request) Successful in 52s
CI / unit_tests (pull_request) Successful in 3m23s
CI / integration_tests (pull_request) Successful in 3m37s
CI / docker (pull_request) Successful in 1m8s
CI / e2e_tests (pull_request) Successful in 5m26s
CI / coverage (pull_request) Successful in 8m7s
CI / benchmark-regression (pull_request) Successful in 38m7s
CI / benchmark-publish (pull_request) Has been skipped
CI / lint (pull_request) Successful in 19s
CI / build (pull_request) Successful in 28s
CI / quality (pull_request) Successful in 29s
CI / typecheck (pull_request) Successful in 42s
CI / security (pull_request) Successful in 52s
CI / unit_tests (pull_request) Successful in 3m23s
CI / integration_tests (pull_request) Successful in 3m37s
CI / docker (pull_request) Successful in 1m8s
CI / e2e_tests (pull_request) Successful in 5m26s
CI / coverage (pull_request) Successful in 8m7s
CI / benchmark-regression (pull_request) Successful in 38m7s
Add 11 deferred physical resource types covering the git object taxonomy (git, git-remote, git-branch, git-tag, git-commit, git-tree, git-tree-entry, git-stash, git-submodule) and filesystem link types (fs-symlink, fs-hardlink). - YAML configs under examples/resource-types/ - Bootstrap registration via _resource_registry_physical.py module - Auto-discovery rules with bounded scan_depth (1-2) for git object graph - fs-directory scan_depth=1 (immediate children only) - git-branch scan_depth=1 (single HEAD), git-tree scan_depth=2 (capped) - Updated fs-directory child_types/parent_types/auto_discovery - Updated git-checkout child_types to include git - Fixed git-tag child_types to include git-commit (DAG consistency) - Behave tests, Robot tests, ASV benchmarks - Documentation in docs/reference/resource_types_builtin.md ISSUES CLOSED: #330
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
"""ASV benchmarks for deferred physical resource type loading (#330)."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
_EXAMPLES_DIR = Path(__file__).resolve().parent.parent / "examples" / "resource-types"
|
||||
|
||||
_GIT_TAXONOMY_TYPES = (
|
||||
"git",
|
||||
"git-remote",
|
||||
"git-branch",
|
||||
"git-tag",
|
||||
"git-commit",
|
||||
"git-tree",
|
||||
"git-tree-entry",
|
||||
"git-stash",
|
||||
"git-submodule",
|
||||
)
|
||||
|
||||
_FS_LINK_TYPES = (
|
||||
"fs-symlink",
|
||||
"fs-hardlink",
|
||||
)
|
||||
|
||||
_ALL_DEFERRED_PHYSICAL = _GIT_TAXONOMY_TYPES + _FS_LINK_TYPES
|
||||
|
||||
|
||||
class TimeDeferredPhysicalYAMLLoad:
|
||||
"""Benchmark deferred physical resource type YAML loading."""
|
||||
|
||||
def setup(self) -> None:
|
||||
import yaml
|
||||
|
||||
from cleveragents.domain.models.core.resource_type import ResourceTypeSpec
|
||||
|
||||
self.spec_cls = ResourceTypeSpec
|
||||
self.configs: dict[str, dict[str, Any]] = {}
|
||||
for name in _ALL_DEFERRED_PHYSICAL:
|
||||
path = _EXAMPLES_DIR / f"{name}.yaml"
|
||||
with open(path) as f:
|
||||
self.configs[name] = yaml.safe_load(f)
|
||||
|
||||
def time_load_git_type(self) -> None:
|
||||
self.spec_cls.from_config(self.configs["git"])
|
||||
|
||||
def time_load_git_branch(self) -> None:
|
||||
self.spec_cls.from_config(self.configs["git-branch"])
|
||||
|
||||
def time_load_git_commit(self) -> None:
|
||||
self.spec_cls.from_config(self.configs["git-commit"])
|
||||
|
||||
def time_load_git_tree(self) -> None:
|
||||
self.spec_cls.from_config(self.configs["git-tree"])
|
||||
|
||||
def time_load_git_tree_entry(self) -> None:
|
||||
self.spec_cls.from_config(self.configs["git-tree-entry"])
|
||||
|
||||
def time_load_fs_symlink(self) -> None:
|
||||
self.spec_cls.from_config(self.configs["fs-symlink"])
|
||||
|
||||
def time_load_fs_hardlink(self) -> None:
|
||||
self.spec_cls.from_config(self.configs["fs-hardlink"])
|
||||
|
||||
def time_load_all_git_taxonomy(self) -> None:
|
||||
for name in _GIT_TAXONOMY_TYPES:
|
||||
self.spec_cls.from_config(self.configs[name])
|
||||
|
||||
def time_load_all_fs_links(self) -> None:
|
||||
for name in _FS_LINK_TYPES:
|
||||
self.spec_cls.from_config(self.configs[name])
|
||||
|
||||
def time_load_all_deferred_physical(self) -> None:
|
||||
for name in _ALL_DEFERRED_PHYSICAL:
|
||||
self.spec_cls.from_config(self.configs[name])
|
||||
|
||||
|
||||
class TimeDeferredPhysicalCliDict:
|
||||
"""Benchmark as_cli_dict rendering for deferred physical types."""
|
||||
|
||||
def setup(self) -> None:
|
||||
import yaml
|
||||
|
||||
from cleveragents.domain.models.core.resource_type import ResourceTypeSpec
|
||||
|
||||
self.specs: dict[str, Any] = {}
|
||||
for name in _ALL_DEFERRED_PHYSICAL:
|
||||
path = _EXAMPLES_DIR / f"{name}.yaml"
|
||||
with open(path) as f:
|
||||
config: dict[str, Any] = yaml.safe_load(f)
|
||||
self.specs[name] = ResourceTypeSpec.from_config(config)
|
||||
|
||||
def time_git_cli_dict(self) -> None:
|
||||
self.specs["git"].as_cli_dict()
|
||||
|
||||
def time_all_deferred_physical_cli_dict(self) -> None:
|
||||
for name in _ALL_DEFERRED_PHYSICAL:
|
||||
self.specs[name].as_cli_dict()
|
||||
|
||||
|
||||
class TimeBootstrapBuiltinTypes:
|
||||
"""Benchmark bootstrap_builtin_types() including deferred physical types."""
|
||||
|
||||
timeout = 120
|
||||
|
||||
def setup(self) -> None:
|
||||
from sqlalchemy import create_engine
|
||||
from sqlalchemy.orm import sessionmaker
|
||||
|
||||
from cleveragents.infrastructure.database.models import Base
|
||||
|
||||
self.engine = create_engine("sqlite:///:memory:")
|
||||
Base.metadata.create_all(self.engine)
|
||||
self.factory = sessionmaker(bind=self.engine)
|
||||
|
||||
def time_bootstrap(self) -> None:
|
||||
from cleveragents.application.services.resource_registry_service import (
|
||||
ResourceRegistryService,
|
||||
)
|
||||
|
||||
service = ResourceRegistryService(session_factory=self.factory)
|
||||
service.bootstrap_builtin_types()
|
||||
Reference in New Issue
Block a user