How bluesky/bluesky-queueserver-api works
Project type and purpose
• This is a Python client‐library (“bluesky-queueserver-api”) that exposes a high-level API for interacting with a Bluesky Queue Server.
• The README calls it a “Python API for Bluesky Queue Server,” intended to let user code submit and control experiments in a remote or local queue server via multiple transport layers.
File structure
Top-level:
• blueky_queueserver_api/
– api_base.py, api_threads.py, api_async.py, api_docstrings.py
– comm_base.py, comm_threads.py, comm_async.py
– http/aio.py
– zmq/aio.py
– console_monitor.py
• tests/ under bluesky_queueserver_api/tests
• docs/ (Sphinx conf, .rst files)
• CI and lint config (.github/workflows, flake8, isort, pre-commit)
• packaging (setup.py, pyproject.toml, requirements*.txt)
Architectural clues:
– “api_*.py” modules define the public client interface
– “comm_*.py” modules define communication abstraction and implementations
– Under “http/” and “zmq/” are the asynchronous I/O specific transport implementations
– “api_threads.py” & “comm_threads.py” provide threaded‐mode transport
– “api_async.py” & “comm_async.py” provide asyncio‐based transport
README for additional insights
• The docs/ folder contains usage and API‐reference pages—good hints at core classes and modules.
Components and relationships
a. Main components
1. User code / Client application
2. API layer (api_base, api_threads, api_async)
3. Communication layer (comm_base, comm_threads, comm_async)
4. Transport implementations:
• Threaded transport (in-process)
• AsyncIO transport (in-process)
• HTTP transport (using aiohttp in http/aio.py)
• ZMQ transport (using zmq/aio.py)
5. Bluesky Queue Server (external service)
b. Relationships & interactions
• API layer calls into Communication layer
• Communication layer chooses a transport implementation
• Transport implementation sends/receives messages to/from the Queue Server
• Optionally, console_monitor monitors or logs queue server state
c. Architectural patterns & principles
• Layered architecture: clear separation of API vs. transport
• Dependency inversion: API layer depends on comm_base abstractions
• Strategy pattern: multiple transport strategies (threads, async, HTTP, ZMQ)
• Extensibility: new transports can plug into comm_base
d. Key technologies & libraries
• Python’s threading and asyncio libraries
• ZeroMQ (pyzmq) for zmq/aio.py
• aiohttp for HTTP transport
• Sphinx for docs, pytest for tests, versioneer for versioning