cloudpss 4.0.0a7__py3-none-any.whl → 4.0.2__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.
- cloudpss/dslab/dataManageModel.py +13 -2
- cloudpss/dslab/dslab.py +65 -0
- cloudpss/job/__init__.py +5 -0
- cloudpss/job/job.py +277 -0
- cloudpss/job/jobMachine.py +11 -0
- cloudpss/job/jobPolicy.py +129 -0
- cloudpss/job/jobQueue.py +14 -0
- cloudpss/job/jobReceiver.py +33 -0
- cloudpss/job/jobTres.py +6 -0
- cloudpss/job/messageStreamReceiver.py +120 -0
- cloudpss/job/messageStreamSender.py +74 -0
- cloudpss/job/view/EMTView.py +216 -0
- cloudpss/job/view/IESLabSimulationView.py +5 -0
- cloudpss/job/view/IESLabTypicalDayView.py +27 -0
- cloudpss/job/view/IESView.py +103 -0
- cloudpss/job/view/PowerFlowView.py +80 -0
- cloudpss/job/view/__init__.py +42 -0
- cloudpss/job/view/view.py +122 -0
- cloudpss/utils/IO.py +18 -7
- cloudpss/utils/httprequests.py +1 -1
- cloudpss/version.py +1 -1
- {cloudpss-4.0.0a7.dist-info → cloudpss-4.0.2.dist-info}/METADATA +1 -1
- {cloudpss-4.0.0a7.dist-info → cloudpss-4.0.2.dist-info}/RECORD +25 -9
- {cloudpss-4.0.0a7.dist-info → cloudpss-4.0.2.dist-info}/WHEEL +0 -0
- {cloudpss-4.0.0a7.dist-info → cloudpss-4.0.2.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,122 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
from ..messageStreamSender import MessageStreamSender
|
4
|
+
from ..messageStreamReceiver import MessageStreamReceiver
|
5
|
+
|
6
|
+
|
7
|
+
class View(object):
|
8
|
+
"""
|
9
|
+
结果视图基类,提供基础的结果获取接口
|
10
|
+
"""
|
11
|
+
def __init__(self, receiver:MessageStreamReceiver,sender:MessageStreamSender=None) -> None:
|
12
|
+
"""
|
13
|
+
初始化
|
14
|
+
"""
|
15
|
+
self.result = {}
|
16
|
+
self._receiver = receiver
|
17
|
+
self._sender = sender
|
18
|
+
self.__logsIndex = 0
|
19
|
+
|
20
|
+
def __deepModify(self, dict1, dict2):
|
21
|
+
|
22
|
+
for key, val in dict1.items():
|
23
|
+
if type(val) is dict:
|
24
|
+
self.__deepModify(val, dict2[key])
|
25
|
+
else:
|
26
|
+
dict2[key] = val
|
27
|
+
|
28
|
+
def modify(self, data, model):
|
29
|
+
"""
|
30
|
+
通过指定消息修改算例文件
|
31
|
+
|
32
|
+
:params: data 消息字典 {}
|
33
|
+
:params: model 项目
|
34
|
+
|
35
|
+
>>> message= view.modify(data,model)
|
36
|
+
|
37
|
+
"""
|
38
|
+
modifyData = data['data']
|
39
|
+
payload = modifyData['payload']
|
40
|
+
self.__deepModify(payload, model)
|
41
|
+
|
42
|
+
def getMessagesByKey(self, key):
|
43
|
+
"""
|
44
|
+
获取指定 key 的消息数据
|
45
|
+
|
46
|
+
:params key: 数据key
|
47
|
+
|
48
|
+
:returns: 对应 key 的数据数组
|
49
|
+
|
50
|
+
>>> message= db.getMessagesByKey('log')
|
51
|
+
"""
|
52
|
+
|
53
|
+
result = []
|
54
|
+
for val in self._receiver:
|
55
|
+
if val.get('key', None) == key:
|
56
|
+
result.append(val)
|
57
|
+
return result
|
58
|
+
|
59
|
+
def getMessagesByType(self, type):
|
60
|
+
"""
|
61
|
+
获取指定类型的消息数据
|
62
|
+
|
63
|
+
:params type: 数据类型
|
64
|
+
|
65
|
+
:returns: 对应类型的数据数组
|
66
|
+
|
67
|
+
>>> message= db.getMessagesByType('log')
|
68
|
+
"""
|
69
|
+
|
70
|
+
result = []
|
71
|
+
for val in self._receiver:
|
72
|
+
if val['type'] == type:
|
73
|
+
result.append(val)
|
74
|
+
return result
|
75
|
+
|
76
|
+
def getMessage(self, index):
|
77
|
+
"""
|
78
|
+
获取指定位置的消息数据
|
79
|
+
|
80
|
+
:params index: 数据的位置信息
|
81
|
+
|
82
|
+
:returns: 消息数据
|
83
|
+
|
84
|
+
>>> message= db.getMessage(1)
|
85
|
+
"""
|
86
|
+
return self._receiver.messages[index]
|
87
|
+
|
88
|
+
def getMessages(self):
|
89
|
+
"""
|
90
|
+
获取所有消息数据
|
91
|
+
|
92
|
+
:returns: 消息数据数组
|
93
|
+
"""
|
94
|
+
return self._receiver.messages
|
95
|
+
|
96
|
+
|
97
|
+
def getLogs(self):
|
98
|
+
'''
|
99
|
+
获取当前任务的日志
|
100
|
+
|
101
|
+
>>>logs= result.getLogs()
|
102
|
+
{...}
|
103
|
+
'''
|
104
|
+
result = []
|
105
|
+
length = len(self._receiver.messages)
|
106
|
+
if (length > self.__logsIndex):
|
107
|
+
for num in range(self.__logsIndex, length):
|
108
|
+
val = self.getMessage(num)
|
109
|
+
if val['type'] == 'log':
|
110
|
+
result.append(val)
|
111
|
+
self.__logsIndex = length
|
112
|
+
return result
|
113
|
+
|
114
|
+
|
115
|
+
@property
|
116
|
+
def end(self):
|
117
|
+
"""
|
118
|
+
获取当前连接状态
|
119
|
+
|
120
|
+
:returns: 当前连接状态 0:关闭 1:打开
|
121
|
+
"""
|
122
|
+
return self._receiver.end
|
cloudpss/utils/IO.py
CHANGED
@@ -5,6 +5,7 @@ import yaml
|
|
5
5
|
import gzip
|
6
6
|
import base64
|
7
7
|
import struct
|
8
|
+
import zstandard as zstd
|
8
9
|
|
9
10
|
|
10
11
|
def float32Array(_loader, node):
|
@@ -56,7 +57,8 @@ def int32Array(_loader, node):
|
|
56
57
|
yaml.add_constructor('tag:yaml.org,2002:js/Float32Array', float32Array)
|
57
58
|
yaml.add_constructor('tag:yaml.org,2002:js/Float64Array', float64Array)
|
58
59
|
yaml.add_constructor('tag:yaml.org,2002:js/Uint8Array', uint8Array)
|
59
|
-
yaml.add_constructor('tag:yaml.org,2002:js/Uint8ClampedArray',
|
60
|
+
yaml.add_constructor('tag:yaml.org,2002:js/Uint8ClampedArray',
|
61
|
+
uint8ClampedArray)
|
60
62
|
yaml.add_constructor('tag:yaml.org,2002:js/Uint16Array', uint16Array)
|
61
63
|
yaml.add_constructor('tag:yaml.org,2002:js/Uint32Array', uint32Array)
|
62
64
|
yaml.add_constructor('tag:yaml.org,2002:js/Int8Array', int8Array)
|
@@ -73,7 +75,7 @@ class IO(object):
|
|
73
75
|
def serialize(obj, format, compress='gzip') -> bytes:
|
74
76
|
"""
|
75
77
|
根据format序列化模型
|
76
|
-
format 支持 json, ubjson, yaml
|
78
|
+
format 支持 json, ubjson, yaml, zstd
|
77
79
|
compress 支持 gzip
|
78
80
|
"""
|
79
81
|
result = None
|
@@ -87,13 +89,15 @@ class IO(object):
|
|
87
89
|
assert False, 'format not support'
|
88
90
|
if compress == 'gzip':
|
89
91
|
return gzip.compress(result)
|
92
|
+
if compress == 'zstd':
|
93
|
+
return zstd.ZstdCompressor().compress(result)
|
90
94
|
return result
|
91
95
|
|
92
96
|
@staticmethod
|
93
97
|
def deserialize(byt, format):
|
94
98
|
"""
|
95
99
|
根据format反序列化模型
|
96
|
-
format 支持 json, ubjson, yaml
|
100
|
+
format 支持 json, ubjson, yaml, zstd
|
97
101
|
"""
|
98
102
|
if format == 'json':
|
99
103
|
return json.loads(byt)
|
@@ -111,12 +115,17 @@ class IO(object):
|
|
111
115
|
"""
|
112
116
|
### 读取文件
|
113
117
|
f = open(file, 'r+', encoding='utf-8')
|
114
|
-
t = f.buffer.read(
|
118
|
+
t = f.buffer.read(4)
|
115
119
|
f.close()
|
116
120
|
### 判断文件格式是否是gzip或其他格式
|
117
|
-
if t == b'\x1f\x8b':
|
121
|
+
if t[0:2] == b'\x1f\x8b':
|
118
122
|
with gzip.open(file, 'rb') as input_file:
|
119
123
|
return IO.deserialize(input_file.read(), format) # type:ignore
|
124
|
+
if t == b'\x28\xb5\x2f\xfd':
|
125
|
+
with open(file, 'rb') as input_file:
|
126
|
+
return IO.deserialize(
|
127
|
+
zstd.ZstdDecompressor().decompress(input_file.read()),
|
128
|
+
format)
|
120
129
|
else:
|
121
130
|
with open(file, 'rb') as f:
|
122
131
|
data = f.read()
|
@@ -127,7 +136,7 @@ class IO(object):
|
|
127
136
|
def dump(obj, file, format, compress='gzip'):
|
128
137
|
"""
|
129
138
|
根据format将模型保存到文件中
|
130
|
-
format 支持 json, ubjson, yaml
|
139
|
+
format 支持 json, ubjson, yaml, zstd
|
131
140
|
compress 支持 gzip
|
132
141
|
"""
|
133
142
|
### 序列化
|
@@ -147,7 +156,9 @@ if __name__ == '__main__':
|
|
147
156
|
]
|
148
157
|
IO.dump(obj, 'output.json.gz', 'json')
|
149
158
|
IO.dump(obj, 'output.ubjson.gz', 'ubjson')
|
150
|
-
IO.dump(obj, 'output.yaml.gz', 'yaml')
|
159
|
+
IO.dump(obj, 'output.yaml.gz', 'yaml') # type: ignore
|
160
|
+
IO.dump(obj, 'output.yaml.zstd', 'yaml', 'zstd') # type: ignore
|
151
161
|
print(IO.load('output.json.gz', 'json'))
|
152
162
|
print(IO.load('output.ubjson.gz', 'ubjson'))
|
153
163
|
print(IO.load('output.yaml.gz', 'yaml'))
|
164
|
+
print(IO.load('output.yaml.zstd', 'yaml'))
|
cloudpss/utils/httprequests.py
CHANGED
@@ -24,7 +24,7 @@ def request(method, uri, baseUrl=None, params={}, token=None, **kwargs):
|
|
24
24
|
raise Exception(
|
25
25
|
'当前SDK版本(ver 3.X.X)与服务器版本(3.0.0 以下)不兼容,请更换服务器地址或更换SDK版本。')
|
26
26
|
os.environ['X_CLOUDPSS_VERSION'] = r.headers['X-Cloudpss-Version']
|
27
|
-
if float(r.headers['X-Cloudpss-Version'])
|
27
|
+
if float(r.headers['X-Cloudpss-Version']) >= 5:
|
28
28
|
raise Exception('当前SDK版本(ver '+__version__ +')与服务器版本(ver ' +
|
29
29
|
r.headers['X-Cloudpss-Version'] +
|
30
30
|
'.X.X)不兼容,请更换服务器地址或更换SDK版本(pip 使用 pip install -U cloudpss 命令更新, conda 使用 conda update cloudpss 命令更新)。')
|
cloudpss/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '4.0.
|
1
|
+
__version__ = '4.0.2'
|
@@ -1,10 +1,10 @@
|
|
1
1
|
cloudpss/__init__.py,sha256=Ov8K45KxSsPalPErvTRUb2GvPdJ3myucFqx7s37_YZo,777
|
2
2
|
cloudpss/verify.py,sha256=KF4Gd59DGvCyIEkRD7rNnekWw22XxJpi3DW6keb6j4c,1498
|
3
|
-
cloudpss/version.py,sha256=
|
3
|
+
cloudpss/version.py,sha256=X2FSVyXfKfCh487cbRC3bWEH0TAFIoyQIus2dzhKa3U,21
|
4
4
|
cloudpss/dslab/DSLabFinancialResult.py,sha256=7_ho5Xzm9ufcMXo1wCjxJe4VQxqod-6jpvVF3XjlXcw,3612
|
5
5
|
cloudpss/dslab/__init__.py,sha256=rm3bUFSet3KZYrkKo6pfMBNfjvR3U1rwnTnEA5sE87Q,44
|
6
|
-
cloudpss/dslab/dataManageModel.py,sha256=
|
7
|
-
cloudpss/dslab/dslab.py,sha256=
|
6
|
+
cloudpss/dslab/dataManageModel.py,sha256=_a_LiZvnOup71ehgRlI5Rzu1tMO9zSF5AVBlAWcRh90,10710
|
7
|
+
cloudpss/dslab/dslab.py,sha256=XqbciGqDd22d5u983ysQQpizHBwFzuVBeGcGdIr8Ksc,8848
|
8
8
|
cloudpss/dslab/financialAnalysisModel.py,sha256=o-s6rR74UIjj5V9oB9fjdyo3Q3ogtY3QPhxSXbiBHXk,5058
|
9
9
|
cloudpss/dslab/files/__init__.py,sha256=l2g0VadtTiMW39zwCwHPHUC01Kbklb_nFUPVeQ16FwM,58
|
10
10
|
cloudpss/dslab/files/curveData.py,sha256=InlQ_6ZfVkFdhK65PldvIbw_X7Pys2ci4jexZ0flL6c,4291324
|
@@ -19,6 +19,22 @@ cloudpss/ieslab/IESLabPlan.py,sha256=vWRExT0AE5VbR1DaQSINE65sbg0F6cXC7meXNT6Ap6Q
|
|
19
19
|
cloudpss/ieslab/IESLabSimulation.py,sha256=sd27IZ2NIGqUQWWVsobUOOY_7b1QzVbUMeSmFWKianw,1746
|
20
20
|
cloudpss/ieslab/PlanModel.py,sha256=Dk5ZS_8IASqzMlLeN_gIDk76Gm_ybXjGY4pULBsWvEw,4790
|
21
21
|
cloudpss/ieslab/__init__.py,sha256=kiyUaGRgtwqs0EI2dBBqLVK5V65u1PcY7YTFJX1T0yw,186
|
22
|
+
cloudpss/job/__init__.py,sha256=3UIFZYjJTzuckM61o8kim1c3PWt2SSHTL72jrGu5IzI,51
|
23
|
+
cloudpss/job/job.py,sha256=wgw0haur_-4W51vecgSSqKqH7TPmjIa218yJn3TOO6k,8267
|
24
|
+
cloudpss/job/jobMachine.py,sha256=wtJ7X9Cu-4KGpYvxLbvCVWv5Ku0CvsgmfThK8knLfoI,268
|
25
|
+
cloudpss/job/jobPolicy.py,sha256=k5Ur9LYvTnWNgI9yqeCjs5E499DSOrYbYgywU8-zpC4,4083
|
26
|
+
cloudpss/job/jobQueue.py,sha256=31Q7NCjb_51d1JOokVyxIfP1r6S_A-ObySJKwt8MxR8,416
|
27
|
+
cloudpss/job/jobReceiver.py,sha256=kX59JLky86AXwgCWw0abfKu-yDWQ97YAV-sOObF5Kgk,740
|
28
|
+
cloudpss/job/jobTres.py,sha256=1wwdvwxpYKOfsZ1R95Wkhyg_QYMzqzKoaLJLdB-bD88,148
|
29
|
+
cloudpss/job/messageStreamReceiver.py,sha256=PZU31qIz0ly_Mmk2K1m23Wo6I7MxCnrbZfEYhrNWZZQ,3512
|
30
|
+
cloudpss/job/messageStreamSender.py,sha256=kVUrmnMCAFWwmINBzXbNvW09OyZ74UtdCrx5JhlzRwM,2097
|
31
|
+
cloudpss/job/view/EMTView.py,sha256=odEWQVEkHkx75EyN-vk9W05yXvTjBOHfWxhFJrBgv1I,6839
|
32
|
+
cloudpss/job/view/IESLabSimulationView.py,sha256=_hD-fdEwC6U8hQYbXliNMEii0WxiteglQZuLOSQmMOM,76
|
33
|
+
cloudpss/job/view/IESLabTypicalDayView.py,sha256=Za57f9TYcBxYeKo8fnEcOjl517v1LMDN0ua537fxcjc,1168
|
34
|
+
cloudpss/job/view/IESView.py,sha256=bf654u2GFIarhtbPm4bgpUwzpc_hVqSCdw9dDPxKpnU,3755
|
35
|
+
cloudpss/job/view/PowerFlowView.py,sha256=xg-KX37ENxYtEV7CRUszXfsyDmTsOKCh7agSg5K6EWQ,2089
|
36
|
+
cloudpss/job/view/__init__.py,sha256=j_X6aFeY-wa6_0r1EixE0rrvGz_67m4fIqOLmUbkxqY,1466
|
37
|
+
cloudpss/job/view/view.py,sha256=piPoryU3gXBMNuXxuKBXhJEwM8EYHpVRU2Sq_mNoVcM,3150
|
22
38
|
cloudpss/model/__init__.py,sha256=SNq-bfwcQtDHtTNBYppfUEs8wkjfrQfGeywx7igmvOs,151
|
23
39
|
cloudpss/model/jobDefinitions.py,sha256=XqjaaWOLU7zlVHM7TQJbZ3rNBWfBY7eT-5aE6EAatcQ,3770
|
24
40
|
cloudpss/model/model.py,sha256=cMIkamN5wbtCtqQTjgQ8hRa6-oso6HQfnuYklwJXOII,25712
|
@@ -41,14 +57,14 @@ cloudpss/runner/result.py,sha256=MkoTQly7FjKj9mde3bnv4vBDfGJ2U4eK-HhxxdwmemE,131
|
|
41
57
|
cloudpss/runner/runner.py,sha256=NbBJfCVFk9n3eYsQSjTaK12zohwqKYak-lEEOo8vWDo,5316
|
42
58
|
cloudpss/runner/storage.py,sha256=zFET_zwPIOF2Cnh9sgFiS0HFxV1OmVsU34bGUQ6PpkA,4162
|
43
59
|
cloudpss/runner/transform.py,sha256=krOgTZiJSJAb5QSwerAqlbC4Ma0PKi__0WOZlAxw4O8,11613
|
44
|
-
cloudpss/utils/IO.py,sha256=
|
60
|
+
cloudpss/utils/IO.py,sha256=Uh1NOlBn15Jl5_aWS2QRO2-QsKlFT9o8DPtP8-8Z2PA,5314
|
45
61
|
cloudpss/utils/__init__.py,sha256=NU5ZAeXH733nJKooH_1cdT9ntPEYRG4Kk3PA7P6bK_s,291
|
46
62
|
cloudpss/utils/dataEncoder.py,sha256=5PUPb844eOGgFnYrMM8bdjdKH_MZz0lk-67uo8TvwEo,885
|
47
63
|
cloudpss/utils/graphqlUtil.py,sha256=swl6XT1UmUQHdHjMWw3M0i8meEmVKNQvX0SHsbgg8TU,255
|
48
|
-
cloudpss/utils/httprequests.py,sha256
|
64
|
+
cloudpss/utils/httprequests.py,sha256=-RYi1Dc4QDqqupuw0x-lq74dFvCqPrZfCJKgrdolEpk,1643
|
49
65
|
cloudpss/utils/matlab.py,sha256=SLwVt790BjklJK2XNELt9R2n_1ej9Y8QsTIdFkKXLWE,795
|
50
66
|
cloudpss/utils/yamlLoader.py,sha256=KRlRkHFltOjqxa_sesdBLf1W5J7XTgvubszsSw-XR0U,2885
|
51
|
-
cloudpss-4.0.
|
52
|
-
cloudpss-4.0.
|
53
|
-
cloudpss-4.0.
|
54
|
-
cloudpss-4.0.
|
67
|
+
cloudpss-4.0.2.dist-info/METADATA,sha256=B5ede-aq6jNV-jXKAtp_qF_KDrz-Z2ZekA90onhHEVA,2318
|
68
|
+
cloudpss-4.0.2.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
69
|
+
cloudpss-4.0.2.dist-info/top_level.txt,sha256=wS9qPU4-aWM9ouzMOx34Nlq-GkdQKpr9vBskwut1BD8,9
|
70
|
+
cloudpss-4.0.2.dist-info/RECORD,,
|
File without changes
|
File without changes
|