Add .edf and .gb (General Binary) adapters for ALS BL7.3.3#4
Add .edf and .gb (General Binary) adapters for ALS BL7.3.3#4dylanmcreynolds merged 25 commits intomainfrom
.edf and .gb (General Binary) adapters for ALS BL7.3.3#4Conversation
|
Can you please add an |
|
The |
|
Sorry, misread the structure in an IDE that flattens empty dirs. I like the adapters and exporters packages |
…ient]>=0.2.8` a core dependency in `pyproject.toml`
Otherwise test CI fails with missing module error
|
Since the initial review comments the following changes were made:
|
|
Some additional notes: This builds on previous work in mlexchange/workflow-viz, in particular also mlexchange/workflow-viz/pull/2 by @rajasriramoju
|
dylanmcreynolds
left a comment
There was a problem hiding this comment.
I left a comment about logging that is pretty unimportant, happy to merge without.
| **kwargs: Optional[Any], | ||
| ) -> None: | ||
| """Adapter for a stitched detector image .gb produced at ALS beamline 7.3.3.""" | ||
| filepath_gb = path_from_uri(data_uri) |
There was a problem hiding this comment.
I think I'd like to used the unused logger here to printout what file is being processed.
There was a problem hiding this comment.
Added a logger.debug call.
tests/test_main.py
Outdated
| @@ -1,2 +1,2 @@ | |||
| def test_main_function(): | |||
| def test_main_function() -> None: | |||
There was a problem hiding this comment.
What an important Type hint :) . Perhaps we should remove this file.
src/als_tiled/bl733/adapters/edf.py
Outdated
| ) -> None: | ||
| """Adapter for `.edf` files (e.g. PILATUS3 2M) at ALS beamline 7.3.3.""" | ||
| filepath = path_from_uri(data_uri) | ||
| logger.debug("Loading EDF file produced by ALS beamline 7.3.3: %s", filepath) |
There was a problem hiding this comment.
This might be silly optimization, but what if we define the string in the module and only replace it here?
Also, there so reason to replace the string if debug level isn't set. What about
if logger.getEffectiveLevel(logging.DEBUG):
logger.debug(LOADING_MESSAGE, filepath)I wouldn't bother but I think this is code that gets called a lot of times in a server.
There was a problem hiding this comment.
Constants sound like a good idea, I moved the strings to module-level LOADING_MESSAGE for both edf and gb.
For the getEffectiveLevel check: Logging is already doing lazy evaluation for string replacement guarded by isEnabledFor. That type of check seems to be mostly recommended when the calculating the string to be replaces is expensive (according to https://docs.python.org/3/howto/logging.html#optimization). Since we're just passing filepath here, I would think we are fine without the extra guard?
as `LOADING_MESSAGE` constants
|
Closes #1. |
Builds on the initial adapter skeleton to add two working file adapters for the PILATUS 2M detector at beamline 7.3.3:
EDFAdapter: reads.edfimage files viafabio, merging EDF header fields with metadata from a companion .txt fileGeneralBinaryPilatus2MAdapter: reads stitched.gbfloat32 images, combining metadata from paired _hi and _lo EDF companions; selects the later acquisition dateBoth adapters subclass
ArrayAdapter.Includes round-trip integration tests (register, then read via tiled client) and unit tests for metadata parsing and merging logic. Test fixtures use synthetic data derived from real example files, with PI names anonymized.
Requires
pip install ".[bl733]"for fabio.To use the example config, populate a folder
.datawith.edf.gband compainion.edffiles and run:and
Some considerations:
.txtand.edffiles are not registered as explicit data sources. This simplifies registration as a single file can serve as the "trigger" to register a scan and no custom detection of mimetime is needed, as the file ending directly translated to the mimetype). This does mean that built-in download capabilities in Tiled will not include these additional files. We have two option to make native download possible: A custom exporter that exports the full set of side-car, or switching to combined mimetypes (edf+txt), (gb+2txt+2edf). test_image_file_with_sidecar_metadata_fileArrayAdapter(e.g. bluesky/tiled/adapters/jpeg.py) orAdapter[ArrayStructure](e.g. bluesky/tiled/adapters/npy.py. I chooseArrayAdapterasAdapter[ArrayStructure]versions seem to be earmarked for refactoring, see Adapter Rationalisation bluesky/tiled#1066