DiamondLightSource / httomo

High-throughput tomography pipeline
https://diamondlightsource.github.io/httomo/
Other
7 stars 4 forks source link

Revaluate whether `StandardLoaderWrapper` is needed or not #504

Open yousefmoazzam opened 1 month ago

yousefmoazzam commented 1 month ago

TL;DR

Details

The Pipeline object represents the loader and methods in the pipeline. In particular, for the loader, it requires anything that implements the LoaderInterface protocol: https://github.com/DiamondLightSource/httomo/blob/f6bb8aca8a4fb10cce5dd55c94dff2d0f1d77325/httomo/runner/pipeline.py#L12-L14

When the UI layer creates a Pipeline object, it creates an implementor of LoaderInterface by using the make_loader() function (which could be viewed as a factory function for implementors of LoaderInterface): https://github.com/DiamondLightSource/httomo/blob/f6bb8aca8a4fb10cce5dd55c94dff2d0f1d77325/httomo/ui_layer.py#L143-L159

The task runner then uses the make_data_source() method defined on the LoaderInterface protocol to generate an implementor of DataSetSource: https://github.com/DiamondLightSource/httomo/blob/f6bb8aca8a4fb10cce5dd55c94dff2d0f1d77325/httomo/runner/task_runner.py#L226

Now, the way that StandardLoaderWrapper implements LoaderInterface is mostly by using the StandardTomoLoader.global_shape getter: https://github.com/DiamondLightSource/httomo/blob/f6bb8aca8a4fb10cce5dd55c94dff2d0f1d77325/httomo/loaders/standard_tomo_loader.py#L394-L421

Note that the three property getters:

are simply using StandardTomoLoader.global_shape, and that the make_data_source() method is implemented simply by creating a StandardTomoLoader instance.

What this means is that:

Lastly, the make_loader() factory function could then simply create instances that implement both:

and the runner would be able to get a data source without needing to use an intermediate "loader wrapper class" to generate a data source.

I think this could possibly make the "way" that the runner gets access to a data source simpler, and easier to understand, by getting rid of a layer in the generation of data source.