cryoemservices 0.1.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. cryoemservices-0.1.3/LICENSE +28 -0
  2. cryoemservices-0.1.3/PKG-INFO +156 -0
  3. cryoemservices-0.1.3/README.md +120 -0
  4. cryoemservices-0.1.3/pyproject.toml +6 -0
  5. cryoemservices-0.1.3/setup.cfg +100 -0
  6. cryoemservices-0.1.3/setup.py +9 -0
  7. cryoemservices-0.1.3/src/cryoemservices/__init__.py +3 -0
  8. cryoemservices-0.1.3/src/cryoemservices/cli/__init__.py +0 -0
  9. cryoemservices-0.1.3/src/cryoemservices/cli/resubmit_wrapper.py +51 -0
  10. cryoemservices-0.1.3/src/cryoemservices/pipeliner_plugins/__init__.py +0 -0
  11. cryoemservices-0.1.3/src/cryoemservices/pipeliner_plugins/combine_star_files.py +251 -0
  12. cryoemservices-0.1.3/src/cryoemservices/pipeliner_plugins/combine_star_job.py +155 -0
  13. cryoemservices-0.1.3/src/cryoemservices/services/__init__.py +0 -0
  14. cryoemservices-0.1.3/src/cryoemservices/services/cluster_submission.py +229 -0
  15. cryoemservices-0.1.3/src/cryoemservices/services/cryolo.py +414 -0
  16. cryoemservices-0.1.3/src/cryoemservices/services/ctffind.py +331 -0
  17. cryoemservices-0.1.3/src/cryoemservices/services/denoise_iris.py +317 -0
  18. cryoemservices-0.1.3/src/cryoemservices/services/extract.py +439 -0
  19. cryoemservices-0.1.3/src/cryoemservices/services/icebreaker.py +344 -0
  20. cryoemservices-0.1.3/src/cryoemservices/services/images.py +102 -0
  21. cryoemservices-0.1.3/src/cryoemservices/services/images_plugins.py +283 -0
  22. cryoemservices-0.1.3/src/cryoemservices/services/ispyb.py +1085 -0
  23. cryoemservices-0.1.3/src/cryoemservices/services/ispyb_buffer.py +102 -0
  24. cryoemservices-0.1.3/src/cryoemservices/services/motioncorr.py +680 -0
  25. cryoemservices-0.1.3/src/cryoemservices/services/motioncorr_slurm.py +323 -0
  26. cryoemservices-0.1.3/src/cryoemservices/services/node_creator.py +373 -0
  27. cryoemservices-0.1.3/src/cryoemservices/services/select_classes.py +528 -0
  28. cryoemservices-0.1.3/src/cryoemservices/services/select_particles.py +303 -0
  29. cryoemservices-0.1.3/src/cryoemservices/services/tomo_align.py +614 -0
  30. cryoemservices-0.1.3/src/cryoemservices/services/tomo_align_iris.py +219 -0
  31. cryoemservices-0.1.3/src/cryoemservices/util/__init__.py +0 -0
  32. cryoemservices-0.1.3/src/cryoemservices/util/dispatcher_tools.py +234 -0
  33. cryoemservices-0.1.3/src/cryoemservices/util/spa_output_files.py +387 -0
  34. cryoemservices-0.1.3/src/cryoemservices/util/spa_relion_service_options.py +279 -0
  35. cryoemservices-0.1.3/src/cryoemservices/wrappers/__init__.py +0 -0
  36. cryoemservices-0.1.3/src/cryoemservices/wrappers/class2d_wrapper.py +373 -0
  37. cryoemservices-0.1.3/src/cryoemservices/wrappers/class3d_wrapper.py +527 -0
  38. cryoemservices-0.1.3/src/cryoemservices.egg-info/PKG-INFO +156 -0
  39. cryoemservices-0.1.3/src/cryoemservices.egg-info/SOURCES.txt +43 -0
  40. cryoemservices-0.1.3/src/cryoemservices.egg-info/dependency_links.txt +1 -0
  41. cryoemservices-0.1.3/src/cryoemservices.egg-info/entry_points.txt +42 -0
  42. cryoemservices-0.1.3/src/cryoemservices.egg-info/not-zip-safe +1 -0
  43. cryoemservices-0.1.3/src/cryoemservices.egg-info/requires.txt +14 -0
  44. cryoemservices-0.1.3/src/cryoemservices.egg-info/top_level.txt +1 -0
