Coverage for /opt/conda/envs/apienv/lib/python3.10/site-packages/daiquiri/core/components/tomo/slice_reconstruction_resource.py: 39%
23 statements
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
« prev ^ index » next coverage.py v7.6.5, created at 2024-11-15 02:12 +0000
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3import logging
4from marshmallow import fields
6from daiquiri.core import marshal
7from daiquiri.core.components import ComponentResource
8from daiquiri.core.schema import ErrorSchema
11logger = logging.getLogger(__name__)
14class SliceReconstructionResource(ComponentResource):
15 @marshal(
16 inp={
17 "datacollectionid": fields.Number(
18 metadata={"description": "Data collection id to process"}
19 ),
20 "axisposition": fields.Number(
21 metadata={"description": "Position of the axis, in pixel"}
22 ),
23 "deltabeta": fields.Number(
24 metadata={"description": "Delta/beta value for the reconstruction"}
25 ),
26 },
27 out=[
28 # [200, ScanDataSchema(), 'Scan data'],
29 [404, ErrorSchema(), "Data collection id is not available"]
30 ],
31 )
32 def get(
33 self,
34 datacollectionid=None,
35 axisposition=None,
36 deltabeta=None,
37 **kwargs,
38 ):
39 """Get a list of all available detectors and their info"""
40 if datacollectionid is None:
41 return {
42 "error": "Data collection id '%s' is not available" % datacollectionid
43 }, 404
45 tomo_component = self._parent
46 graph_name = "tomo-sinogram-reconstruction"
47 if deltabeta is not None:
48 tomo_component.set_last_delta_beta(deltabeta)
50 try:
51 celery = tomo_component.get_component("celery")
52 if celery:
53 celery.execute_graph(
54 graph_name,
55 datacollectionid,
56 parameters={"axisposition": axisposition, "deltabeta": deltabeta},
57 )
58 except Exception:
59 logger.error(
60 "Error while triggering '%s' workflow", graph_name, exc_info=True
61 )
62 return {
63 "error": f"Problem occurred during {graph_name} workflow triggering"
64 }, 404
65 return "OK", 200