Skip to content

fix: invalidate cached plans and devices on environment reload#1535

Closed
SAY-5 wants to merge 1 commit intoDiamondLightSource:mainfrom
SAY-5:fix/refresh-environment-cached-plans-1503
Closed

fix: invalidate cached plans and devices on environment reload#1535
SAY-5 wants to merge 1 commit intoDiamondLightSource:mainfrom
SAY-5:fix/refresh-environment-cached-plans-1503

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 5, 2026

Fixes #1503

Instructions to reviewer on how to test:

  1. Start a blueapi server, connect a client, and access bc.plans / bc.devices once to populate the caches.
  2. Modify the server-side plan/device modules (add or remove a plan/device) and call bc.reload_environment().
  3. Confirm bc.plans and bc.devices reflect the changes (newly added entries are present, removed entries are gone) without re-creating the client.

Checks for reviewer

  • Would the PR title make sense to a user on a set of release notes

reload_environment() did not invalidate the @cached_property values for plans and devices, so post-reload attribute access returned the pre-reload cache. Pop those entries from __dict__ after the teardown so the next access recomputes against the new environment. Added a unit test that primes both caches, calls reload_environment, and asserts the caches now reflect the new server state.

Closes DiamondLightSource#1503

reload_environment() previously left the @cached_property values for
plans and devices populated, so accessing them after a reload returned
the pre-reload data. Drop the cached entries from __dict__ so the next
access recomputes against the new environment.

Signed-off-by: SAY-5 <say.apm35@gmail.com>
@SAY-5 SAY-5 requested a review from a team as a code owner May 5, 2026 03:15
@tpoliaw
Copy link
Copy Markdown
Contributor

tpoliaw commented May 5, 2026

Duplicate of #1509

@tpoliaw tpoliaw marked this as a duplicate of #1509 May 5, 2026
@tpoliaw tpoliaw closed this May 5, 2026
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.

Refreshing the environment should refresh the cached plans

2 participants