Open gfabbris opened 4 days ago
Funny. Was just looking at this situation today. Not sure if there is a standard way. Here's what I'd do. In short:
if iconfig.get("NEXUS_DATA_FILES", False):
from .nexus_data_file_writer import * # noqa
if iconfig.get("SPEC_DATA_FILES", False):
from .spec_data_file_writer import * # noqa
RE
callback subscriptions require a bit of consideration. They need the RE
object already defined, and they need the callback defined as configured by the instrument. Because of these factors, it seems easiest to import any configured callbacks from the instrument/callbacks/__init__.py
file, as shown above.
BTW, we're working on an overhaul of the instrument template for APS beamlines. We have two propositions now:
This demo uses a re-arranged iconfig.yml
file.
Using a version number to keep track.
# identify the version of this iconfig.yml file
ICONFIG_VERSION: 2.0.0
Don't subscribe callbacks in collection
. Instead, do it in callbacks/__init__.py
. If you have iconfig
settings, apply them as shown above.
With the new iconfig.yml
keys, that code example (above) needs revision:
if iconfig.get("NEXUS_DATA_FILES") is not None:
from .nexus_data_file_writer import * # noqa
if iconfig.get("SPEC_DATA_FILES") is not None:
from .spec_data_file_writer import * # noqa
Sounds good. I like the organization of your prototype, will try to migrate it to that.
We have a duplicated specwriter
RE
subscription during startup:https://github.com/APS-4ID-POLAR/polar_instrument/blob/19dad53865917db7f0526ec42823c97040078ac4/instrument/collection.py#L130
https://github.com/APS-4ID-POLAR/polar_instrument/blob/19dad53865917db7f0526ec42823c97040078ac4/instrument/framework/callbacks.py#L32
@prjemian: This is a detail, but is there any "standard practice" for where to have this?