Skip to content

Conversation

@joaomariolago
Copy link
Collaborator

@joaomariolago joaomariolago commented Dec 19, 2025

Fix #3253
Closes #3276

Summary by Sourcery

Migrate the Kraken service into the secondary Python virtual environment and update its dependency stack accordingly.

Enhancements:

  • Update Kraken service runtime dependencies to newer, compatible versions including FastAPI, Pydantic, aiohttp, and related libraries.
  • Adjust Kraken manifest models to use Pydantic v2-style RootModel and validation APIs.
  • Simplify type handling in Docker-related helpers by removing redundant casts and using explicit type annotations.

Build:

  • Move Kraken from the primary core workspace into the python-venv2 environment, updating workspace membership and dependency wiring.
  • Relax and align commonwealth library constraints on psutil, pydantic, and add packaging to support the updated dependency set.

Summary by Sourcery

Migrate the Kraken service into the secondary Python virtual environment and refresh its dependency stack to align with shared library constraints and newer frameworks.

Enhancements:

  • Update Kraken service runtime dependencies (FastAPI, Pydantic, aiohttp, uvicorn and related libraries) to newer, compatible versions.
  • Adjust Kraken manifest models and validation usage to Pydantic v2 APIs and RootModel semantics.
  • Simplify Docker helper typing by removing unnecessary casts and clarifying type annotations.

Build:

  • Move Kraken from the primary core workspace into the python-venv2 environment and wire it into that workspace configuration.
  • Relax and align commonwealth dependency constraints for psutil, pydantic, and add packaging to support the updated dependency set.

@sourcery-ai
Copy link

sourcery-ai bot commented Dec 19, 2025

Reviewer's Guide

Migrates the Kraken service into the secondary python-venv2 workspace and modernizes its dependency stack (notably FastAPI/Pydantic), including manifest model updates and minor Docker helper cleanups, while relaxing commonwealth’s dependency constraints to match.

Sequence diagram for updated manifest fetch and validation using ManifestData.model_validate

sequenceDiagram
    participant KrakenManifestService
    participant aiohttpClientSession as aiohttp_ClientSession
    participant RemoteManifestServer
    participant ManifestData

    KrakenManifestService->>aiohttpClientSession: get(url)
    aiohttpClientSession->>RemoteManifestServer: HTTP GET /manifest
    RemoteManifestServer-->>aiohttpClientSession: JSON manifest payload
    aiohttpClientSession-->>KrakenManifestService: resp

    KrakenManifestService->>aiohttpClientSession: resp.json(content_type=None)
    aiohttpClientSession-->>KrakenManifestService: raw_manifest_data

    KrakenManifestService->>ManifestData: model_validate(raw_manifest_data)
    ManifestData-->>KrakenManifestService: manifest_data_instance

    KrakenManifestService->>KrakenManifestService: entries = manifest_data_instance.root
Loading

Class diagram for updated Kraken manifest models with Pydantic v2 RootModel

classDiagram
    class BaseModel
    class RootModel~List_RepositoryEntry~{
    }

    class ExtensionMetadata{
    }

    class RepositoryEntry{
    }

    class ManifestData{
    }

    ExtensionMetadata <|-- RepositoryEntry
    RootModel~List_RepositoryEntry~ <|-- ManifestData

    note for ManifestData "Pydantic v1 style: class ManifestData(BaseModel) with __root__ List[RepositoryEntry] replaced by Pydantic v2 style: class ManifestData(RootModel[List[RepositoryEntry]])"
Loading

File-Level Changes

Change Details Files
Update Kraken service dependencies to newer versions compatible with python-venv2 and modern FastAPI/Pydantic.
  • Bump core runtime libraries such as aiocache, aiodocker, aiohttp, fastapi, fastapi-versioning, loguru, psutil, pydantic, semver, and uvicorn to newer versions.
  • Align Kraken’s pydantic requirement with v2 (2.12.5) to match the shared environment.
  • Remove explicit workspace source for commonwealth from Kraken’s pyproject since resolution now happens via the venv2 workspace.
core/services/kraken/pyproject.toml
Move Kraken from the primary core workspace into the python-venv2 workspace and wire it as a dependency there instead of in core.
  • Remove kraken from core’s direct dependencies and from the core workspace members while adding it to the workspace exclude list.
  • Add kraken as a dependency and workspace member of python-venv2, and wire kraken as a workspace source in the venv2 config.
  • Regenerate uv.lock files for core and python-venv2 plus adjust start-blueos-core script to reflect the environment layout changes.
core/pyproject.toml
core/python-venv2/pyproject.toml
core/python-venv2/uv.lock
core/uv.lock
core/start-blueos-core
Adapt Kraken’s manifest models and manifest loading to Pydantic v2 APIs.
  • Refactor ManifestData from a custom BaseModel with root to a Pydantic v2 RootModel[List[RepositoryEntry]].
  • Switch manifest JSON parsing from ManifestData.parse_obj(...) to ManifestData.model_validate(...), and access parsed entries via .root instead of .root.
  • Keep other manifest models intact, relying on the updated Pydantic version for validation.
core/services/kraken/manifest/models.py
core/services/kraken/manifest/manifest.py
Relax and expand commonwealth’s dependency constraints to support the updated global stack.
  • Allow psutil to range between 5.7.2 and 7.1.3 instead of requiring a single pinned version.
  • Add packaging as a new dependency with a broad version range to support version handling.
  • Permit Pydantic to be either 1.10.12 up to 2.12.5, enabling shared usage of Pydantic v2 in venv2.
core/libs/commonwealth/pyproject.toml
Simplify Docker-related helper type handling in Kraken to better match actual return types and reduce redundant casts.
  • Treat Docker image inspection result as a Dict[str, Any] via explicit variable annotation instead of cast(...).
  • Return DockerContainer instances directly from container listing without an unnecessary cast in harbor.container.get_raw_container_by_name.
core/services/kraken/extension/extension.py
core/services/kraken/harbor/container.py

Assessment against linked issues

Issue Objective Addressed Explanation
#3253 Fix the Kraken service’s slowly growing RAM usage (memory leak) observed over long uptimes on idle systems.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@joaomariolago joaomariolago marked this pull request as ready for review December 19, 2025 14:55
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@joaomariolago joaomariolago force-pushed the update-kraken-dependencies branch from 34e19e2 to 66355ad Compare December 19, 2025 15:03
@joaomariolago joaomariolago force-pushed the update-kraken-dependencies branch from 66355ad to 93c3a37 Compare December 19, 2025 15:14
@patrickelectric patrickelectric merged commit 94b3f88 into bluerobotics:master Dec 19, 2025
6 checks passed
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.

[Kraken] Slowly growing RAM usage

2 participants