Skip to content

Conversation

@davidkopp
Copy link
Contributor

@davidkopp davidkopp commented Aug 19, 2025

Ich bin mir nicht sicher, wie die programmatische Schnittstelle (Python API) vom dependency-resolver am besten aussehen soll. Diese ist ja letztlich relevant für die Integration in GMT.

Bislang gibt es eine Funktions-basierte Schnittstelle. Ich habe Claude gebeten mal eine Klasse-basierte Schnittstelle zu erstellen. Ich finde eine Klasse zu haben irgendwie schöner, jedoch erscheint mir das jetzt doch zu over-engineered zu sein. Deshalb hier mal nur als Draft.

Claude meinte, dass die Funktionsbasierte Variante ausreichend ist, jedoch die Klassen-basierte Variante dann einen Mehrwert bringt, wenn die parallele Ausführung mehrerer Resolving-Aktivitäten eine Anforderung ist.
Parallelität ist für die GMT-Anforderung denke ich eine relevante Anforderung, jedoch könnte das auch GMT übernehmen.

Vergleich der Schnittstellen

Funktions-basiert

deps_dict = dependency_resolver.resolve_dependencies_as_dict(
    environment_type="docker",
    environment_identifier="nginx",
    skip_system_scope=True,
    working_dir="/app"
)

Klassen-basiert

Simpel

docker_resolver = DependencyResolver(
    environment_type="docker",
    skip_system_scope=True
)

docker_result = docker_resolver.resolve(
    environment_identifier="nginx",
    working_dir="/app"
)

Parallelität

docker_resolver = DependencyResolver(
    environment_type="docker",
    skip_system_scope=True
)

docker_requests = [
    ResolveRequest(environment_identifier="nginx", working_dir="/app"),
    ResolveRequest(environment_identifier="redis", working_dir="/data"),
    ResolveRequest(environment_identifier="postgres")
]

def progress_callback(completed, total, result):
    print(f"Progress: {completed}/{total} ({'✓' if result.success else '✗'})")

docker_results = docker_resolver.resolve_batch(
    docker_requests,
    progress_callback=progress_callback,
    fail_fast=False
)

davidkopp and others added 2 commits August 18, 2025 22:17
- Add new DependencyResolver class for advanced programmatic usage
- Implement parallel processing for multiple environments using ThreadPoolExecutor
- Add ResolveRequest and ResolveResult dataclasses for structured configuration
- Support progress tracking via optional callback functions
- Refactor venv_path from resolver-level to per-request configuration
- Add comprehensive test suite with 16 test cases covering all functionality
- Update README with detailed usage examples for all three interfaces:
  - Functional interface for simple operations
  - Class-based interface for parallel processing
  - Low-level interface for advanced control
- Maintain full backward compatibility with existing functional API

Key features:
- Batch resolution with configurable parallelism (max_workers)
- Per-request configuration (venv_path, working_dir, environment settings)
- Error handling with detailed result objects including execution time
- Multiple output formats (list of results, consolidated dictionary)
- Progress monitoring for long-running batch operations

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Move environment_type and only_container_info from per-request to per-class model while keeping environment_identifier per-request for flexibility:

- Environment type and container-specific options configured in DependencyResolver constructor
- Environment identifier passed per-request to enable batch processing of multiple containers/services
- ResolveRequest simplified to contain identifier, working directory, and detector options
- Added validation that only_container_info only works with docker environment
- Updated all usage sites including CLI, convenience functions, and tests
- Updated README.md documentation with better examples showing batch processing

This design correctly separates configuration concerns (per-class) from data concerns (per-request), enabling efficient analysis of multiple containers with the same resolver instance.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants