Skip to content

Remove backends information and get it from httomo-backends instead #532

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

Merged
merged 14 commits into from
Jan 17, 2025
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion .github/workflows/run_tests_iris.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ jobs:
run: |
micromamba activate httomo
pip install --upgrade --force-reinstall pillow
pip install httomolibgpu tomobar httomo-backends
pip install httomolibgpu tomobar
pip install --no-deps httomo-backends
pip install .
micromamba list

Expand Down
22 changes: 8 additions & 14 deletions docs/source/howto/process_lists/process_list_configure.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,20 +47,14 @@ The pattern of any supported method can be found in :ref:`pl_library`.
Library files
-------------

Here is the list of library files for backends where patterns and other fixed arguments for methods are specified. When HTTomo operates
with a certain method it always refers to its library file in order get the specific requirements for that method.

.. dropdown:: TomoPy's library file

.. literalinclude:: ../../../../httomo/methods_database/packages/external/tomopy/tomopy.yaml

.. dropdown:: Httomolibgpu's library file

.. literalinclude:: ../../../../httomo/methods_database/packages/external/httomolibgpu/httomolibgpu.yaml

.. dropdown:: Httomolib's library file

.. literalinclude:: ../../../../httomo/methods_database/packages/external/httomolib/httomolib.yaml
In order for HTTomo to execute a method it requires certain information about the method, such
as its pattern, and (if it's a GPU method) the amount of GPU memory required per-slice. HTTomo
uses a package called :code:`httomo-backends` to get this information.

See the `httomo-backends
<https://diamondlightsource.github.io/httomo-backends/backends/method_info.html>`_
documentation for more details on how it provides the required information through "library
files" and "supporting functions".

.. _pl_grouping:

Expand Down
168 changes: 0 additions & 168 deletions httomo/cufft.py

This file was deleted.

4 changes: 3 additions & 1 deletion httomo/loaders/standard_tomo_loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
from httomo.runner.dataset_store_interfaces import DataSetSource
from httomo.runner.loader import LoaderInterface
from httomo.types import generic_array
from httomo.utils import Pattern, log_once, make_3d_shape_from_shape
from httomo.utils import log_once, make_3d_shape_from_shape

from httomo_backends.methods_database.query import Pattern


class StandardTomoLoader(DataSetSource):
Expand Down
25 changes: 22 additions & 3 deletions httomo/method_wrappers/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,15 +394,15 @@ def calculate_output_dims(
"""Calculate the dimensions of the output for this method"""
if self.output_dims_change:
return self._query.calculate_output_dims(
non_slice_dims_shape, **self.config_params
non_slice_dims_shape, **self._unwrap_output_ref_values()
)

return non_slice_dims_shape

def calculate_padding(self) -> Tuple[int, int]:
"""Calculate the padding required by the method"""
if self.padding:
return self._query.calculate_padding(**self.config_params)
return self._query.calculate_padding(**self._unwrap_output_ref_values())
return (0, 0)

def calculate_max_slices(
Expand Down Expand Up @@ -449,7 +449,7 @@ def calculate_max_slices(
memory_bytes_method,
subtract_bytes,
) = self._query.calculate_memory_bytes(
non_slice_dims_shape, data_dtype, **self.config_params
non_slice_dims_shape, data_dtype, **self._unwrap_output_ref_values()
)

if memory_bytes_method == 0:
Expand All @@ -458,3 +458,22 @@ def calculate_max_slices(
return (
available_memory - subtract_bytes
) // memory_bytes_method, available_memory

def _unwrap_output_ref_values(self) -> Dict[str, Any]:
"""
Iterate through params in `self.config_params` and, for any value of type `OutputRef`,
extract the value inside the `OutputRef`.

Returns
-------
Dict[str, Any]
A dict containing all parameters in `self.config_params`, but with any `OutputRef`
values replaced with the value inside the `OutputRef`.
"""
params = dict()
for name, value in self.config_params.items():
if isinstance(value, OutputRef):
params[name] = value.value
continue
params[name] = value
return params
2 changes: 1 addition & 1 deletion httomo/method_wrappers/reconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from typing import Any, Dict, Optional

from httomo.utils import Pattern
from httomo_backends.methods_database.query import Pattern


class ReconstructionWrapper(GenericMethodWrapper):
Expand Down
4 changes: 3 additions & 1 deletion httomo/method_wrappers/rotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
from httomo.method_wrappers.generic import GenericMethodWrapper
from httomo.runner.method_wrapper import MethodParameterDictType
from httomo.runner.methods_repository_interface import MethodRepository
from httomo.utils import Pattern, catchtime, log_once, xp
from httomo.utils import catchtime, log_once, xp

from httomo_backends.methods_database.query import Pattern


import numpy as np
Expand Down
Empty file.
Empty file.
Empty file.
Empty file.
34 changes: 0 additions & 34 deletions httomo/methods_database/packages/external/httomolib/httomolib.yaml

This file was deleted.

This file was deleted.

Empty file.
Loading
Loading