ChessAnalysisPipeline 0.0.17.dev3__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.
- CHAP/TaskManager.py +216 -0
- CHAP/__init__.py +27 -0
- CHAP/common/__init__.py +57 -0
- CHAP/common/models/__init__.py +8 -0
- CHAP/common/models/common.py +124 -0
- CHAP/common/models/integration.py +659 -0
- CHAP/common/models/map.py +1291 -0
- CHAP/common/processor.py +2869 -0
- CHAP/common/reader.py +658 -0
- CHAP/common/utils.py +110 -0
- CHAP/common/writer.py +730 -0
- CHAP/edd/__init__.py +23 -0
- CHAP/edd/models.py +876 -0
- CHAP/edd/processor.py +3069 -0
- CHAP/edd/reader.py +1023 -0
- CHAP/edd/select_material_params_gui.py +348 -0
- CHAP/edd/utils.py +1572 -0
- CHAP/edd/writer.py +26 -0
- CHAP/foxden/__init__.py +19 -0
- CHAP/foxden/models.py +71 -0
- CHAP/foxden/processor.py +124 -0
- CHAP/foxden/reader.py +224 -0
- CHAP/foxden/utils.py +80 -0
- CHAP/foxden/writer.py +168 -0
- CHAP/giwaxs/__init__.py +11 -0
- CHAP/giwaxs/models.py +491 -0
- CHAP/giwaxs/processor.py +776 -0
- CHAP/giwaxs/reader.py +8 -0
- CHAP/giwaxs/writer.py +8 -0
- CHAP/inference/__init__.py +7 -0
- CHAP/inference/processor.py +69 -0
- CHAP/inference/reader.py +8 -0
- CHAP/inference/writer.py +8 -0
- CHAP/models.py +227 -0
- CHAP/pipeline.py +479 -0
- CHAP/processor.py +125 -0
- CHAP/reader.py +124 -0
- CHAP/runner.py +277 -0
- CHAP/saxswaxs/__init__.py +7 -0
- CHAP/saxswaxs/processor.py +8 -0
- CHAP/saxswaxs/reader.py +8 -0
- CHAP/saxswaxs/writer.py +8 -0
- CHAP/server.py +125 -0
- CHAP/sin2psi/__init__.py +7 -0
- CHAP/sin2psi/processor.py +8 -0
- CHAP/sin2psi/reader.py +8 -0
- CHAP/sin2psi/writer.py +8 -0
- CHAP/tomo/__init__.py +15 -0
- CHAP/tomo/models.py +210 -0
- CHAP/tomo/processor.py +3862 -0
- CHAP/tomo/reader.py +9 -0
- CHAP/tomo/writer.py +59 -0
- CHAP/utils/__init__.py +6 -0
- CHAP/utils/converters.py +188 -0
- CHAP/utils/fit.py +2947 -0
- CHAP/utils/general.py +2655 -0
- CHAP/utils/material.py +274 -0
- CHAP/utils/models.py +595 -0
- CHAP/utils/parfile.py +224 -0
- CHAP/writer.py +122 -0
- MLaaS/__init__.py +0 -0
- MLaaS/ktrain.py +205 -0
- MLaaS/mnist_img.py +83 -0
- MLaaS/tfaas_client.py +371 -0
- chessanalysispipeline-0.0.17.dev3.dist-info/LICENSE +60 -0
- chessanalysispipeline-0.0.17.dev3.dist-info/METADATA +29 -0
- chessanalysispipeline-0.0.17.dev3.dist-info/RECORD +70 -0
- chessanalysispipeline-0.0.17.dev3.dist-info/WHEEL +5 -0
- chessanalysispipeline-0.0.17.dev3.dist-info/entry_points.txt +2 -0
- chessanalysispipeline-0.0.17.dev3.dist-info/top_level.txt +2 -0
CHAP/common/utils.py
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
#-*- coding: utf-8 -*-
|
|
3
|
+
"""
|
|
4
|
+
File : utils.py
|
|
5
|
+
Author : Valentin Kuznetsov <vkuznet AT gmail dot com>
|
|
6
|
+
Description: common set of utility functions
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
# System modules
|
|
10
|
+
import os
|
|
11
|
+
import sys
|
|
12
|
+
import platform
|
|
13
|
+
import subprocess
|
|
14
|
+
import json
|
|
15
|
+
|
|
16
|
+
# Third party modules
|
|
17
|
+
import pkg_resources
|
|
18
|
+
|
|
19
|
+
def osinfo():
|
|
20
|
+
"""Helper function to provide osinfo."""
|
|
21
|
+
os_info = {
|
|
22
|
+
'name': f'{platform.system().lower()}-{platform.release()}',
|
|
23
|
+
'kernel': platform.version(),
|
|
24
|
+
'version': platform.platform(),
|
|
25
|
+
}
|
|
26
|
+
return os_info
|
|
27
|
+
|
|
28
|
+
def environments():
|
|
29
|
+
"""Detects the current Python environment (system, virtualenv,
|
|
30
|
+
Conda, or pip) and collects package information. Returns a list
|
|
31
|
+
of detected environments with installed packages.
|
|
32
|
+
"""
|
|
33
|
+
environments_ = []
|
|
34
|
+
os_name = f'{platform.system().lower()}-{platform.release()}'
|
|
35
|
+
|
|
36
|
+
# Check for Conda environment
|
|
37
|
+
conda_env = os.getenv('CONDA_PREFIX')
|
|
38
|
+
if conda_env:
|
|
39
|
+
conda_env_name = os.getenv('CONDA_DEFAULT_ENV', 'unknown-conda-env')
|
|
40
|
+
try:
|
|
41
|
+
# Fetch Conda packages
|
|
42
|
+
conda_packages = subprocess.check_output(
|
|
43
|
+
['conda', 'list', '--json'], text=True)
|
|
44
|
+
conda_packages = json.loads(conda_packages)
|
|
45
|
+
packages = [{'name': pkg['name'], 'version': pkg['version']}
|
|
46
|
+
for pkg in conda_packages]
|
|
47
|
+
except Exception:
|
|
48
|
+
packages = []
|
|
49
|
+
environments_.append({
|
|
50
|
+
'name': conda_env_name,
|
|
51
|
+
'version': sys.version.split()[0],
|
|
52
|
+
'details': 'Conda environment',
|
|
53
|
+
'parent_environment': None,
|
|
54
|
+
'os_name': os_name,
|
|
55
|
+
'packages': packages,
|
|
56
|
+
})
|
|
57
|
+
|
|
58
|
+
# Check for Virtualenv (excluding Conda)
|
|
59
|
+
elif hasattr(sys, 'real_prefix') or os.getenv('VIRTUAL_ENV'):
|
|
60
|
+
venv_name = os.path.basename(os.getenv('VIRTUAL_ENV', 'unknown-venv'))
|
|
61
|
+
packages = [{'name': pkg.key, 'version': pkg.version}
|
|
62
|
+
for pkg in pkg_resources.working_set]
|
|
63
|
+
environments_.append({
|
|
64
|
+
'name': venv_name,
|
|
65
|
+
'version': sys.version.split()[0],
|
|
66
|
+
'details': 'Virtualenv environment',
|
|
67
|
+
'parent_environment': None,
|
|
68
|
+
'os_name': os_name,
|
|
69
|
+
'packages': packages,
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
# System Python (not inside Conda or Virtualenv)
|
|
73
|
+
else:
|
|
74
|
+
packages = [{'name': pkg.key, 'version': pkg.version}
|
|
75
|
+
for pkg in pkg_resources.working_set]
|
|
76
|
+
environments_.append({
|
|
77
|
+
'name': 'system-python',
|
|
78
|
+
'version': sys.version.split()[0],
|
|
79
|
+
'details': 'System-wide Python',
|
|
80
|
+
'parent_environment': None,
|
|
81
|
+
'os_name': os_name,
|
|
82
|
+
'packages': packages,
|
|
83
|
+
})
|
|
84
|
+
|
|
85
|
+
# Check for PIP installed editable packages
|
|
86
|
+
try:
|
|
87
|
+
# Fetch Git repo info for PIP installed editable packages
|
|
88
|
+
pip_packages = subprocess.check_output(
|
|
89
|
+
['pip', 'list', '--format', 'json'], text=True)
|
|
90
|
+
pip_packages = json.loads(pip_packages)
|
|
91
|
+
packages = [{'name': pkg['name'],
|
|
92
|
+
#'version': pkg['version'],
|
|
93
|
+
'commit_hash': subprocess.check_output(
|
|
94
|
+
["git", "rev-parse", "HEAD"],
|
|
95
|
+
cwd=pkg['editable_project_location']
|
|
96
|
+
).strip().decode()}
|
|
97
|
+
for pkg in pip_packages
|
|
98
|
+
if 'editable_project_location' in pkg]
|
|
99
|
+
environments_.append({
|
|
100
|
+
'name': 'Python Package Installer',
|
|
101
|
+
'version': sys.version.split()[0],
|
|
102
|
+
'details': 'Editable project locations',
|
|
103
|
+
'parent_environment': None,
|
|
104
|
+
'os_name': os_name,
|
|
105
|
+
'packages': packages,
|
|
106
|
+
})
|
|
107
|
+
except Exception:
|
|
108
|
+
pass
|
|
109
|
+
|
|
110
|
+
return environments_
|