ChessAnalysisPipeline 0.0.5__py3-none-any.whl → 0.0.6__py3-none-any.whl

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.

Potentially problematic release.


This version of ChessAnalysisPipeline might be problematic. Click here for more details.

Files changed (41) hide show
  1. CHAP/TaskManager.py +214 -0
  2. CHAP/common/models/integration.py +392 -249
  3. CHAP/common/models/map.py +350 -198
  4. CHAP/common/processor.py +227 -189
  5. CHAP/common/reader.py +52 -39
  6. CHAP/common/utils/fit.py +1197 -991
  7. CHAP/common/utils/general.py +629 -372
  8. CHAP/common/utils/material.py +158 -121
  9. CHAP/common/utils/scanparsers.py +735 -339
  10. CHAP/common/writer.py +31 -25
  11. CHAP/edd/models.py +63 -49
  12. CHAP/edd/processor.py +130 -109
  13. CHAP/edd/reader.py +1 -1
  14. CHAP/edd/writer.py +1 -1
  15. CHAP/inference/processor.py +35 -28
  16. CHAP/inference/reader.py +1 -1
  17. CHAP/inference/writer.py +1 -1
  18. CHAP/pipeline.py +14 -28
  19. CHAP/processor.py +44 -75
  20. CHAP/reader.py +49 -40
  21. CHAP/runner.py +73 -32
  22. CHAP/saxswaxs/processor.py +1 -1
  23. CHAP/saxswaxs/reader.py +1 -1
  24. CHAP/saxswaxs/writer.py +1 -1
  25. CHAP/server.py +130 -0
  26. CHAP/sin2psi/processor.py +1 -1
  27. CHAP/sin2psi/reader.py +1 -1
  28. CHAP/sin2psi/writer.py +1 -1
  29. CHAP/tomo/__init__.py +1 -4
  30. CHAP/tomo/models.py +53 -31
  31. CHAP/tomo/processor.py +1326 -900
  32. CHAP/tomo/reader.py +4 -2
  33. CHAP/tomo/writer.py +4 -2
  34. CHAP/writer.py +47 -41
  35. {ChessAnalysisPipeline-0.0.5.dist-info → ChessAnalysisPipeline-0.0.6.dist-info}/METADATA +1 -1
  36. ChessAnalysisPipeline-0.0.6.dist-info/RECORD +52 -0
  37. ChessAnalysisPipeline-0.0.5.dist-info/RECORD +0 -50
  38. {ChessAnalysisPipeline-0.0.5.dist-info → ChessAnalysisPipeline-0.0.6.dist-info}/LICENSE +0 -0
  39. {ChessAnalysisPipeline-0.0.5.dist-info → ChessAnalysisPipeline-0.0.6.dist-info}/WHEEL +0 -0
  40. {ChessAnalysisPipeline-0.0.5.dist-info → ChessAnalysisPipeline-0.0.6.dist-info}/entry_points.txt +0 -0
  41. {ChessAnalysisPipeline-0.0.5.dist-info → ChessAnalysisPipeline-0.0.6.dist-info}/top_level.txt +0 -0
CHAP/common/reader.py CHANGED
@@ -1,44 +1,46 @@
1
1
  #!/usr/bin/env python
2
- '''
2
+ """
3
3
  File : reader.py
4
4
  Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
5
- Description: Module for Writers used in multiple experiment-specific workflows.
6
- '''
5
+ Description: Module for Writers used in multiple experiment-specific
6
+ workflows.
7
+ """
7
8
 
8
9
  # system modules
9
- import argparse
10
- import json
11
- import logging
12
- import sys
10
+ from sys import modules
13
11
  from time import time
14
12
 
15
13
  # local modules
16
14
  from CHAP import Reader
17
15
 
16
+
18
17
  class BinaryFileReader(Reader):
18
+ """Reader for binary files"""
19
19
  def _read(self, filename):
20
- '''Return a content of a given file name
20
+ """Return a content of a given file name
21
21
 
22
22
  :param filename: name of the binart file to read from
23
23
  :return: the content of `filename`
24
24
  :rtype: binary
25
- '''
25
+ """
26
+
26
27
  with open(filename, 'rb') as file:
27
28
  data = file.read()
28
- return(data)
29
+ return data
30
+
29
31
 
30
32
  class MultipleReader(Reader):
31
- def read(self, readers):
32
- '''Return resuts from multiple `Reader`s.
33
+ def read(self, readers, **_read_kwargs):
34
+ """Return resuts from multiple `Reader`s.
33
35
 
34
- :param readers: a dictionary where the keys are specific names that are
35
- used by the next item in the `Pipeline`, and the values are `Reader`
36
- configurations.
36
+ :param readers: a dictionary where the keys are specific names
37
+ that are used by the next item in the `Pipeline`, and the
38
+ values are `Reader` configurations.
37
39
  :type readers: list[dict]
38
- :return: The results of calling `Reader.read(**kwargs)` for each item
39
- configured in `readers`.
40
+ :return: The results of calling `Reader.read(**kwargs)` for
41
+ each item configured in `readers`.
40
42
  :rtype: list[dict[str,object]]
41
- '''
43
+ """
42
44
 
