-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal configuration for inserting documents into Tiled #755
base: main
Are you sure you want to change the base?
Changes from 5 commits
b7cbcfc
5561e0d
21e80e0
7f3e707
f3767e1
e9406e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,6 +13,10 @@ classifiers = [ | |
] | ||
description = "Lightweight bluesky-as-a-service wrapper application. Also usable as a library." | ||
dependencies = [ | ||
"tiled", | ||
"json_merge_patch", | ||
"jsonpatch", | ||
"pyarrow", | ||
"bluesky>=1.13", | ||
"ophyd", | ||
"nslsii", | ||
|
@@ -95,7 +99,8 @@ addopts = """ | |
--ignore=src/blueapi/startup | ||
""" | ||
# https://iscinumpy.gitlab.io/post/bound-version-constraints/#watch-for-warnings | ||
filterwarnings = ["error", "ignore::DeprecationWarning"] | ||
# Unignore UserWarning after Pydantic warning removed from bluesky/bluesky and release | ||
filterwarnings = ["error", "ignore::DeprecationWarning", "ignore::UserWarning"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any way to only ignore warnings from the tests in question? Otherwise we may end up removing this in a few months time only to find the tests blowing up in a bunch of other places? |
||
# Doctest python code in docs, python code in src docstrings, test functions in tests | ||
testpaths = "docs src tests" | ||
asyncio_mode = "auto" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,15 @@ class StompConfig(BaseModel): | |
auth: BasicAuthentication | None = None | ||
|
||
|
||
class TiledConfig(BaseModel): | ||
""" | ||
Config for connecting to a tiled instance | ||
""" | ||
|
||
uri: str | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could: Can we use separate |
||
api_key: str | ||
|
||
|
||
class WorkerEventConfig(BlueapiBaseModel): | ||
""" | ||
Config for event broadcasting via the message bus | ||
|
@@ -160,6 +169,7 @@ class ApplicationConfig(BlueapiBaseModel): | |
""" | ||
|
||
stomp: StompConfig | None = None | ||
tiled: TiledConfig | None = None | ||
env: EnvironmentConfig = Field(default_factory=EnvironmentConfig) | ||
logging: LoggingConfig = Field(default_factory=LoggingConfig) | ||
api: RestConfig = Field(default_factory=RestConfig) | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,10 +3,12 @@ | |||||
from functools import cache | ||||||
from typing import Any | ||||||
|
||||||
from bluesky.callbacks.tiled_writer import TiledWriter | ||||||
from bluesky_stomp.messaging import StompClient | ||||||
from bluesky_stomp.models import Broker, DestinationBase, MessageTopic | ||||||
from tiled.client import from_uri | ||||||
|
||||||
from blueapi.config import ApplicationConfig, OIDCConfig, StompConfig | ||||||
from blueapi.config import ApplicationConfig, OIDCConfig, StompConfig, TiledConfig | ||||||
from blueapi.core.context import BlueskyContext | ||||||
from blueapi.core.event import EventStream | ||||||
from blueapi.service.model import DeviceModel, PlanModel, WorkerTask | ||||||
|
@@ -48,6 +50,19 @@ | |||||
return worker | ||||||
|
||||||
|
||||||
@cache | ||||||
def tiled_inserter(): | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should:
Suggested change
...or whatever it's called |
||||||
tiled_config: TiledConfig | None = config().tiled | ||||||
if tiled_config is not None: | ||||||
client = from_uri(tiled_config.uri, api_key=tiled_config.api_key) | ||||||
|
||||||
ctx = context() | ||||||
ctx.run_engine.subscribe(TiledWriter(client)) | ||||||
return client | ||||||
else: | ||||||
return None | ||||||
|
||||||
|
||||||
@cache | ||||||
def stomp_client() -> StompClient | None: | ||||||
stomp_config: StompConfig | None = config().stomp | ||||||
|
@@ -86,6 +101,7 @@ | |||||
logging.basicConfig(format="%(asctime)s - %(message)s", level=config.logging.level) | ||||||
worker() | ||||||
stomp_client() | ||||||
tiled_inserter() | ||||||
|
||||||
|
||||||
def teardown() -> None: | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bluesky/bluesky#1867
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should: Include issue link in a comment in the file