cloudpss 4.0.4__py3-none-any.whl → 4.0.5__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/version.py +1 -1
- {cloudpss-4.0.4.dist-info → cloudpss-4.0.5.dist-info}/METADATA +1 -1
- {cloudpss-4.0.4.dist-info → cloudpss-4.0.5.dist-info}/RECORD +5 -33
- cloudpss/asyncio/__init__.py +0 -8
- cloudpss/asyncio/job/__init__.py +0 -5
- cloudpss/asyncio/job/job.py +0 -116
- cloudpss/asyncio/job/messageStreamReceiver.py +0 -121
- cloudpss/asyncio/job/messageStreamSender.py +0 -45
- cloudpss/asyncio/model/__init__.py +0 -5
- cloudpss/asyncio/model/model.py +0 -257
- cloudpss/asyncio/model/revision.py +0 -41
- cloudpss/asyncio/model/topology.py +0 -34
- cloudpss/asyncio/utils/AsyncIterable.py +0 -27
- cloudpss/asyncio/utils/__init__.py +0 -6
- cloudpss/asyncio/utils/httpAsyncRequest.py +0 -68
- cloudpss/job/__init__.py +0 -5
- cloudpss/job/job.py +0 -260
- cloudpss/job/jobMachine.py +0 -11
- cloudpss/job/jobPolicy.py +0 -127
- cloudpss/job/jobQueue.py +0 -14
- cloudpss/job/jobReceiver.py +0 -39
- cloudpss/job/jobTres.py +0 -6
- cloudpss/job/messageStreamReceiver.py +0 -146
- cloudpss/job/messageStreamSender.py +0 -93
- cloudpss/job/view/EMTView.py +0 -214
- cloudpss/job/view/IESLabSimulationView.py +0 -5
- cloudpss/job/view/IESLabTypicalDayView.py +0 -136
- cloudpss/job/view/IESView.py +0 -105
- cloudpss/job/view/PowerFlowView.py +0 -80
- cloudpss/job/view/__init__.py +0 -42
- cloudpss/job/view/view.py +0 -160
- {cloudpss-4.0.4.dist-info → cloudpss-4.0.5.dist-info}/WHEEL +0 -0
- {cloudpss-4.0.4.dist-info → cloudpss-4.0.5.dist-info}/top_level.txt +0 -0
cloudpss/job/view/IESView.py
DELETED
@@ -1,105 +0,0 @@
|
|
1
|
-
import copy
|
2
|
-
import collections
|
3
|
-
|
4
|
-
from cloudpss.job.view.view import View
|
5
|
-
|
6
|
-
class IESView(View):
|
7
|
-
"""
|
8
|
-
综合能源结果视图,
|
9
|
-
|
10
|
-
提供快捷 plot 数据的接口函数,获取到的 plot 数据为合并后的数据格式,不在是接收时分段的数据
|
11
|
-
|
12
|
-
该类只提供 IES 仿真使用
|
13
|
-
|
14
|
-
"""
|
15
|
-
|
16
|
-
|
17
|
-
def __init__(self,receiver,sender) -> None:
|
18
|
-
super().__init__(receiver,sender)
|
19
|
-
self.result = {'Sankey': []}
|
20
|
-
# self._receiver = receiver
|
21
|
-
|
22
|
-
|
23
|
-
def __readPlotResult(self):
|
24
|
-
for val in self._receiver:
|
25
|
-
if val['type'] == 'plot':
|
26
|
-
key = val['key']
|
27
|
-
if key == 'Sankey':
|
28
|
-
self.result['Sankey'].append(copy.deepcopy(val))
|
29
|
-
else:
|
30
|
-
if self.result.get(key, None) is None:
|
31
|
-
self.result[key] = copy.deepcopy(val)
|
32
|
-
else:
|
33
|
-
traces = val['data']['traces']
|
34
|
-
for i in range(len(traces)):
|
35
|
-
v = traces[i]
|
36
|
-
self.result[key]['data']['traces'][i][
|
37
|
-
'x'].extend(v['x'])
|
38
|
-
self.result[key]['data']['traces'][i][
|
39
|
-
'y'].extend(v['y'])
|
40
|
-
|
41
|
-
def getPlotData(self, compID, labelName, traceName='all', index=-1):
|
42
|
-
'''
|
43
|
-
获取元件ID为compID的元件,对应标签为labelName、图例名称为traceName的plot 数据的第index项
|
44
|
-
|
45
|
-
:params: compID string类型,代表元件的标识符
|
46
|
-
:params: labelName string类型,代表plot曲线的分组标签
|
47
|
-
:params: traceName string类型,代表Plot曲线对应分组下的图例名称,当为'all'时,返回所有图例的数据
|
48
|
-
:params: index int类型,代表对应图例时序数据中的第index项,当小于0时,返回该图例所有的时序数据
|
49
|
-
|
50
|
-
:return: dict类型
|
51
|
-
'''
|
52
|
-
self.__readPlotResult()
|
53
|
-
key = compID + '_' + labelName
|
54
|
-
if key not in self.result.keys():
|
55
|
-
raise Exception('未找到元件标志为{0},对应label为{1}的plot数据'.format(
|
56
|
-
compID, labelName))
|
57
|
-
|
58
|
-
traceData = self.result[key]['data']['traces']
|
59
|
-
if traceName != 'all':
|
60
|
-
traceNameList = [traceName]
|
61
|
-
else:
|
62
|
-
traceNameList = [
|
63
|
-
traceData[i]['name'] for i in range(len(traceData))
|
64
|
-
]
|
65
|
-
|
66
|
-
startIndex = 0
|
67
|
-
endIndex = len(traceData[0]['x'])
|
68
|
-
if index >= 0:
|
69
|
-
startIndex = index
|
70
|
-
endIndex = index + 1
|
71
|
-
|
72
|
-
plotData = collections.defaultdict(lambda: {})
|
73
|
-
for tName in traceNameList:
|
74
|
-
for i in range(len(traceData)):
|
75
|
-
dataLen = len(traceData[i]['x'])
|
76
|
-
if traceData[i]['name'] == tName:
|
77
|
-
if endIndex > dataLen:
|
78
|
-
raise Exception('请求的index超过了plot数据序列的长度')
|
79
|
-
plotData[tName]['x'] = traceData[i]['x'][
|
80
|
-
startIndex:endIndex]
|
81
|
-
plotData[tName]['y'] = traceData[i]['y'][
|
82
|
-
startIndex:endIndex]
|
83
|
-
|
84
|
-
return plotData
|
85
|
-
|
86
|
-
|
87
|
-
def getSankey(self, index):
|
88
|
-
'''
|
89
|
-
获取第index个桑基图数据
|
90
|
-
|
91
|
-
>>> result.getSankey(index)
|
92
|
-
{...}
|
93
|
-
'''
|
94
|
-
self.__readPlotResult()
|
95
|
-
if index >= len(self.result['Sankey']):
|
96
|
-
raise Exception('index超过了桑基图数据序列的长度')
|
97
|
-
return self.result['Sankey'][index]
|
98
|
-
def getSankeyNum(self):
|
99
|
-
'''
|
100
|
-
获取桑基图数据序列的长度
|
101
|
-
|
102
|
-
>>> result.getSankeyNum()
|
103
|
-
'''
|
104
|
-
self.__readPlotResult()
|
105
|
-
return len(self.result['Sankey'])
|
@@ -1,80 +0,0 @@
|
|
1
|
-
import copy
|
2
|
-
import re
|
3
|
-
|
4
|
-
from .view import View
|
5
|
-
|
6
|
-
|
7
|
-
class PowerFlowView(View):
|
8
|
-
"""
|
9
|
-
潮流结果视图,
|
10
|
-
|
11
|
-
提供快速获取 buses 和 branches 的接口,并提供潮流写入项目的接口
|
12
|
-
|
13
|
-
该类只提供潮流仿真时使用
|
14
|
-
|
15
|
-
"""
|
16
|
-
|
17
|
-
def getBuses(self):
|
18
|
-
"""
|
19
|
-
获取所有的 buses 数据
|
20
|
-
|
21
|
-
>>> view.getBuses()
|
22
|
-
[...]
|
23
|
-
"""
|
24
|
-
result = []
|
25
|
-
pattern = re.compile("value=\"(.*)\"")
|
26
|
-
data = self.getMessagesByKey('buses-table')
|
27
|
-
if len(data) == 0:
|
28
|
-
return []
|
29
|
-
table = copy.deepcopy(data[0])
|
30
|
-
columns = table['data']['columns']
|
31
|
-
for column in columns:
|
32
|
-
if column['type'] == 'html':
|
33
|
-
data = column['data']
|
34
|
-
for i in range(len(data)):
|
35
|
-
if data[i] != '':
|
36
|
-
s = pattern.findall(data[i])
|
37
|
-
data[i] = s[0].replace('/', '')
|
38
|
-
|
39
|
-
result.append(table)
|
40
|
-
return result
|
41
|
-
|
42
|
-
|
43
|
-
def getBranches(self):
|
44
|
-
"""
|
45
|
-
获取潮流结果 branches 数据
|
46
|
-
|
47
|
-
>>> view.getBranches()
|
48
|
-
[...]
|
49
|
-
"""
|
50
|
-
|
51
|
-
result = []
|
52
|
-
pattern = re.compile("value=\"(.*)\"")
|
53
|
-
data = self.getMessagesByKey('branches-table')
|
54
|
-
if len(data) == 0:
|
55
|
-
return []
|
56
|
-
table = copy.deepcopy(data[0])
|
57
|
-
|
58
|
-
columns = table['data']['columns']
|
59
|
-
for column in columns:
|
60
|
-
if column['type'] == 'html':
|
61
|
-
data = column['data']
|
62
|
-
for i in range(len(data)):
|
63
|
-
if data[i] != '':
|
64
|
-
s = pattern.findall(data[i])
|
65
|
-
data[i] = s[0].replace('/', '')
|
66
|
-
|
67
|
-
result.append(table)
|
68
|
-
return result
|
69
|
-
|
70
|
-
def powerFlowModify(self, model):
|
71
|
-
"""
|
72
|
-
潮流数据写入 model
|
73
|
-
|
74
|
-
>>> view.powerFlowModify(model)
|
75
|
-
"""
|
76
|
-
|
77
|
-
data = self.getMessagesByKey('power-flow-modify')
|
78
|
-
if len(data) == 0:
|
79
|
-
raise Exception('未找到到数据')
|
80
|
-
self.modify(data[0], model)
|
cloudpss/job/view/__init__.py
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
from .IESView import IESView
|
2
|
-
from .view import View
|
3
|
-
from .EMTView import EMTView
|
4
|
-
from .PowerFlowView import PowerFlowView
|
5
|
-
from .IESLabSimulationView import IESLabSimulationView
|
6
|
-
from .IESLabTypicalDayView import IESLabTypicalDayView
|
7
|
-
from ..messageStreamReceiver import MessageStreamReceiver
|
8
|
-
from ..messageStreamSender import MessageStreamSender
|
9
|
-
__all__ = [
|
10
|
-
'View','EMTView','PowerFlowView','IESLabSimulationView','IESView','IESLabTypicalDayView'
|
11
|
-
]
|
12
|
-
|
13
|
-
VIEW = {
|
14
|
-
'function/CloudPSS/emtp': EMTView,
|
15
|
-
'function/CloudPSS/emtps': EMTView,
|
16
|
-
'function/CloudPSS/sfemt': EMTView,
|
17
|
-
'function/CloudPSS/power-flow': PowerFlowView,
|
18
|
-
'function/CloudPSS/ies-simulation': IESView,
|
19
|
-
'function/CloudPSS/ies-optimization': IESView,
|
20
|
-
'function/ies/ies-optimization': IESView,
|
21
|
-
'function/CloudPSS/three-phase-powerFlow': PowerFlowView,
|
22
|
-
'function/ies/ies-simulation': IESLabSimulationView,
|
23
|
-
'function/ies/ies-gmm':IESLabTypicalDayView,
|
24
|
-
'function/CloudPSS/ieslab-simulation': IESLabSimulationView,
|
25
|
-
'function/CloudPSS/ieslab-gmm':IESLabTypicalDayView,
|
26
|
-
'function/CloudPSS/ieslab-optimization': IESView,
|
27
|
-
}
|
28
|
-
|
29
|
-
|
30
|
-
def getViewClass(rid: str) -> View:
|
31
|
-
"""
|
32
|
-
获取仿真结果视图
|
33
|
-
|
34
|
-
:param rid: 仿真任务的 rid
|
35
|
-
:param db: 仿真任务的数据库
|
36
|
-
|
37
|
-
:return: 仿真结果视图
|
38
|
-
|
39
|
-
>>> view = get_view('function/CloudPSS/emtp', db)
|
40
|
-
>>> view.getPlots()
|
41
|
-
"""
|
42
|
-
return VIEW.get(rid, View)
|
cloudpss/job/view/view.py
DELETED
@@ -1,160 +0,0 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
import sys
|
4
|
-
from deprecated import deprecated
|
5
|
-
from ..messageStreamSender import MessageStreamSender
|
6
|
-
from ..messageStreamReceiver import MessageStreamReceiver
|
7
|
-
|
8
|
-
class View(object):
|
9
|
-
"""
|
10
|
-
结果视图基类,提供基础的结果获取接口
|
11
|
-
"""
|
12
|
-
def __init__(self, receiver:MessageStreamReceiver,sender:MessageStreamSender=None) -> None:
|
13
|
-
"""
|
14
|
-
初始化
|
15
|
-
"""
|
16
|
-
self.result = {}
|
17
|
-
self._receiver = receiver
|
18
|
-
self._sender = sender
|
19
|
-
self.__logsIndex = 0
|
20
|
-
|
21
|
-
async def receive(self):
|
22
|
-
async for msg in self._receiver:
|
23
|
-
yield msg
|
24
|
-
|
25
|
-
def __len__(self):
|
26
|
-
return len(self._receiver)
|
27
|
-
|
28
|
-
def __iter__(self):
|
29
|
-
return self
|
30
|
-
def __next__(self):
|
31
|
-
return next(self._receiver)
|
32
|
-
|
33
|
-
def __deepModify(self, dict1, dict2):
|
34
|
-
|
35
|
-
for key, val in dict1.items():
|
36
|
-
if type(val) is dict:
|
37
|
-
self.__deepModify(val, dict2[key])
|
38
|
-
else:
|
39
|
-
dict2[key] = val
|
40
|
-
|
41
|
-
def modify(self, data, model):
|
42
|
-
"""
|
43
|
-
通过指定消息修改算例文件
|
44
|
-
|
45
|
-
:params: data 消息字典 {}
|
46
|
-
:params: model 项目
|
47
|
-
|
48
|
-
>>> message= view.modify(data,model)
|
49
|
-
|
50
|
-
"""
|
51
|
-
modifyData = data['data']
|
52
|
-
payload = modifyData['payload']
|
53
|
-
self.__deepModify(payload, model)
|
54
|
-
|
55
|
-
def getMessagesByKey(self, key):
|
56
|
-
"""
|
57
|
-
获取指定 key 的消息数据
|
58
|
-
|
59
|
-
:params key: 数据key
|
60
|
-
|
61
|
-
:returns: 对应 key 的数据数组
|
62
|
-
|
63
|
-
>>> message= db.getMessagesByKey('log')
|
64
|
-
"""
|
65
|
-
|
66
|
-
result = []
|
67
|
-
for val in self._receiver.messages:
|
68
|
-
if val.get('key', None) == key:
|
69
|
-
result.append(val)
|
70
|
-
return result
|
71
|
-
|
72
|
-
def getMessagesByType(self, type):
|
73
|
-
"""
|
74
|
-
获取指定类型的消息数据
|
75
|
-
|
76
|
-
:params type: 数据类型
|
77
|
-
|
78
|
-
:returns: 对应类型的数据数组
|
79
|
-
|
80
|
-
>>> message= db.getMessagesByType('log')
|
81
|
-
"""
|
82
|
-
|
83
|
-
result = []
|
84
|
-
for val in self._receiver:
|
85
|
-
if val['type'] == type:
|
86
|
-
result.append(val)
|
87
|
-
return result
|
88
|
-
|
89
|
-
def getMessage(self, index):
|
90
|
-
"""
|
91
|
-
获取指定位置的消息数据
|
92
|
-
|
93
|
-
:params index: 数据的位置信息
|
94
|
-
|
95
|
-
:returns: 消息数据
|
96
|
-
|
97
|
-
>>> message= db.getMessage(1)
|
98
|
-
"""
|
99
|
-
return self._receiver.messages[index]
|
100
|
-
|
101
|
-
def getMessages(self):
|
102
|
-
"""
|
103
|
-
获取所有消息数据
|
104
|
-
|
105
|
-
:returns: 消息数据数组
|
106
|
-
"""
|
107
|
-
return self._receiver.messages
|
108
|
-
|
109
|
-
|
110
|
-
def getLogs(self):
|
111
|
-
'''
|
112
|
-
获取当前任务的日志
|
113
|
-
|
114
|
-
>>>logs= result.getLogs()
|
115
|
-
{...}
|
116
|
-
'''
|
117
|
-
result = []
|
118
|
-
length = len(self._receiver.messages)
|
119
|
-
if (length > self.__logsIndex):
|
120
|
-
for num in range(self.__logsIndex, length):
|
121
|
-
val = self.getMessage(num)
|
122
|
-
if val['type'] == 'log':
|
123
|
-
result.append(val)
|
124
|
-
self.__logsIndex = length
|
125
|
-
return result
|
126
|
-
|
127
|
-
def getMessageLength(self):
|
128
|
-
"""
|
129
|
-
获取消息数据的长度
|
130
|
-
|
131
|
-
:returns: 消息数据的长度
|
132
|
-
"""
|
133
|
-
return len(self._receiver.messages)
|
134
|
-
|
135
|
-
|
136
|
-
def waitFor(self,timeOut=sys.maxsize):
|
137
|
-
"""
|
138
|
-
阻塞方法,直到任务完成
|
139
|
-
|
140
|
-
:params timeOut: 超时时间
|
141
|
-
"""
|
142
|
-
return self._receiver.waitFor(timeOut)
|
143
|
-
|
144
|
-
@property
|
145
|
-
@deprecated(version='3.0', reason="该方法将在 5.0 版本移除")
|
146
|
-
def db(self):
|
147
|
-
"""
|
148
|
-
获取数据库对象
|
149
|
-
|
150
|
-
:returns: 数据库对象
|
151
|
-
"""
|
152
|
-
return self._receiver
|
153
|
-
|
154
|
-
def pop(self,index=-1):
|
155
|
-
"""
|
156
|
-
pop 出缓存中的消息
|
157
|
-
|
158
|
-
:returns: 消息数据
|
159
|
-
"""
|
160
|
-
return self._receiver.messages.pop(index)
|
File without changes
|
File without changes
|