ChessAnalysisPipeline 0.0.2__py3-none-any.whl → 0.0.4__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.
- CHAP/__init__.py +3 -0
- CHAP/common/__init__.py +19 -0
- CHAP/common/models/__init__.py +2 -0
- CHAP/common/models/integration.py +515 -0
- CHAP/common/models/map.py +535 -0
- CHAP/common/processor.py +644 -0
- CHAP/common/reader.py +119 -0
- CHAP/common/utils/__init__.py +37 -0
- CHAP/common/utils/fit.py +2613 -0
- CHAP/common/utils/general.py +1225 -0
- CHAP/common/utils/material.py +231 -0
- CHAP/common/utils/scanparsers.py +785 -0
- CHAP/common/writer.py +96 -0
- CHAP/edd/__init__.py +7 -0
- CHAP/edd/models.py +215 -0
- CHAP/edd/processor.py +321 -0
- CHAP/edd/reader.py +5 -0
- CHAP/edd/writer.py +5 -0
- CHAP/inference/__init__.py +3 -0
- CHAP/inference/processor.py +68 -0
- CHAP/inference/reader.py +5 -0
- CHAP/inference/writer.py +5 -0
- CHAP/pipeline.py +1 -1
- CHAP/processor.py +11 -818
- CHAP/reader.py +18 -113
- CHAP/saxswaxs/__init__.py +6 -0
- CHAP/saxswaxs/processor.py +5 -0
- CHAP/saxswaxs/reader.py +5 -0
- CHAP/saxswaxs/writer.py +5 -0
- CHAP/sin2psi/__init__.py +7 -0
- CHAP/sin2psi/processor.py +5 -0
- CHAP/sin2psi/reader.py +5 -0
- CHAP/sin2psi/writer.py +5 -0
- CHAP/tomo/__init__.py +5 -0
- CHAP/tomo/models.py +125 -0
- CHAP/tomo/processor.py +2009 -0
- CHAP/tomo/reader.py +5 -0
- CHAP/tomo/writer.py +5 -0
- CHAP/writer.py +17 -167
- {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/METADATA +1 -1
- ChessAnalysisPipeline-0.0.4.dist-info/RECORD +50 -0
- CHAP/async.py +0 -56
- ChessAnalysisPipeline-0.0.2.dist-info/RECORD +0 -17
- {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/LICENSE +0 -0
- {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/WHEEL +0 -0
- {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/entry_points.txt +0 -0
- {ChessAnalysisPipeline-0.0.2.dist-info → ChessAnalysisPipeline-0.0.4.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#-*- coding: utf-8 -*-
|
|
3
|
+
#pylint: disable=
|
|
4
|
+
'''
|
|
5
|
+
File : processor.py
|
|
6
|
+
Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
|
|
7
|
+
Description: Processor module
|
|
8
|
+
'''
|
|
9
|
+
|
|
10
|
+
# system modules
|
|
11
|
+
from time import time
|
|
12
|
+
|
|
13
|
+
# local modules
|
|
14
|
+
from CHAP import Processor
|
|
15
|
+
|
|
16
|
+
class TFaaSImageProcessor(Processor):
|
|
17
|
+
'''
|
|
18
|
+
A Processor to get predictions from TFaaS inference server.
|
|
19
|
+
'''
|
|
20
|
+
def process(self, data, url, model, verbose=False):
|
|
21
|
+
'''
|
|
22
|
+
process data API
|
|
23
|
+
'''
|
|
24
|
+
|
|
25
|
+
t0 = time()
|
|
26
|
+
self.logger.info(f'Executing "process" with url {url} model {model}')
|
|
27
|
+
|
|
28
|
+
data = self._process(data, url, model, verbose)
|
|
29
|
+
|
|
30
|
+
self.logger.info(f'Finished "process" in {time()-t0:.3f} seconds\n')
|
|
31
|
+
|
|
32
|
+
return(data)
|
|
33
|
+
|
|
34
|
+
def _process(self, data, url, model, verbose):
|
|
35
|
+
'''Print and return the input data.
|
|
36
|
+
|
|
37
|
+
:param data: Input image data, either file name or actual image data
|
|
38
|
+
:type data: object
|
|
39
|
+
:return: `data`
|
|
40
|
+
:rtype: object
|
|
41
|
+
'''
|
|
42
|
+
|
|
43
|
+
from MLaaS.tfaas_client import predictImage
|
|
44
|
+
from pathlib import Path
|
|
45
|
+
|
|
46
|
+
self.logger.info(f'input data {type(data)}')
|
|
47
|
+
if isinstance(data, str) and Path(data).is_file():
|
|
48
|
+
imgFile = data
|
|
49
|
+
data = predictImage(url, imgFile, model, verbose)
|
|
50
|
+
else:
|
|
51
|
+
rdict = data[0]
|
|
52
|
+
import requests
|
|
53
|
+
img = rdict['data']
|
|
54
|
+
session = requests.Session()
|
|
55
|
+
rurl = url + '/predict/image'
|
|
56
|
+
payload = dict(model=model)
|
|
57
|
+
files = dict(image=img)
|
|
58
|
+
self.logger.info(f'HTTP request {rurl} with image file and {payload} payload')
|
|
59
|
+
req = session.post(rurl, files=files, data=payload )
|
|
60
|
+
data = req.content
|
|
61
|
+
data = data.decode('utf-8').replace('\n', '')
|
|
62
|
+
self.logger.info(f'HTTP response {data}')
|
|
63
|
+
|
|
64
|
+
return(data)
|
|
65
|
+
|
|
66
|
+
if __name__ == '__main__':
|
|
67
|
+
from CHAP.processor import main
|
|
68
|
+
main()
|
CHAP/inference/reader.py
ADDED
CHAP/inference/writer.py
ADDED
CHAP/pipeline.py
CHANGED
|
@@ -50,7 +50,7 @@ class Pipeline():
|
|
|
50
50
|
self.logger.info(f'Calling "write" on {item}')
|
|
51
51
|
data = item.write(data, **kwargs)
|
|
52
52
|
|
|
53
|
-
self.logger.info(f'
|
|
53
|
+
self.logger.info(f'Executed "execute" in {time()-t0:.3f} seconds')
|
|
54
54
|
|
|
55
55
|
class PipelineObject():
|
|
56
56
|
"""
|