Skip to content

refactor: make client almost client again - #1666

Merged
ZohebShaikh merged 1 commit into
mainfrom
fix-dependencies
Nov 10, 2026
Merged

ZohebShaikh merged 1 commit into
mainfrom
fix-dependencies

Conversation

@ZohebShaikh

@ZohebShaikh ZohebShaikh commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

I'm trying to resolve this issue #1414

By the following changes

  • Make the client a thin client again (session/auth handling moved to
    client.session, environment handling to service.environment)
  • Move numtracker from utils to core

ie. Separating out what is client only and what is server only functionality

Once this is merged, I would like to go further in the split by doing the following:-

  1. Move setup-scratch to be server only
  2. Have a click interface for only the serve which can only run commands like serve, setup-scratch
  3. Move the bluesky, ophyd-async,event-model,opentelemetry-distro,observability-utils to server only
  4. Add import linter rules https://import-linter.readthedocs.io/en/v1.2.1/contract_types.html

@ZohebShaikh
ZohebShaikh requested a review from a team as a code owner September 10, 2026 17:39
@codecov

codecov Bot commented Sep 10, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.96970% with 7 lines in your changes missing coverage. Please review.
✅ Project coverage is 96.34%. Comparing base (4bb49a9) to head (79ab49f).

Files with missing lines Patch % Lines
src/blueapi/cli/cli.py 36.36% 7 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1666      +/-   ##
==========================================
- Coverage   96.47%   96.34%   -0.14%     
==========================================
  Files          49       51       +2     
  Lines        3804     3832      +28     
==========================================
+ Hits         3670     3692      +22     
- Misses        134      140       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Alexj9837 Alexj9837 self-assigned this Sep 11, 2026

@Alexj9837 Alexj9837 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

Comment thread src/blueapi/core/context.py Outdated

if (nt_conf := configuration.numtracker) is not None:
if configuration.env.metadata is not None:
from blueapi.service.numtracker import NumtrackerClient

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If we need to import it anyway, is there any real benefit to wrapping the initial import in the TYPE_CHECKING check?

I see the circular import error when importing the client eagerly. Were there other issues with numtracker being in the utils package instead of service? Lazy imports to avoid circular references feels like we're working around doing something wrong.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

numtracker is a server only thing so I do feel that it should be in the service module, The main problem with keeping numtracker in utils is cli also gets the httpx which is what I'm trying to avoid.

Comment thread pyproject.toml Resolved
@fajinyuan

Copy link
Copy Markdown
Contributor

@ZohebShaikh please address comments and conflicts raised here. Thank you.

@ZohebShaikh
ZohebShaikh force-pushed the fix-dependencies branch 2 times, most recently from cb7aa1d to a16e800 Compare November 2, 2026 12:31

@tpoliaw tpoliaw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is it possible to run the client tests without the server group being installed? With this set up, all development work and CI tests are going to have server dependencies available and I can see it being easy for the client to fail at runtime with a missing dependency.

Comment thread src/blueapi/service/__init__.py Resolved
Move FastAPI, aiohttp, graypy, httpx, tiled and related packages to
the optional `server` extra so the client can be installed without them.

Move session handling into blueapi.client.session, numtracker into
blueapi.service, and the Python environment code into
blueapi.service.environment. Update docs, the Dockerfile and tests.
@ZohebShaikh
ZohebShaikh added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit 7cf9bd8 Nov 10, 2026
19 checks passed
@ZohebShaikh
ZohebShaikh deleted the fix-dependencies branch November 10, 2026 18:17
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.

4 participants