43
45
  t0 = time()
44
46
  self.logger.info(f'Executing "read" with {len(readers)} Readers')
@@ -46,73 +48,84 @@ class MultipleReader(Reader):
46
48
  data = []
47
49
  for reader_config in readers:
48
50
  reader_name = list(reader_config.keys())[0]
49
- reader_class = getattr(sys.modules[__name__], reader_name)
51
+ reader_class = getattr(modules[__name__], reader_name)
50
52
  reader = reader_class()
51
53
  reader_kwargs = reader_config[reader_name]
52
54
 
53
- data.extend(reader.read(**reader_kwargs))
55
+ # Combine keyword arguments to MultipleReader.read with those to the reader
56
+ # giving precedence to those in the latter
57
+ combined_kwargs = {**_read_kwargs, **reader_kwargs}
58
+ data.extend(reader.read(**combined_kwargs))
54
59
 
55
60
  self.logger.info(f'Finished "read" in {time()-t0:.3f} seconds\n')
56
61
 
57
- return(data)
62
+ return data
63
+
58
64
 
59
65
  class NexusReader(Reader):
66
+ """Reader for NeXus files"""
60
67
  def _read(self, filename, nxpath='/'):
61
- '''Return the NeXus object stored at `nxpath` in the nexus file
62
- `filename`.
68
+ """Return the NeXus object stored at `nxpath` in the nexus
69
+ file `filename`.
63
70
 
64
71
  :param filename: name of the NeXus file to read from
65
72
  :type filename: str
66
- :param nxpath: path to a specific loaction in the NeXus file to read
67
- from, defaults to `'/'`
73
+ :param nxpath: path to a specific loaction in the NeXus file
74
+ to read from, defaults to `'/'`
68
75
  :type nxpath: str, optional
69
- :raises nexusformat.nexus.NeXusError: if `filename` is not a NeXus
70
- file or `nxpath` is not in `filename`.
76
+ :raises nexusformat.nexus.NeXusError: if `filename` is not a
77
+ NeXus file or `nxpath` is not in `filename`.
71
78
  :return: the NeXus structure indicated by `filename` and `nxpath`.
72
79
  :rtype: nexusformat.nexus.NXobject
73
- '''
80
+ """
74
81
 
75
82
  from nexusformat.nexus import nxload
76
83
 
77
84
  nxobject = nxload(filename)[nxpath]
78
- return(nxobject)
85
+ return nxobject
86
+
79
87
 
80
88
  class URLReader(Reader):
81
- def _read(self, url, headers={}):
82
- '''Make an HTTPS request to the provided URL and return the results.
83
- Headers for the request are optional.
89
+ """Reader for data available over HTTPS"""
90
+ def _read(self, url, headers={}, timeout=10):
91
+ """Make an HTTPS request to the provided URL and return the
92
+ results. Headers for the request are optional.
84
93
 
85
94
  :param url: the URL to read
86
95
  :type url: str
87
- :param headers: headers to attach to the request, defaults to `{}`
96
+ :param headers: headers to attach to the request, defaults to
97
+ `{}`
88
98
  :type headers: dict, optional
89
99
  :return: the content of the response
90
100
  :rtype: object
91
- '''
101
+ """
92
102
 
93
103
  import requests
94
104
 
95
- resp = requests.get(url, headers=headers)
105
+ resp = requests.get(url, headers=headers, timeout=timeout)
96
106
  data = resp.content
97
107
 
98
108
  self.logger.debug(f'Response content: {data}')
99
109
 
100
- return(data)
110
+ return data
111
+
101
112
 
102
113
  class YAMLReader(Reader):
114
+ """Reader for YAML files"""
103
115
  def _read(self, filename):
104
- '''Return a dictionary from the contents of a yaml file.
116
+ """Return a dictionary from the contents of a yaml file.
105
117
 
106
118
  :param filename: name of the YAML file to read from
107
119
  :return: the contents of `filename`
108
120
  :rtype: dict
109
- '''
121
+ """
110
122
 
111
123
  import yaml
112
124
 
113
125
  with open(filename) as file:
114
126
  data = yaml.safe_load(file)
115
- return(data)
127
+ return data
128
+
116
129
 
117
130
  if __name__ == '__main__':
118
131
  from CHAP.reader import main