Skip to content

Conversation

@joaomariolago
Copy link
Collaborator

@joaomariolago joaomariolago commented Sep 4, 2025

Fix #3523

  • Move from pykson with custom directory to new settings implementation using pydantic

Summary by Sourcery

Migrate the bridget service settings from a custom pykson-based implementation to Pydantic models and the PydanticSettings framework, consolidate legacy migration logic, and standardize settings storage to the standard user config path using a service name constant.

Enhancements:

  • Replace pykson.JsonObject specs and custom BaseSettings with Pydantic BaseModel and PydanticSettings subclasses for SettingsV1 and SettingsV2
  • Introduce migrate_from_old_settings and on_settings_created hooks to automatically migrate legacy v1 and v2 JSON settings files
  • Standardize settings directory by using a SERVICE_NAME constant and remove the hardcoded USERDATA path in Manager initialization
  • Add a new config module to define SERVICE_NAME for consistent configuration across the service

* Move from pykson with custom directory to new settings implementation
  using pydantic
@sourcery-ai
Copy link

sourcery-ai bot commented Sep 4, 2025

Reviewer's Guide

Migrates the Bridget service settings from a custom pykson-based system to a PydanticSettings-backed implementation, refactors versioned specs and settings classes, introduces a shared migration helper, and updates service initialization to use a standardized SERVICE_NAME configuration.

File-Level Changes

Change Details Files
Convert pykson-based spec classes to Pydantic models
  • Replaced JsonObject-based BridgeSettingsSpecV1/V2 with Pydantic BaseModel definitions
  • Updated field annotations and removed pykson imports
core/services/bridget/settings.py
Refactor SettingsV1 and SettingsV2 to extend PydanticSettings
  • Changed inheritance from custom BaseSettings to PydanticSettings
  • Replaced VERSION constants with STATIC_VERSION and updated migrate signatures
  • Added on_settings_created hooks for post-creation migration
core/services/bridget/settings.py
Add generic legacy migration helper
  • Introduced migrate_from_old_settings to load and parse legacy JSON files
  • Integrated helper into on_settings_created for both versions
core/services/bridget/settings.py
Standardize service configuration and Manager usage
  • Created config.py to define SERVICE_NAME
  • Removed custom USERDATA path and updated Manager init in bridget.py to use SERVICE_NAME
core/services/bridget/bridget.py
core/services/bridget/config.py

Assessment against linked issues

Issue Objective Addressed Explanation
#3523 Change Bridget service to save its settings at /root/.config/blueos/bridget/ instead of /usr/blueos/userdata/settings/bridget/bridget/.
#3523 Migrate existing settings from the old location (/usr/blueos/userdata/settings/bridget/bridget/) to the new location (/root/.config/blueos/bridget/) and ensure backward compatibility.
#3523 Ensure migration occurs before service initialization and that permissions/ownership are correct after moving the folder.

Possibly linked issues


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

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.

Bridget service saves settings in the wrong location

1 participant