Skip to content
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

fix: configure_kafka_publisher assumed a string #209

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions nslsii/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,10 @@ def configure_base(
ipython_logging : boolean, optional
True by default. Console output and exception stack traces will be
written to IPython log file when IPython logging is enabled.
publish_documents_with_kafka: boolean, optional
publish_documents_with_kafka: Union[boolean, str], optional
False by default. If True publish bluesky documents to a Kafka message broker using
configuration parameters read from a file.
configuration parameters read from a file. If bool used, the Kafka topic is auto-configured if the
broker_name is a string. If a string is used, it will override the TLA for the auto-configured topic.
tb_minimize : boolean, optional
If IPython should print out 'minimal' tracebacks.

Expand Down Expand Up @@ -223,7 +224,15 @@ def configure_base(
configure_ipython_logging(exception_logger=log_exception, ipython=ipython)

if publish_documents_with_kafka:
configure_kafka_publisher(RE, beamline_name=broker_name)
if isinstance(publish_documents_with_kafka, str):
configure_kafka_publisher(RE, beamline_name=publish_documents_with_kafka)
elif hasattr(broker_name, "name"):
configure_kafka_publisher(RE, beamline_name=broker_name.name)
elif isinstance(broker_name, str):
configure_kafka_publisher(RE, beamline_name=broker_name)
else:
raise ValueError("If broker_name is not a string and lacks a name attribute, "
"publish_documents_with_kafka must be a string")

if tb_minimize and ipython:
# configure %xmode minimal
Expand Down
Loading