cloudpss 4.1.1b9__py3-none-any.whl → 4.5.1__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/__init__.py +2 -3
- cloudpss/asyncio/job/job.py +2 -2
- cloudpss/function/functionExecution.py +26 -3
- cloudpss/ieslab/DataManageModel.py +119 -46
- cloudpss/ieslab/EvaluationModel.py +80 -9
- cloudpss/ieslab/IESLabOpt.py +235 -0
- cloudpss/ieslab/IESLabPlan.py +4 -4
- cloudpss/ieslab/PlanModel.py +271 -32
- cloudpss/ieslab/__init__.py +2 -1
- cloudpss/job/job.py +27 -19
- cloudpss/job/jobReceiver.py +2 -2
- cloudpss/job/{view/EMTView.py → result/EMTResult.py} +2 -2
- cloudpss/job/result/IESLabSimulationResult.py +5 -0
- cloudpss/job/{view/IESLabTypicalDayView.py → result/IESLabTypicalDayResult.py} +3 -3
- cloudpss/job/{view/IESView.py → result/IESResult.py} +2 -2
- cloudpss/job/{view/PowerFlowView.py → result/PowerFlowResult.py} +2 -2
- cloudpss/job/result/__init__.py +39 -0
- cloudpss/job/{view/view.py → result/result.py} +1 -1
- cloudpss/model/model.py +82 -47
- cloudpss/model/revision.py +3 -3
- cloudpss/model/topology.py +2 -2
- cloudpss/runner/IESLabEvaluationResult.py +14 -6
- cloudpss/runner/IESLabPlanResult.py +91 -35
- cloudpss/runner/IESLabTypicalDayResult.py +62 -50
- cloudpss/runner/MessageStreamReceiver.py +5 -102
- cloudpss/runner/result.py +6 -1
- cloudpss/runner/runner.py +77 -48
- cloudpss/utils/IO.py +1 -1
- cloudpss/utils/graphqlUtil.py +3 -2
- cloudpss/utils/httprequests.py +11 -4
- cloudpss/version.py +1 -1
- {cloudpss-4.1.1b9.dist-info → cloudpss-4.5.1.dist-info}/METADATA +2 -2
- cloudpss-4.5.1.dist-info/RECORD +70 -0
- cloudpss/dslab/__init__.py +0 -2
- cloudpss/dslab/dataManageModel.py +0 -275
- cloudpss/dslab/dslab.py +0 -304
- cloudpss/dslab/files/__init__.py +0 -2
- cloudpss/dslab/files/curveData.py +0 -140229
- cloudpss/dslab/files/files.py +0 -27
- cloudpss/dslab/financialAnalysisModel.py +0 -137
- cloudpss/job/view/IESLabSimulationView.py +0 -5
- cloudpss/job/view/__init__.py +0 -42
- cloudpss/runner/DSLabResult.py +0 -92
- cloudpss-4.1.1b9.dist-info/RECORD +0 -77
- {cloudpss-4.1.1b9.dist-info → cloudpss-4.5.1.dist-info}/WHEEL +0 -0
- {cloudpss-4.1.1b9.dist-info → cloudpss-4.5.1.dist-info}/top_level.txt +0 -0
cloudpss/ieslab/IESLabPlan.py
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
import json
|
2
2
|
|
3
3
|
from cloudpss.ieslab.DataManageModel import IESPlanDataManageModel
|
4
|
-
from cloudpss.ieslab.EvaluationModel import
|
4
|
+
from cloudpss.ieslab.EvaluationModel import IESLabPlanEvaluationModel
|
5
5
|
from cloudpss.ieslab.PlanModel import IESLabPlanModel
|
6
6
|
from cloudpss.runner.IESLabTypicalDayResult import IESLabTypicalDayResult
|
7
7
|
from ..utils import request
|
8
8
|
from ..model.model import Model
|
9
9
|
from cloudpss.runner.runner import Runner
|
10
10
|
from cloudpss.runner.IESLabPlanResult import IESLabPlanResult
|
11
|
-
from cloudpss.runner.IESLabEvaluationResult import
|
11
|
+
from cloudpss.runner.IESLabEvaluationResult import IESLabPlanEvaluationResult
|
12
12
|
|
13
13
|
class IESLabPlan(object):
|
14
14
|
def __init__(self, project={}):
|
@@ -23,9 +23,9 @@ class IESLabPlan(object):
|
|
23
23
|
self.model = Model.fetch(self.__modelRid)
|
24
24
|
self.dataManageModel = IESPlanDataManageModel(self.id)
|
25
25
|
self.planModel = IESLabPlanModel(self.id)
|
26
|
-
self.evaluationModel =
|
26
|
+
self.evaluationModel = IESLabPlanEvaluationModel(self.id)
|
27
27
|
self.currentPlanResult = IESLabPlanResult(self.id)
|
28
|
-
self.currentEvaluationResult =
|
28
|
+
self.currentEvaluationResult = IESLabPlanEvaluationResult(self.id)
|
29
29
|
|
30
30
|
@staticmethod
|
31
31
|
def fetch(simulationId):
|
cloudpss/ieslab/PlanModel.py
CHANGED
@@ -1,12 +1,15 @@
|
|
1
|
-
from cloudpss.runner.IESLabPlanResult import IESLabPlanResult
|
2
|
-
from cloudpss.runner.runner import HttpRunner,
|
1
|
+
from cloudpss.runner.IESLabPlanResult import IESLabPlanResult, IESLabOptResult
|
2
|
+
from cloudpss.runner.runner import HttpRunner, HttpOPTRunner
|
3
|
+
from cloudpss.model import Model
|
4
|
+
from cloudpss.model.revision import ModelRevision
|
3
5
|
from ..utils import request, fileLoad
|
4
6
|
import json
|
5
7
|
from enum import IntEnum, unique
|
6
8
|
|
7
9
|
|
8
10
|
class IESLabPlanModel(object):
|
9
|
-
_baseUri = 'api/ieslab-plan/
|
11
|
+
_baseUri = 'api/ieslab-plan/rest'
|
12
|
+
_runUri = 'api/ieslab-plan/taskmanager'
|
10
13
|
|
11
14
|
def __init__(self, simulationId):
|
12
15
|
'''
|
@@ -14,44 +17,83 @@ class IESLabPlanModel(object):
|
|
14
17
|
'''
|
15
18
|
self.simulationId = simulationId
|
16
19
|
self.optimizationInfo = self.GetOptimizationInfo()
|
17
|
-
self.OptimizationMode = OptimizationMode
|
20
|
+
# self.OptimizationMode = OptimizationMode
|
18
21
|
|
19
|
-
def _fetchItemData(self, url):
|
22
|
+
def _fetchItemData(self, url, params):
|
20
23
|
'''
|
21
24
|
获取当前算例的优化目标设置信息
|
22
25
|
|
23
|
-
:return:
|
26
|
+
:return: List 类型,包括优化目标和全局参数储能动作灵敏度,若没有设置则返回 []
|
24
27
|
'''
|
25
|
-
r = request('GET', url, params=
|
28
|
+
r = request('GET', url, params=params)
|
26
29
|
data = json.loads(r.text)
|
27
|
-
return data
|
30
|
+
return data['results']
|
28
31
|
|
29
32
|
def GetOptimizationInfo(self):
|
30
33
|
'''
|
31
34
|
获取当前算例的优化目标设置信息
|
32
35
|
|
33
|
-
:return:
|
36
|
+
:return: Dict 类型,例如:{'OptimizationMode': <OptimizationMode.经济性: 0>, 'StoSen': 0.1}
|
34
37
|
'''
|
35
38
|
try:
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
39
|
+
url = f'{self._baseUri}/simuOpt/'
|
40
|
+
params = {"simu_id": self.simulationId}
|
41
|
+
r = self._fetchItemData(url, params)
|
42
|
+
if (len(r) == 0):
|
43
|
+
return {
|
44
|
+
"OptimizationMode": OptimizationMode['经济性'],
|
45
|
+
"StoSen": 0.1
|
46
|
+
}
|
47
|
+
else:
|
48
|
+
value = json.loads(r[0]['opt_params'])
|
49
|
+
return {
|
50
|
+
"OptimizationMode": OptimizationMode(value['OptimizationMode']),
|
51
|
+
"StoSen": value['StoSen']
|
52
|
+
}
|
41
53
|
except:
|
42
|
-
|
54
|
+
raise Exception('获得优化目标设置失败')
|
43
55
|
|
44
|
-
def SetOptimizationInfo(self,
|
56
|
+
def SetOptimizationInfo(self, data: dict):
|
45
57
|
'''
|
46
|
-
无对应接口
|
47
58
|
设置当前算例的优化目标
|
48
59
|
|
49
|
-
:param
|
50
|
-
'''
|
51
|
-
self.optimizationInfo = optType
|
52
|
-
return True
|
60
|
+
:param data: dict 类型,例如:{'OptimizationMode': <OptimizationMode.经济性: 0>, 'StoSen': 0.1}
|
53
61
|
|
54
|
-
|
62
|
+
:return: boolean 类型,为 True 则设置成功
|
63
|
+
'''
|
64
|
+
try:
|
65
|
+
url = f'{self._baseUri}/simuOpt/'
|
66
|
+
params = {"simu_id": self.simulationId}
|
67
|
+
r = self._fetchItemData(url, params)
|
68
|
+
opt_params = {
|
69
|
+
"OptimizationMode": data.get('OptimizationMode', '').value,
|
70
|
+
"StoSen": data.get('StoSen', ''),
|
71
|
+
"ProjectPeriod": "20"
|
72
|
+
}
|
73
|
+
if(len(r) == 0):
|
74
|
+
payload = {
|
75
|
+
"simu_id": self.simulationId,
|
76
|
+
"opt_params": json.dumps(opt_params)
|
77
|
+
}
|
78
|
+
r = request('POST',
|
79
|
+
url,
|
80
|
+
data=json.dumps(payload))
|
81
|
+
return True
|
82
|
+
else:
|
83
|
+
url2 = f'{self._baseUri}/simuOpt/{r[0]["id"]}/'
|
84
|
+
payload = {
|
85
|
+
"simu_id": self.simulationId,
|
86
|
+
"opt_params": json.dumps(opt_params),
|
87
|
+
"id": r[0]["id"]
|
88
|
+
}
|
89
|
+
r = request('PUT',
|
90
|
+
url2,
|
91
|
+
data=json.dumps(payload))
|
92
|
+
return True
|
93
|
+
except:
|
94
|
+
return False
|
95
|
+
|
96
|
+
def run(self) -> HttpRunner[IESLabPlanResult]:
|
55
97
|
'''
|
56
98
|
生成方案优选算例
|
57
99
|
|
@@ -61,10 +103,12 @@ class IESLabPlanModel(object):
|
|
61
103
|
if isRunning:
|
62
104
|
raise Exception('该算例正在运行!请从浏览器算例页面点击结束运行或者调用IESPlan对象的kill接口终止计算后重试!')
|
63
105
|
else:
|
64
|
-
url = 'api/
|
65
|
-
|
66
|
-
self.optimizationInfo
|
67
|
-
|
106
|
+
url = f'api/{self._runUri}/runOptimization'
|
107
|
+
opt = {
|
108
|
+
"OptimizationMode": self.optimizationInfo.get('OptimizationMode', 0).value,
|
109
|
+
"ProjectPeriod": "20",
|
110
|
+
"StoSen": self.optimizationInfo.get('StoSen', 0.1)
|
111
|
+
}
|
68
112
|
try:
|
69
113
|
r = request('GET',
|
70
114
|
url,
|
@@ -72,17 +116,14 @@ class IESLabPlanModel(object):
|
|
72
116
|
"simuid":
|
73
117
|
self.simulationId,
|
74
118
|
"optPara":
|
75
|
-
json.dumps(
|
76
|
-
"OptimizationMode": optType,
|
77
|
-
"ProjectPeriod": "20"
|
78
|
-
})
|
119
|
+
json.dumps(opt)
|
79
120
|
})
|
80
121
|
data = json.loads(r.text)
|
81
122
|
return HttpRunner({}, self.simulationId)
|
82
123
|
except:
|
83
124
|
raise Exception('生成方案优选算例失败')
|
84
125
|
|
85
|
-
def GetRunner(self) ->
|
126
|
+
def GetRunner(self) -> HttpRunner[IESLabPlanResult]:
|
86
127
|
'''
|
87
128
|
获得运行实例
|
88
129
|
|
@@ -100,7 +141,7 @@ class IESLabPlanModel(object):
|
|
100
141
|
data = res.get('data', {})
|
101
142
|
if data is not None:
|
102
143
|
taskID = data.get('task_id', '')
|
103
|
-
url = f'
|
144
|
+
url = f'{self._runUri}/removeOptimizationTask'
|
104
145
|
try:
|
105
146
|
r = request('GET',
|
106
147
|
url,
|
@@ -141,6 +182,204 @@ class IESLabPlanModel(object):
|
|
141
182
|
return isRunning
|
142
183
|
|
143
184
|
|
185
|
+
|
186
|
+
class IESLabOptModel(object):
|
187
|
+
_baseUri = 'api/ieslab-opt/rest'
|
188
|
+
_runUri = 'api/ieslab-opt/taskmanager'
|
189
|
+
|
190
|
+
|
191
|
+
def __init__(self, simulationId, rid):
|
192
|
+
'''
|
193
|
+
初始化
|
194
|
+
'''
|
195
|
+
self.simulationId = simulationId
|
196
|
+
self.rid = rid
|
197
|
+
self.optimizationInfo = self.GetOptimizationInfo()
|
198
|
+
|
199
|
+
def _fetchItemData(self, url, params):
|
200
|
+
'''
|
201
|
+
获取当前算例的优化目标设置信息
|
202
|
+
|
203
|
+
:return: List 类型,包括优化目标和全局参数储能动作灵敏度,若没有设置则返回 []
|
204
|
+
'''
|
205
|
+
r = request('GET', url, params=params)
|
206
|
+
data = json.loads(r.text)
|
207
|
+
return data['results']
|
208
|
+
|
209
|
+
def GetOptimizationInfo(self):
|
210
|
+
'''
|
211
|
+
获取当前算例的优化目标设置信息
|
212
|
+
|
213
|
+
:return: Dict 类型,例如:{'OptGoal': <OptimizationMode.经济性: 0>, 'StoSen': "10", '@debug': '', 'clustering_algorithm': '0', 'num_method': '0', 'PowUnPrice': '1000', 'HeatAbandonPrice': '1000'}
|
214
|
+
'''
|
215
|
+
try:
|
216
|
+
url = f'{self._baseUri}/simuOpt/'
|
217
|
+
params = {"simu_id": self.simulationId}
|
218
|
+
r = self._fetchItemData(url, params)
|
219
|
+
if (len(r) == 0):
|
220
|
+
return {
|
221
|
+
"OptGoal": OptimizationMode['经济性'],
|
222
|
+
"StoSen": "10",
|
223
|
+
"@debug": "",
|
224
|
+
"clustering_algorithm": "0",
|
225
|
+
"num_method": "0",
|
226
|
+
"PowUnPrice": "1000",
|
227
|
+
"HeatAbandonPrice": "1000"
|
228
|
+
}
|
229
|
+
else:
|
230
|
+
value = json.loads(r[0]['opt_params'])
|
231
|
+
return {
|
232
|
+
"OptGoal": OptimizationMode(int(value['OptGoal'])),
|
233
|
+
"StoSen": value['StoSen'],
|
234
|
+
"@debug": value["@debug"],
|
235
|
+
"clustering_algorithm": value["clustering_algorithm"],
|
236
|
+
"num_method": value["num_method"],
|
237
|
+
"PowUnPrice": value["PowUnPrice"],
|
238
|
+
"HeatAbandonPrice": value["HeatAbandonPrice"]
|
239
|
+
}
|
240
|
+
except:
|
241
|
+
raise Exception('获得优化目标设置失败')
|
242
|
+
|
243
|
+
def SetOptimizationInfo(self, data: dict):
|
244
|
+
'''
|
245
|
+
设置当前算例的优化目标
|
246
|
+
|
247
|
+
:param data: dict 类型,例如:{'OptGoal': <OptimizationMode.经济性: 0>, 'StoSen': "10", '@debug': '', 'clustering_algorithm': '0', 'num_method': '0', 'PowUnPrice': '1000', 'HeatAbandonPrice': '1000'}
|
248
|
+
|
249
|
+
:return: boolean 类型,为 True 则设置成功
|
250
|
+
'''
|
251
|
+
try:
|
252
|
+
url = f'{self._baseUri}/simuOpt/'
|
253
|
+
params = {"simu_id": self.simulationId}
|
254
|
+
r = self._fetchItemData(url, params)
|
255
|
+
opt_params = {
|
256
|
+
"OptGoal": data.get('OptGoal', ''),
|
257
|
+
"StoSen": data.get('StoSen', ''),
|
258
|
+
"@debug": data.get('@debug', ''),
|
259
|
+
"clustering_algorithm": data.get('clustering_algorithm', ''),
|
260
|
+
"num_method": data.get('num_method', ''),
|
261
|
+
"PowUnPrice": data.get('PowUnPrice', ''),
|
262
|
+
"HeatAbandonPrice": data.get('HeatAbandonPrice', '')
|
263
|
+
}
|
264
|
+
if(len(r) == 0):
|
265
|
+
payload = {
|
266
|
+
"simu_id": self.simulationId,
|
267
|
+
"opt_params": json.dumps(opt_params)
|
268
|
+
}
|
269
|
+
r = request('POST',
|
270
|
+
url,
|
271
|
+
data=json.dumps(payload))
|
272
|
+
return True
|
273
|
+
else:
|
274
|
+
url2 = f'{self._baseUri}/simuOpt/{r[0]["id"]}/'
|
275
|
+
payload = {
|
276
|
+
"simu_id": self.simulationId,
|
277
|
+
"opt_params": json.dumps(opt_params),
|
278
|
+
"id": r[0]["id"]
|
279
|
+
}
|
280
|
+
r = request('PUT',
|
281
|
+
url2,
|
282
|
+
data=json.dumps(payload))
|
283
|
+
return True
|
284
|
+
except:
|
285
|
+
return False
|
286
|
+
|
287
|
+
def run(self) -> HttpOPTRunner[IESLabOptResult]:
|
288
|
+
'''
|
289
|
+
生成方案优选算例
|
290
|
+
|
291
|
+
:return: Runner[IESLabOptResult]
|
292
|
+
'''
|
293
|
+
isRunning = self.GetLastTaskResult()
|
294
|
+
if isRunning:
|
295
|
+
raise Exception('该算例正在运行!请从浏览器算例页面点击结束运行或者调用IESPlan对象的kill接口终止计算后重试!')
|
296
|
+
else:
|
297
|
+
# 通过 rid 获取 model
|
298
|
+
model = Model.fetch(self.rid)
|
299
|
+
# 通过 model 获取 revision
|
300
|
+
revision = ModelRevision.create(model.revision, model.revision.hash)
|
301
|
+
hash = revision.get('hash', '')
|
302
|
+
url = f'{self._runUri}/runOptimization'
|
303
|
+
opt = {
|
304
|
+
"OptGoal": self.optimizationInfo.get('OptGoal', 0).value,
|
305
|
+
"StoSen": self.optimizationInfo.get('StoSen', 10),
|
306
|
+
"@debug": self.optimizationInfo.get('@debug', ''),
|
307
|
+
"clustering_algorithm": self.optimizationInfo.get('clustering_algorithm', '0'),
|
308
|
+
"num_method": self.optimizationInfo.get('num_method', '0'),
|
309
|
+
"PowUnPrice": self.optimizationInfo.get('PowUnPrice', '1000'),
|
310
|
+
"HeatAbandonPrice": self.optimizationInfo.get('HeatAbandonPrice', '1000'),
|
311
|
+
}
|
312
|
+
try:
|
313
|
+
r = request('GET',
|
314
|
+
url,
|
315
|
+
params={
|
316
|
+
"simuid":
|
317
|
+
self.simulationId,
|
318
|
+
"optPara":
|
319
|
+
json.dumps(opt),
|
320
|
+
"revision": hash
|
321
|
+
})
|
322
|
+
data = json.loads(r.text)
|
323
|
+
return HttpOPTRunner({}, self.simulationId)
|
324
|
+
except:
|
325
|
+
raise Exception('生成方案优选算例失败')
|
326
|
+
|
327
|
+
def GetRunner(self) -> HttpOPTRunner[IESLabOptResult]:
|
328
|
+
'''
|
329
|
+
获得运行实例
|
330
|
+
|
331
|
+
:return: Runner[IESLabOptResult]
|
332
|
+
'''
|
333
|
+
return HttpOPTRunner({}, self.simulationId)
|
334
|
+
|
335
|
+
def kill(self) -> bool:
|
336
|
+
'''
|
337
|
+
停止并删除当前运行的优化算例
|
338
|
+
'''
|
339
|
+
res = IESLabOptResult(self.simulationId).getLastTaskResult()
|
340
|
+
error = res.get('error', 0)
|
341
|
+
if error == 0:
|
342
|
+
data = res.get('data', {})
|
343
|
+
if data is not None:
|
344
|
+
taskID = data.get('task_id', '')
|
345
|
+
url = f'{self._runUri}/removeOptimizationTask'
|
346
|
+
try:
|
347
|
+
r = request('GET',
|
348
|
+
url,
|
349
|
+
params={
|
350
|
+
"taskid": taskID,
|
351
|
+
"stopFlag": '2'
|
352
|
+
})
|
353
|
+
json.loads(r.text)
|
354
|
+
return True
|
355
|
+
except:
|
356
|
+
return False
|
357
|
+
|
358
|
+
def GetLastTaskResult(self)-> bool:
|
359
|
+
'''
|
360
|
+
获取最后一次运行的taskID的运行结果与日志
|
361
|
+
|
362
|
+
:return: boolean 类型
|
363
|
+
'''
|
364
|
+
isRunning = True
|
365
|
+
res = IESLabOptResult(self.simulationId).getLastTaskResult()
|
366
|
+
error = res.get('error', 0)
|
367
|
+
if error == 0:
|
368
|
+
data = res.get('data', {})
|
369
|
+
if data is not None:
|
370
|
+
status = data.get('status', '')
|
371
|
+
if status == 'stop':
|
372
|
+
isRunning = False
|
373
|
+
logs = IESLabOptResult(self.simulationId).GetLogs()
|
374
|
+
if logs is not None:
|
375
|
+
for log in logs:
|
376
|
+
if(log.get('data', '') == 'run ends'):
|
377
|
+
isRunning = False
|
378
|
+
break
|
379
|
+
return isRunning
|
380
|
+
|
381
|
+
|
382
|
+
|
144
383
|
# @unique
|
145
384
|
class OptimizationMode(IntEnum):
|
146
385
|
经济性 = 0
|
cloudpss/ieslab/__init__.py
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
from .IESLabSimulation import IESLabSimulation
|
2
2
|
from .IESLabPlan import IESLabPlan
|
3
3
|
from .PlanModel import OptimizationMode
|
4
|
-
|
4
|
+
from .IESLabOpt import IESLabOpt
|
5
|
+
__all__ = ['IESLabSimulation','IESLabPlan', 'OptimizationMode', 'IESLabOpt']
|
cloudpss/job/job.py
CHANGED
@@ -3,8 +3,8 @@ import random
|
|
3
3
|
import re
|
4
4
|
import time
|
5
5
|
|
6
|
-
from cloudpss.job.
|
7
|
-
from .
|
6
|
+
from cloudpss.job.result.result import Result
|
7
|
+
from .result import getResultClass
|
8
8
|
|
9
9
|
from cloudpss.utils.IO import IO
|
10
10
|
from .messageStreamReceiver import MessageStreamReceiver
|
@@ -13,7 +13,7 @@ from cloudpss.utils.graphqlUtil import graphql_request
|
|
13
13
|
from .messageStreamSender import MessageStreamSender
|
14
14
|
from typing import Any, Callable, Generic, TypeVar
|
15
15
|
F = TypeVar('F', bound=Callable[..., Any])
|
16
|
-
T = TypeVar('T', bound=Callable[...,
|
16
|
+
T = TypeVar('T', bound=Callable[..., Result])
|
17
17
|
class Job(Generic[T]):
|
18
18
|
"""docstring for Job"""
|
19
19
|
__jobQuery = """query($_a:JobInput!){
|
@@ -112,7 +112,7 @@ class Job(Generic[T]):
|
|
112
112
|
|
113
113
|
|
114
114
|
@staticmethod
|
115
|
-
def __createJobVariables(job, config, revisionHash, rid, policy, **kwargs):
|
115
|
+
def __createJobVariables(job, config, revisionHash, rid=None, policy=None, **kwargs):
|
116
116
|
# 处理policy字段
|
117
117
|
if policy is None:
|
118
118
|
policy = {}
|
@@ -136,6 +136,17 @@ class Job(Generic[T]):
|
|
136
136
|
t= [ i.split('=') for i in re.split(r'\s+',debug) if i.find('=')>0]
|
137
137
|
for i in t:
|
138
138
|
debugargs[i[0]]=i[1]
|
139
|
+
context=[
|
140
|
+
function,
|
141
|
+
f"model/@sdk/{str(int(time.time() * random.random()))}",
|
142
|
+
]
|
143
|
+
if rid is not None and rid != "":
|
144
|
+
context.append(rid)
|
145
|
+
|
146
|
+
PARENT_JOB_ID =kwargs.get("PARENT_JOB_ID",None)
|
147
|
+
if PARENT_JOB_ID is not None:
|
148
|
+
context.append(f"job/parent/{PARENT_JOB_ID}")
|
149
|
+
|
139
150
|
variables = {
|
140
151
|
"input": {
|
141
152
|
"args": {
|
@@ -144,18 +155,14 @@ class Job(Generic[T]):
|
|
144
155
|
"_ModelArgs": config["args"],
|
145
156
|
"implement":implement
|
146
157
|
},
|
147
|
-
"context":
|
148
|
-
function,
|
149
|
-
rid,
|
150
|
-
f"model/@sdk/{str(int(time.time() * random.random()))}",
|
151
|
-
],
|
158
|
+
"context": context,
|
152
159
|
"policy": policy,
|
153
160
|
"debug":debugargs
|
154
161
|
}
|
155
162
|
}
|
156
163
|
return variables
|
157
164
|
@staticmethod
|
158
|
-
def create(revisionHash, job, config, name=None, rid=
|
165
|
+
def create(revisionHash, job, config, name=None, rid=None, policy=None, **kwargs):
|
159
166
|
"""
|
160
167
|
创建一个运行任务
|
161
168
|
|
@@ -169,7 +176,7 @@ class Job(Generic[T]):
|
|
169
176
|
|
170
177
|
>>> runner = Runner.runRevision(revision,job,config,'')
|
171
178
|
"""
|
172
|
-
variables=Job.__createJobVariables(job, config, revisionHash, rid, policy)
|
179
|
+
variables=Job.__createJobVariables(job, config, revisionHash, rid=rid, policy=policy, **kwargs)
|
173
180
|
r = graphql_request(Job.__createJobQuery, variables)
|
174
181
|
if "errors" in r:
|
175
182
|
raise Exception(r["errors"])
|
@@ -229,8 +236,9 @@ class Job(Generic[T]):
|
|
229
236
|
"""
|
230
237
|
连接接收器和发送器
|
231
238
|
"""
|
232
|
-
|
233
|
-
|
239
|
+
resultType = getResultClass(self.context[0])
|
240
|
+
|
241
|
+
self._result = self._resultView(resultType)
|
234
242
|
|
235
243
|
@property
|
236
244
|
def result(self)->T:
|
@@ -241,17 +249,17 @@ class Job(Generic[T]):
|
|
241
249
|
self.__connect()
|
242
250
|
return self._result
|
243
251
|
|
244
|
-
|
245
|
-
|
252
|
+
|
253
|
+
|
254
|
+
def _resultView(self, resultType=None):
|
246
255
|
"""
|
247
256
|
获取当前运行实例的输出
|
248
257
|
"""
|
249
258
|
receiver = self.read()
|
250
259
|
sender = self.write()
|
251
|
-
if
|
252
|
-
|
253
|
-
|
254
|
-
return viewType(receiver, sender)
|
260
|
+
if resultType is None:
|
261
|
+
resultType = getResultClass(self.context[0])
|
262
|
+
return resultType(receiver, sender)
|
255
263
|
|
256
264
|
|
257
265
|
|
cloudpss/job/jobReceiver.py
CHANGED
@@ -21,7 +21,7 @@ class JobReceiver(object):
|
|
21
21
|
return message
|
22
22
|
raise StopIteration()
|
23
23
|
|
24
|
-
def
|
24
|
+
def result(self, resultType):
|
25
25
|
"""
|
26
26
|
获取指定类型的视图数据
|
27
27
|
|
@@ -31,7 +31,7 @@ class JobReceiver(object):
|
|
31
31
|
|
32
32
|
>>> view= receiver.view(EMTView)
|
33
33
|
"""
|
34
|
-
return
|
34
|
+
return resultType(self)
|
35
35
|
|
36
36
|
@property
|
37
37
|
@deprecated(version='3.0', reason="该方法将在 5.0 版本移除")
|
@@ -1,13 +1,13 @@
|
|
1
|
-
from .
|
1
|
+
from .IESResult import IESResult
|
2
2
|
import re
|
3
3
|
import copy
|
4
|
-
class
|
4
|
+
class IESLabTypicalDayResult(IESResult):
|
5
5
|
|
6
6
|
def __init__(self, *args, **kwargs):
|
7
7
|
"""
|
8
8
|
初始化
|
9
9
|
"""
|
10
|
-
|
10
|
+
IESResult.__init__(self, *args, **kwargs)
|
11
11
|
self.__plotIndex = 0
|
12
12
|
self.__typicalIndex = 0
|
13
13
|
self.__type_list =['电负荷', '热负荷','冷负荷','总辐射','散射辐射', '直射辐射', '天顶角', '环境温度', '土壤温度', '10m风速', '50m风速', '建筑物高度风速', '风机高度风速']
|
@@ -0,0 +1,39 @@
|
|
1
|
+
from .IESResult import IESResult
|
2
|
+
from .result import Result
|
3
|
+
from .EMTResult import EMTResult
|
4
|
+
from .PowerFlowResult import PowerFlowResult
|
5
|
+
from .IESLabSimulationResult import IESLabSimulationResult
|
6
|
+
from .IESLabTypicalDayResult import IESLabTypicalDayResult
|
7
|
+
from ..messageStreamReceiver import MessageStreamReceiver
|
8
|
+
from ..messageStreamSender import MessageStreamSender
|
9
|
+
__all__ = [
|
10
|
+
'Result','EMTResult','PowerFlowResult','IESLabSimulationResult','IESResult','IESLabTypicalDayResult','MessageStreamReceiver','MessageStreamSender'
|
11
|
+
]
|
12
|
+
|
13
|
+
RESULT = {
|
14
|
+
'function/CloudPSS/emtp': EMTResult,
|
15
|
+
'function/CloudPSS/emtps': EMTResult,
|
16
|
+
'function/CloudPSS/sfemt': EMTResult,
|
17
|
+
'function/CloudPSS/power-flow': PowerFlowResult,
|
18
|
+
'function/CloudPSS/ies-simulation': IESResult,
|
19
|
+
'function/CloudPSS/ies-optimization': IESResult,
|
20
|
+
'function/ies/ies-optimization': IESResult,
|
21
|
+
'function/CloudPSS/three-phase-powerFlow': PowerFlowResult,
|
22
|
+
'function/ies/ies-simulation': IESLabSimulationResult,
|
23
|
+
'function/ies/ies-gmm':IESLabTypicalDayResult,
|
24
|
+
'function/CloudPSS/ieslab-simulation': IESLabSimulationResult,
|
25
|
+
'function/CloudPSS/ieslab-gmm':IESLabTypicalDayResult,
|
26
|
+
'function/CloudPSS/ieslab-optimization': IESResult,
|
27
|
+
}
|
28
|
+
|
29
|
+
|
30
|
+
def getResultClass(rid: str) -> Result:
|
31
|
+
"""
|
32
|
+
获取仿真结果视图
|
33
|
+
|
34
|
+
:param rid: 仿真任务的 rid
|
35
|
+
:param db: 仿真任务的数据库
|
36
|
+
|
37
|
+
:return: 仿真结果视图
|
38
|
+
"""
|
39
|
+
return RESULT.get(rid, Result)
|