@@ -0,0 +1,28 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2023, Diamond Light Source
4
+
5
+ Redistribution and use in source and binary forms, with or without
6
+ modification, are permitted provided that the following conditions are met:
7
+
8
+ 1. Redistributions of source code must retain the above copyright notice, this
9
+ list of conditions and the following disclaimer.
10
+
11
+ 2. Redistributions in binary form must reproduce the above copyright notice,
12
+ this list of conditions and the following disclaimer in the documentation
13
+ and/or other materials provided with the distribution.
14
+
15
+ 3. Neither the name of the copyright holder nor the names of its
16
+ contributors may be used to endorse or promote products derived from
17
+ this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
23
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
26
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
27
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,156 @@
1
+ Metadata-Version: 2.1
2
+ Name: cryoemservices
3
+ Version: 0.1.3
4
+ Summary: Services for CryoEM processing
5
+ Author: Diamond Light Source - Data Analysis et al.
6
+ Author-email: dataanalysis@diamond.ac.uk
7
+ License: BSD 3-Clause
8
+ Project-URL: GitHub, https://github.com/DiamondLightSource/cryoem-services
9
+ Project-URL: Bug-Tracker, https://github.com/DiamondLightSource/cryoem-services/issues
10
+ Keywords: cryoem-services
11
+ Classifier: Development Status :: 3 - Alpha
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: GNU General Public License v2 (GPLv2)
14
+ Classifier: Natural Language :: English
15
+ Classifier: Programming Language :: Python :: 3
16
+ Classifier: Programming Language :: Python :: 3.8
17
+ Classifier: Programming Language :: Python :: 3.9
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Requires-Python: >=3.8
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Requires-Dist: gemmi
23
+ Requires-Dist: htcondor
24
+ Requires-Dist: icebreaker-em
25
+ Requires-Dist: importlib_metadata
26
+ Requires-Dist: ispyb
27
+ Requires-Dist: marshmallow-sqlalchemy
28
+ Requires-Dist: mrcfile
29
+ Requires-Dist: numpy
30
+ Requires-Dist: pillow
31
+ Requires-Dist: plotly
32
+ Requires-Dist: pydantic==1.10.7
33
+ Requires-Dist: starfile
34
+ Requires-Dist: workflows
35
+ Requires-Dist: zocalo
36
+
37
+ # cryoem-services
38
+ Services and configuration for cryo-EM pipelines.
39
+
40
+ This package consists of a number of services to process cryo-EM micrographs,
41
+ both for single particle analysis and tomography,
42
+ using a range of commonly used cryo-EM processing software.
43
+ These services can be run independently to process data,
44
+ or as part of a wider structure for performing live analysis during microscope collection.
45
+ For live analysis, this package integrates with a package
46
+ for transferring and monitoring collected data,
47
+ [Murfey](https://github.com/DiamondLightSource/python-murfey),
48
+ and a database for storing processing outcomes,
49
+ [ISPyB](https://github.com/DiamondLightSource/ispyb-database).
50
+
51
+ To run these services the software executables being called must be installed.
52
+ These do not come with this package.
53
+
54
+
55
+ # Tomography processing
56
+
57
+ The tomography processing pipeline consists of:
58
+ - Motion correction
59
+ - CTF estimation
60
+ - Tomogram alignment
61
+ - Tomogram denoising using [Topaz](http://topaz-em.readthedocs.io)
62
+
63
+
64
+ # Single particle analysis
65
+
66
+ The single particle analysis pipeline produces a project
67
+ that can be opened and continued using
68
+ [CCP-EM doppio](https://www.ccpem.ac.uk/docs/doppio/user_guide.html)
69
+ or [Relion](https://relion.readthedocs.io).
70
+
71
+ The processing pipeline consists of:
72
+ - Motion correction
73
+ - CTF estimation
74
+ - Particle picking
75
+ - (Optionally) Ice thickness estimation
76
+ - Particle extraction and rebatching
77
+ - 2D classification using Relion
78
+ - Automated 2D class selection using Relion
79
+ - 3D classification using Relion
80
+
81
+
82
+ # Services currently available
83
+
84
+ The following services are provided for running the pipelines:
85
+ - Utility services:
86
+ - **ClusterSubmission**: Submits zocalo wrappers to an HPC cluster
87
+ - **Dispatcher**: Converts recipes into messages suitable for processing services
88
+ - **Images**: Creates thumbnail images for viewing processing outcomes
89
+ - **ISPyB**: Inserts results into an ISPyB database
90
+ - **NodeCreator**: Creates Relion project files for the services run
91
+ - Processing services:
92
+ - **CrYOLO**: Particle picking on micrographs using
93
+ [crYOLO](https://cryolo.readthedocs.io)
94
+ - **CTFFind**: CTF estimation on micrographs using
95
+ [CTFFIND4](https://grigoriefflab.umassmed.edu/ctffind4)
96
+ - **Extract**: Extracts picked particles from micrographs
97
+ - **IceBreaker**: Ice thickness estimation with
98
+ [IceBreaker](https://github.com/DiamondLightSource/python-icebreaker)
99
+ - **MotionCorr**: Motion correction of micrographs using
100
+ [MotionCor2](http://emcore.ucsf.edu/ucsf-software)
101
+ or [Relion](https://relion.readthedocs.io)
102
+ - **MotionCorrSlurm**: MotionCor2 processing submitted to a slurm HPC cluster
103
+ - **SelectClasses**: Runs automated 2D class selection using
104
+ [Relion](https://relion.readthedocs.io) and re-batches the particles from these classes
105
+ - **SelectParticles**: Creates files listing batches of extracted particles
106
+ - **TomoAlign**: Tomogram reconstruction from a list of micrographs using
107
+ [imod](https://bio3d.colorado.edu/imod) and [AreTomo](http://msg.ucsf.edu/software)
108
+
109
+ There are also two zocalo wrapper scripts that can be run on an HPC cluster.
110
+ These perform 2D and 3D classification using [Relion](https://relion.readthedocs.io).
111
+
112
+
113
+ # Running services using zocalo
114
+ The services in this package are run using
115
+ [zocalo](https://github.com/DiamondLightSource/python-zocalo)
116
+ and [python-workflows](https://github.com/DiamondLightSource/python-workflows).
117
+ To start a service run the `zocalo.service` command and specify the service name.
118
+ For example, to start a motion correction service:
119
+
120
+ ```bash
121
+ $ zocalo.service -s MotionCorr
122
+ ```
123
+
124
+ Once started, these services will initialise and then wait for messages to be sent to them.
125
+ Messages are sent through a message broker,
126
+ currently [RabbitMQ](http://www.rabbitmq.com) is supported using pika transport in `python-workflows`.
127
+ Individual processing stages can be run by sending a dictionary of the parameters,
128
+ but the processing pipelines are designed to run through recipes.
129
+
130
+ A recipe is a specication of a series of steps to carry out,
131
+ and how these steps interact with each other.
132
+ Recipes for the current processing pipelines are provided in the `recipes` folder.
133
+
134
+ To run a recipe in python a dictionary needs to be provided consisting of
135
+ the recipe name and the parameters expected by the recipe.
136
+ The following snippet shows an example of the setup needed.
137
+ This will send a message to a running **Dispatcher** service which
138
+ prepares the recipe for the processing services.
139
+
140
+ ```python
141
+ import workflows.transport.pika_transport as pt
142
+
143
+ example_message = {
144
+ "recipes": ["em-tomo-align"],
145
+ "parameters": {
146
+ "path_pattern": "micrograph_*.mrc",
147
+ "pix_size": "1",
148
+ ...
149
+ },
150
+ }
151
+
152
+ transport = pt.PikaTransport()
153
+ transport.connect()
154
+ transport.send("processing_recipe", example_message)
155
+ ```
156
+
@@ -0,0 +1,120 @@
1
+ # cryoem-services
2
+ Services and configuration for cryo-EM pipelines.
3
+
4
+ This package consists of a number of services to process cryo-EM micrographs,
5
+ both for single particle analysis and tomography,
6
+ using a range of commonly used cryo-EM processing software.
7
+ These services can be run independently to process data,
8
+ or as part of a wider structure for performing live analysis during microscope collection.
9
+ For live analysis, this package integrates with a package
10
+ for transferring and monitoring collected data,
11
+ [Murfey](https://github.com/DiamondLightSource/python-murfey),
12
+ and a database for storing processing outcomes,
13
+ [ISPyB](https://github.com/DiamondLightSource/ispyb-database).
14
+
15
+ To run these services the software executables being called must be installed.
16
+ These do not come with this package.
17
+
18
+
19
+ # Tomography processing
20
+
21
+ The tomography processing pipeline consists of:
22
+ - Motion correction
23
+ - CTF estimation
24
+ - Tomogram alignment
25
+ - Tomogram denoising using [Topaz](http://topaz-em.readthedocs.io)
26
+
27
+
28
+ # Single particle analysis
29
+
30
+ The single particle analysis pipeline produces a project
31
+ that can be opened and continued using
32
+ [CCP-EM doppio](https://www.ccpem.ac.uk/docs/doppio/user_guide.html)
33
+ or [Relion](https://relion.readthedocs.io).
34
+
35
+ The processing pipeline consists of:
36
+ - Motion correction
37
+ - CTF estimation
38
+ - Particle picking
39
+ - (Optionally) Ice thickness estimation
40
+ - Particle extraction and rebatching
41
+ - 2D classification using Relion
42
+ - Automated 2D class selection using Relion
43
+ - 3D classification using Relion
44
+
45
+
46
+ # Services currently available
47
+
48
+ The following services are provided for running the pipelines:
49
+ - Utility services:
50
+ - **ClusterSubmission**: Submits zocalo wrappers to an HPC cluster
51
+ - **Dispatcher**: Converts recipes into messages suitable for processing services
52
+ - **Images**: Creates thumbnail images for viewing processing outcomes
53
+ - **ISPyB**: Inserts results into an ISPyB database
54
+ - **NodeCreator**: Creates Relion project files for the services run
55
+ - Processing services:
56
+ - **CrYOLO**: Particle picking on micrographs using
57
+ [crYOLO](https://cryolo.readthedocs.io)
58
+ - **CTFFind**: CTF estimation on micrographs using
59
+ [CTFFIND4](https://grigoriefflab.umassmed.edu/ctffind4)
60
+ - **Extract**: Extracts picked particles from micrographs
61
+ - **IceBreaker**: Ice thickness estimation with
62
+ [IceBreaker](https://github.com/DiamondLightSource/python-icebreaker)
63
+ - **MotionCorr**: Motion correction of micrographs using
64
+ [MotionCor2](http://emcore.ucsf.edu/ucsf-software)
65
+ or [Relion](https://relion.readthedocs.io)
66
+ - **MotionCorrSlurm**: MotionCor2 processing submitted to a slurm HPC cluster
67
+ - **SelectClasses**: Runs automated 2D class selection using
68
+ [Relion](https://relion.readthedocs.io) and re-batches the particles from these classes
69
+ - **SelectParticles**: Creates files listing batches of extracted particles
70
+ - **TomoAlign**: Tomogram reconstruction from a list of micrographs using
71
+ [imod](https://bio3d.colorado.edu/imod) and [AreTomo](http://msg.ucsf.edu/software)
72
+
73
+ There are also two zocalo wrapper scripts that can be run on an HPC cluster.
74
+ These perform 2D and 3D classification using [Relion](https://relion.readthedocs.io).
75
+
76
+
77
+ # Running services using zocalo
78
+ The services in this package are run using
79
+ [zocalo](https://github.com/DiamondLightSource/python-zocalo)
80
+ and [python-workflows](https://github.com/DiamondLightSource/python-workflows).
81
+ To start a service run the `zocalo.service` command and specify the service name.
82
+ For example, to start a motion correction service:
83
+
84
+ ```bash
85
+ $ zocalo.service -s MotionCorr
86
+ ```
87
+
88
+ Once started, these services will initialise and then wait for messages to be sent to them.
89
+ Messages are sent through a message broker,
90
+ currently [RabbitMQ](http://www.rabbitmq.com) is supported using pika transport in `python-workflows`.
91
+ Individual processing stages can be run by sending a dictionary of the parameters,
92
+ but the processing pipelines are designed to run through recipes.
93
+
94
+ A recipe is a specication of a series of steps to carry out,
95
+ and how these steps interact with each other.
96
+ Recipes for the current processing pipelines are provided in the `recipes` folder.
97
+
98
+ To run a recipe in python a dictionary needs to be provided consisting of
99
+ the recipe name and the parameters expected by the recipe.
100
+ The following snippet shows an example of the setup needed.
101
+ This will send a message to a running **Dispatcher** service which
102
+ prepares the recipe for the processing services.
103
+
104
+ ```python
105
+ import workflows.transport.pika_transport as pt
106
+
107
+ example_message = {
108
+ "recipes": ["em-tomo-align"],
109
+ "parameters": {
110
+ "path_pattern": "micrograph_*.mrc",
111
+ "pix_size": "1",
112
+ ...
113
+ },
114
+ }
115
+
116
+ transport = pt.PikaTransport()
117
+ transport.connect()
118
+ transport.send("processing_recipe", example_message)
119
+ ```
120
+
@@ -0,0 +1,6 @@
1
+ [build-system]
2
+ requires = ["setuptools >= 40.6.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [tool.isort]
6
+ profile="black"
@@ -0,0 +1,100 @@
1
+ [metadata]
2
+ name = cryoemservices
3
+ version = 0.1.3
4
+ description = Services for CryoEM processing
5
+ long_description = file: README.md
6
+ long_description_content_type = text/markdown
7
+ author = Diamond Light Source - Data Analysis et al.
8
+ author_email = dataanalysis@diamond.ac.uk
9
+ license = BSD 3-Clause
10
+ license_files = LICENSE
11
+ classifiers =
12
+ Development Status :: 3 - Alpha
13
+ Intended Audience :: Developers
14
+ License :: OSI Approved :: GNU General Public License v2 (GPLv2)
15
+ Natural Language :: English
16
+ Programming Language :: Python :: 3
17
+ Programming Language :: Python :: 3.8
18
+ Programming Language :: Python :: 3.9
19
+ Programming Language :: Python :: 3.10
20
+ keywords = cryoem-services
21
+ project_urls =
22
+ GitHub = https://github.com/DiamondLightSource/cryoem-services
23
+ Bug-Tracker = https://github.com/DiamondLightSource/cryoem-services/issues
24
+
25
+ [options]
26
+ include_package_data = True
27
+ install_requires =
28
+ gemmi
29
+ htcondor
30
+ icebreaker-em
31
+ importlib_metadata
32
+ ispyb
33
+ marshmallow-sqlalchemy
34
+ mrcfile
35
+ numpy
36
+ pillow
37
+ plotly
38
+ pydantic ==1.10.7
39
+ starfile
40
+ workflows
41
+ zocalo
42
+ packages = find:
43
+ package_dir =
44
+ =src
45
+ python_requires = >=3.8
46
+ zip_safe = False
47
+
48
+ [options.entry_points]
49
+ ccpem_pipeliner.jobs =
50
+ combine_star_files_job = cryoemservices.pipeliner_plugins.combine_star_job:ProcessStarFiles
51
+ console_scripts =
52
+ combine_star_files = cryoemservices.pipeliner_plugins.combine_star_files:main
53
+ cryoemservices.resubmit_wrapper = cryoemservices.cli.resubmit_wrapper:run
54
+ cryoemservices.services.cluster.schedulers =
55
+ slurm = cryoemservices.services.cluster_submission:submit_to_slurm
56
+ cryoemservices.services.images.plugins =
57
+ mrc_to_jpeg = cryoemservices.services.images_plugins:mrc_to_jpeg
58
+ picked_particles = cryoemservices.services.images_plugins:picked_particles
59
+ mrc_central_slice = cryoemservices.services.images_plugins:mrc_central_slice
60
+ mrc_to_apng = cryoemservices.services.images_plugins:mrc_to_apng
61
+ workflows.services =
62
+ ClusterSubmission = cryoemservices.services.cluster_submission:ClusterSubmission
63
+ CrYOLO = cryoemservices.services.cryolo:CrYOLO
64
+ CTFFind = cryoemservices.services.ctffind:CTFFind
65
+ DenoiseIris = cryoemservices.services.denoise_iris:DenoiseIris
66
+ Extract = cryoemservices.services.extract:Extract
67
+ IceBreaker = cryoemservices.services.icebreaker:IceBreaker
68
+ Images = cryoemservices.services.images:Images
69
+ ISPyB = cryoemservices.services.ispyb:EMISPyB
70
+ MotionCorr = cryoemservices.services.motioncorr:MotionCorr
71
+ MotionCorrSlurm = cryoemservices.services.motioncorr_slurm:MotionCorrSlurm
72
+ NodeCreator = cryoemservices.services.node_creator:NodeCreator
73
+ SelectClasses = cryoemservices.services.select_classes:SelectClasses
74
+ SelectParticles = cryoemservices.services.select_particles:SelectParticles
75
+ TomoAlign = cryoemservices.services.tomo_align:TomoAlign
76
+ TomoAlignIris = cryoemservices.services.tomo_align_iris:TomoAlignIris
77
+ zocalo.services.dispatcher.filters =
78
+ ispyb = cryoemservices.util.dispatcher_tools:ispyb_filter
79
+ zocalo.services.dispatcher.ready_for_processing =
80
+ ispyb = cryoemservices.util.dispatcher_tools:ready_for_processing
81
+ zocalo.wrappers =
82
+ Class2D = cryoemservices.wrappers.class2d_wrapper:Class2DWrapper
83
+ Class3D = cryoemservices.wrappers.class3d_wrapper:Class3DWrapper
84
+
85
+ [options.packages.find]
86
+ where = src
87
+
88
+ [flake8]
89
+ ignore = E203, E266, E501, W503
90
+ max-line-length = 88
91
+ select =
92
+ E401,E711,E712,E713,E714,E721,E722,E901,
93
+ F401,F402,F403,F405,F541,F631,F632,F633,F811,F812,F821,F822,F841,F901,
94
+ W191,W291,W292,W293,W602,W603,W604,W605,W606,
95
+ C4,
96
+
97
+ [egg_info]
98
+ tag_build =
99
+ tag_date = 0
100
+
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env python
2
+
3
+ from __future__ import annotations
4
+
5
+ import setuptools
6
+
7
+ if __name__ == "__main__":
8
+ # Do not add any parameters here. Edit setup.cfg instead.
9
+ setuptools.setup()
@@ -0,0 +1,3 @@
1
+ from __future__ import annotations
2
+
3
+ __version__ = "0.1.3"
@@ -0,0 +1,51 @@
1
+ from __future__ import annotations
2
+
3
+ import argparse
4
+ import json
5
+ from pathlib import Path
6
+
7
+ import workflows.transport.pika_transport as pt
8
+ from workflows.recipe import RecipeWrapper
9
+
10
+
11
+ def run():
12
+ parser = argparse.ArgumentParser(
13
+ description="Resubmit a failed zocalo wrapper script using the .recipewrap file"
14
+ )
15
+ parser.add_argument(
16
+ "-w",
17
+ "--wrapper",
18
+ help="Location of the .recipewrap wrapper file to resubmit",
19
+ dest="wrapper",
20
+ required=True,
21
+ )
22
+ parser.add_argument(
23
+ "-c",
24
+ "--config",
25
+ help="Transport configuration file for connecting to the message broker",
26
+ dest="config",
27
+ required=True,
28
+ )
29
+ args = parser.parse_args()
30
+
31
+ if not Path(args.wrapper).is_file():
32
+ print(f"{args.wrapper} cannot be found")
33
+ return
34
+ if not Path(args.config).is_file():
35
+ print(f"{args.config} cannot be found")
36
+ return
37
+
38
+ # Connect to the message transport
39
+ transport = pt.PikaTransport()
40
+ transport.load_configuration_file(args.config)
41
+ transport.connect()
42
+
43
+ # Load and submit the wrapper part of the recipe
44
+ with open(args.wrapper, "r") as wrap:
45
+ recipe = json.load(wrap)
46
+ rw = RecipeWrapper(message=recipe, transport=transport)
47
+ rw._send_to_destination(rw.recipe_pointer, None, rw.payload, {})
48
+
49
+
50
+ if __name__ == "__main__":
51
+ run()