cloudpss 4.5.13__py3-none-any.whl → 4.5.15__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 -1
- cloudpss/ieslab/DataManageModel.py +2 -1
- cloudpss/ieslab/IESLabOpt.py +235 -234
- cloudpss/job/job.py +16 -13
- cloudpss/job/messageStreamReceiver.py +53 -18
- cloudpss/job/messageStreamSender.py +6 -6
- cloudpss/job/result/EMTResult.py +13 -2
- cloudpss/job/result/IESLabTypicalDayResult.py +101 -18
- cloudpss/job/result/result.py +0 -1
- cloudpss/model/implements/diagram.py +3 -1
- cloudpss/model/model.py +8 -7
- cloudpss/model/revision.py +4 -4
- cloudpss/runner/IESLabTypicalDayResult.py +2 -1
- cloudpss/runner/result.py +0 -1
- cloudpss/runner/runner.py +15 -2
- cloudpss/utils/graphqlUtil.py +2 -2
- cloudpss/utils/httprequests.py +3 -2
- cloudpss/version.py +1 -1
- {cloudpss-4.5.13.dist-info → cloudpss-4.5.15.dist-info}/METADATA +1 -1
- {cloudpss-4.5.13.dist-info → cloudpss-4.5.15.dist-info}/RECORD +22 -22
- {cloudpss-4.5.13.dist-info → cloudpss-4.5.15.dist-info}/WHEEL +0 -0
- {cloudpss-4.5.13.dist-info → cloudpss-4.5.15.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,9 @@
|
|
1
|
+
import datetime
|
1
2
|
import logging
|
2
3
|
import sys
|
4
|
+
|
5
|
+
from cloudpss.job.TemplateManager import TemplateManager
|
6
|
+
|
3
7
|
from .jobReceiver import JobReceiver
|
4
8
|
import os
|
5
9
|
from urllib.parse import urlparse
|
@@ -7,7 +11,6 @@ import websocket
|
|
7
11
|
import pytz
|
8
12
|
import threading
|
9
13
|
import time
|
10
|
-
|
11
14
|
utc_tz = pytz.timezone("UTC")
|
12
15
|
|
13
16
|
from ..utils.IO import IO
|
@@ -18,15 +21,31 @@ class Message(object):
|
|
18
21
|
self.id = id
|
19
22
|
self.token = token
|
20
23
|
|
21
|
-
|
24
|
+
|
25
|
+
|
22
26
|
class MessageStreamReceiver(JobReceiver):
|
23
|
-
def __init__(self,
|
27
|
+
def __init__(self, output,**kwargs):
|
24
28
|
super().__init__()
|
25
|
-
self.
|
26
|
-
self.
|
27
|
-
self.origin = os.environ.get("CLOUDPSS_API_URL", "https://cloudpss.net/")
|
29
|
+
self.id = output
|
30
|
+
self.origin = kwargs.get("baseUrl",os.environ.get("CLOUDPSS_API_URL", "https://cloudpss.net/"))
|
28
31
|
self.__hasOpen = False
|
29
|
-
|
32
|
+
self.templates=TemplateManager()
|
33
|
+
self.timeOffset=0
|
34
|
+
self.lastMessageTime=0
|
35
|
+
|
36
|
+
|
37
|
+
def updateTime(self,timestamp):
|
38
|
+
self.lastMessageTime = timestamp
|
39
|
+
|
40
|
+
## 判断是否到达当前时间点的数据或者消息流结束
|
41
|
+
def isEnd(self,current_time=None):
|
42
|
+
|
43
|
+
if self.status == 1:
|
44
|
+
return True
|
45
|
+
logging.debug('lastMessageTime',self.lastMessageTime)
|
46
|
+
current_time = current_time if current_time is not None else time.time()
|
47
|
+
return (self.lastMessageTime/1000)>=current_time-self.timeOffset
|
48
|
+
|
30
49
|
def __path(self, from_=None):
|
31
50
|
if self.id is None:
|
32
51
|
raise Exception("id is None")
|
@@ -39,22 +58,34 @@ class MessageStreamReceiver(JobReceiver):
|
|
39
58
|
|
40
59
|
###下面是兼容Receiver部分功能实现
|
41
60
|
def __on_message_legacy(self, *args, **kwargs):
|
42
|
-
|
43
61
|
if type(args[0]) != websocket.WebSocketApp:
|
44
62
|
message = args[0]
|
45
63
|
else:
|
46
64
|
message = args[1]
|
47
65
|
return self.__on_message(message)
|
48
|
-
|
49
66
|
def __on_message(self, message):
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
67
|
+
try:
|
68
|
+
data = IO.deserialize(message, "ubjson")
|
69
|
+
self.updateTime(data["timestamp"])
|
70
|
+
self.ws.url = self.__path(data["id"])
|
71
|
+
msg = IO.deserialize(data["data"], "ubjson")
|
72
|
+
if type(msg) is list:
|
73
|
+
if len(msg) == 3:
|
74
|
+
pass
|
75
|
+
|
76
|
+
templateMessage = self.templates.invoke(msg)
|
77
|
+
for m in templateMessage:
|
78
|
+
self.messages.append(m)
|
79
|
+
return
|
80
|
+
else:
|
81
|
+
self.templates.create(msg)
|
82
|
+
return
|
83
|
+
|
84
|
+
self.messages.append(msg)
|
85
|
+
return msg
|
86
|
+
except Exception as e:
|
87
|
+
self.ws.close()
|
88
|
+
return None
|
58
89
|
|
59
90
|
|
60
91
|
def __on_error(self, *args, **kwargs):
|
@@ -101,6 +132,10 @@ class MessageStreamReceiver(JobReceiver):
|
|
101
132
|
|
102
133
|
def __on_open(self,ws, *args, **kwargs):
|
103
134
|
self.ws = ws
|
135
|
+
gmt_format = '%a, %d %b %Y %H:%M:%S GMT'
|
136
|
+
serverTime = datetime.datetime.strptime(ws.sock.headers['date'],gmt_format)
|
137
|
+
self.timeOffset = time.time()+time.timezone-serverTime.timestamp()
|
138
|
+
|
104
139
|
logging.debug(f"MessageStreamReceiver on_open")
|
105
140
|
self._status = 0
|
106
141
|
self.__hasOpen = True
|
@@ -128,7 +163,7 @@ class MessageStreamReceiver(JobReceiver):
|
|
128
163
|
|
129
164
|
|
130
165
|
def connect(self):
|
131
|
-
self._status =
|
166
|
+
self._status = 0
|
132
167
|
path = self.__path()
|
133
168
|
logging.info(f"receive data from websocket: {path}")
|
134
169
|
self.ws = websocket.WebSocketApp(
|
@@ -12,10 +12,10 @@ import logging
|
|
12
12
|
|
13
13
|
|
14
14
|
class MessageStreamSender:
|
15
|
-
def __init__(self,
|
15
|
+
def __init__(self, input,**kwargs):
|
16
16
|
super().__init__()
|
17
|
-
self.
|
18
|
-
self.origin = os.environ.get("CLOUDPSS_API_URL", "https://cloudpss.net/")
|
17
|
+
self.input = input
|
18
|
+
self.origin = kwargs.get("baseUrl",os.environ.get("CLOUDPSS_API_URL", "https://cloudpss.net/"))
|
19
19
|
self.__hasOpen = False
|
20
20
|
|
21
21
|
def __on_message(self, ws, message):
|
@@ -60,14 +60,14 @@ class MessageStreamSender:
|
|
60
60
|
同步方法连接ws
|
61
61
|
"""
|
62
62
|
self._status = 0
|
63
|
-
if self.
|
63
|
+
if self.input is None:
|
64
64
|
raise Exception("id is None")
|
65
|
-
if self.
|
65
|
+
if self.input == "00000000-0000-0000-0000-000000000000":
|
66
66
|
return
|
67
67
|
u = list(urlparse(self.origin))
|
68
68
|
head = "wss" if u[0] == "https" else "ws"
|
69
69
|
|
70
|
-
path = head + "://" + str(u[1]) + "/api/streams/token/" + self.
|
70
|
+
path = head + "://" + str(u[1]) + "/api/streams/token/" + self.input
|
71
71
|
logging.debug(f"MessageStreamSender data from websocket: {path}")
|
72
72
|
|
73
73
|
self.ws = websocket.WebSocketApp(
|
cloudpss/job/result/EMTResult.py
CHANGED
@@ -38,6 +38,11 @@ class EMTResult(Result):
|
|
38
38
|
该类只提供 EMT 仿真使用
|
39
39
|
|
40
40
|
"""
|
41
|
+
|
42
|
+
def __init__(self, receiver, sender = None):
|
43
|
+
super().__init__(receiver, sender)
|
44
|
+
self.virtualInput=VirtualInput()
|
45
|
+
|
41
46
|
__messageIndex = 0
|
42
47
|
def getPlots(self):
|
43
48
|
'''
|
@@ -140,15 +145,21 @@ class EMTResult(Result):
|
|
140
145
|
else:
|
141
146
|
raise Exception('transmitter is None')
|
142
147
|
|
143
|
-
def send(self,message):
|
148
|
+
def send(self,message=None):
|
144
149
|
"""
|
145
150
|
发送消息
|
146
151
|
"""
|
147
152
|
if self._sender is not None:
|
148
|
-
val =
|
153
|
+
val ={
|
154
|
+
"type": 'virtual_input',
|
155
|
+
"data": message,
|
156
|
+
}
|
149
157
|
if type(message) is VirtualInput:
|
150
158
|
val = message.toJson()
|
151
159
|
|
160
|
+
if message is None:
|
161
|
+
val = self.virtualInput.toJson()
|
162
|
+
|
152
163
|
self._sender.write(val)
|
153
164
|
else:
|
154
165
|
raise Exception('transmitter is None')
|
@@ -1,6 +1,44 @@
|
|
1
1
|
from .IESResult import IESResult
|
2
2
|
import re
|
3
3
|
import copy
|
4
|
+
from cloudpss.job.messageStreamReceiver import MessageStreamReceiver, Message
|
5
|
+
import asyncio
|
6
|
+
from concurrent.futures import ThreadPoolExecutor
|
7
|
+
import threading
|
8
|
+
import time
|
9
|
+
from queue import Queue
|
10
|
+
|
11
|
+
class IESLabTypicalDaySubMessageResult():
|
12
|
+
def __init__(self, output) -> None:
|
13
|
+
self.receiver = MessageStreamReceiver(output)
|
14
|
+
# self.result={}
|
15
|
+
|
16
|
+
def connect(self):
|
17
|
+
self.receiver.connect()
|
18
|
+
|
19
|
+
def status(self):
|
20
|
+
return self.receiver.status()
|
21
|
+
|
22
|
+
def wait(self,timeout=10,current_time=None):
|
23
|
+
start = time.time()
|
24
|
+
while True:
|
25
|
+
time.sleep(0.1)
|
26
|
+
if self.receiver.isEnd(current_time):
|
27
|
+
break
|
28
|
+
if time.time()-start>timeout:
|
29
|
+
break
|
30
|
+
# raise Exception("获取数据超时")
|
31
|
+
|
32
|
+
def getMessages(self,timeout=10,current_time=None):
|
33
|
+
result={}
|
34
|
+
self.wait(timeout,current_time)
|
35
|
+
|
36
|
+
for val in self.receiver:
|
37
|
+
if val.get('type',None) !='plot':
|
38
|
+
continue
|
39
|
+
result[val['key']] = val['data']
|
40
|
+
return result
|
41
|
+
|
4
42
|
class IESLabTypicalDayResult(IESResult):
|
5
43
|
|
6
44
|
def __init__(self, *args, **kwargs):
|
@@ -12,27 +50,36 @@ class IESLabTypicalDayResult(IESResult):
|
|
12
50
|
self.__typicalIndex = 0
|
13
51
|
self.__type_list =['总辐射','散射辐射', '直射辐射','天顶角', '环境温度', '湿球温度','土壤温度', '10m风速', '50m风速','电负荷', '热负荷','冷负荷','氢负荷']
|
14
52
|
self.__map_load = { 'maxElectricalLoad':'电负荷', 'maxHeatLoad':'热负荷','maxCoolLoad':'冷负荷','maxHydrogenLoad':'氢负荷' }
|
53
|
+
self.token = ''
|
15
54
|
|
16
55
|
self.result = {'TypicalMonth': [{'月份': int,'持续天数': [],**{key: [] for key in self.__type_list}} for i in range(12)],'TypicalDay': []}
|
56
|
+
self.messagemap={}
|
57
|
+
|
17
58
|
def __readPlotResult(self):
|
59
|
+
|
18
60
|
length = self.getMessageLength()
|
61
|
+
|
62
|
+
print(length)
|
19
63
|
if (length > self.__plotIndex):
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
64
|
+
|
65
|
+
|
66
|
+
# stream_id = "fce32578-75c2-4aca-8323-1ce60941e57b"
|
67
|
+
|
68
|
+
# if val['type'] == 'plot':# 每个月各类型数据的各个典型日的数据,由于部分月份可能没有电冷热负荷,某月的某个典型日可能缺少冷热负荷
|
69
|
+
# key_re = re.split('-month',val['key'])#格式为:散射辐射-month1,re后分别为类型和月份
|
70
|
+
# typical_month_m = self.result['TypicalMonth'][int(key_re[1])-1]
|
71
|
+
# typical_month_m['月份'] = int(key_re[1])
|
72
|
+
# val_data_traces = val['data']['traces']
|
73
|
+
# #val['data']['traces'][i]['name']格式为:典型日1-共31天,re正则后[0]为典型日顺序,[1]为持续天数
|
74
|
+
# typicalNum = int(re.findall('\d+',val_data_traces[-1]['name'])[0])
|
75
|
+
# for i in range(typicalNum):#取该类型的最后一个典型日顺序,当该类型缺少后排典型日时,小于实际典型日数量
|
76
|
+
# typical_month_m[key_re[0]].append([])
|
77
|
+
# if key_re[0] == '环境温度':#各类版本气象数据均有环境温度数据,其典型日数量为实际数量
|
78
|
+
# typical_month_m['持续天数'].append(int(re.findall('\d+',val_data_traces[i]['name'])[1]))
|
79
|
+
# # 当前排典型日缺少数据时,该类型数据为空list[];当后排典型日缺少数据时,该类型数据为空
|
80
|
+
# for i in range(len(val_data_traces)):
|
81
|
+
# typical_month_m[key_re[0]][int(re.findall('\d+',val_data_traces[i]['name'])[0])-1] = copy.deepcopy(val_data_traces[i]['y'])
|
82
|
+
|
36
83
|
self.__plotIndex = length
|
37
84
|
# update TypicalDay based on TypicalMonth
|
38
85
|
for m in range(12):
|
@@ -54,6 +101,36 @@ class IESLabTypicalDayResult(IESResult):
|
|
54
101
|
if typical_month_m[type_i] and i < len(typical_month_m[type_i]):
|
55
102
|
typical_day_index['data'][type_i] = typical_month_m[type_i][i]
|
56
103
|
self.__typicalIndex += 1
|
104
|
+
def __init_message_map(self):
|
105
|
+
|
106
|
+
message = self.getMessagesByKey("message_map")
|
107
|
+
if message is None or len(message) == 0:
|
108
|
+
return
|
109
|
+
|
110
|
+
self.messagemap = {}
|
111
|
+
for m in message:
|
112
|
+
dataMap = m['data']['map']
|
113
|
+
for item in dataMap:
|
114
|
+
messages = item['messages']
|
115
|
+
for val in messages:
|
116
|
+
self.messagemap[val] = item['id']
|
117
|
+
|
118
|
+
def __init_result(self):
|
119
|
+
self.__init_message_map()
|
120
|
+
# print(self.messagemap)
|
121
|
+
current_time = time.time()
|
122
|
+
|
123
|
+
for key,val in self.messagemap.items():
|
124
|
+
|
125
|
+
sub=IESLabTypicalDaySubMessageResult(val)
|
126
|
+
sub.connect()
|
127
|
+
message = sub.getMessages(current_time=current_time,timeout=10)
|
128
|
+
print("key",key,'message', message)
|
129
|
+
|
130
|
+
|
131
|
+
pass
|
132
|
+
|
133
|
+
|
57
134
|
def GetTypical(self):
|
58
135
|
'''
|
59
136
|
获取所有的 GetTypical 典型日数据
|
@@ -61,7 +138,7 @@ class IESLabTypicalDayResult(IESResult):
|
|
61
138
|
>>> result.GetTypical()
|
62
139
|
{...}
|
63
140
|
'''
|
64
|
-
self.
|
141
|
+
self.__init_result()
|
65
142
|
return self.result['TypicalDay']
|
66
143
|
def GetTypicalDayNum(self):
|
67
144
|
'''
|
@@ -131,4 +208,10 @@ class IESLabTypicalDayResult(IESResult):
|
|
131
208
|
:return: list<list>类型,代表以1h为时间间隔的该参数的典型日内时序曲线
|
132
209
|
'''
|
133
210
|
self.__readPlotResult()
|
134
|
-
return self.result['TypicalMonth'][monthID-1].get(dataType,'没有该类型数据')
|
211
|
+
return self.result['TypicalMonth'][monthID-1].get(dataType,'没有该类型数据')
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
217
|
+
|
cloudpss/job/result/result.py
CHANGED
@@ -126,8 +126,10 @@ class DiagramImplement(object):
|
|
126
126
|
component = self.cells.get(key)
|
127
127
|
if not component:
|
128
128
|
return False
|
129
|
-
position = component.position.copy()
|
130
129
|
del self.cells[key]
|
130
|
+
position=getattr(component, "position", None)
|
131
|
+
if position is None:
|
132
|
+
return True
|
131
133
|
for edge in self.cells.values():
|
132
134
|
if edge.shape == "diagram-edge":
|
133
135
|
if edge.source.get("cell") == key:
|
cloudpss/model/model.py
CHANGED
@@ -298,7 +298,7 @@ class Model(object):
|
|
298
298
|
return config
|
299
299
|
|
300
300
|
@staticmethod
|
301
|
-
def fetchMany(name=None, cursor=[], pageSize=10,owner=None):
|
301
|
+
def fetchMany(name=None, cursor=[], pageSize=10,owner=None,**kwargs):
|
302
302
|
"""
|
303
303
|
获取用户可以运行的项目列表
|
304
304
|
|
@@ -332,13 +332,13 @@ class Model(object):
|
|
332
332
|
if name is not None:
|
333
333
|
variables["_search"] = name
|
334
334
|
|
335
|
-
data = graphql_request(Model.__models_query, {"input": variables})
|
335
|
+
data = graphql_request(Model.__models_query, {"input": variables},**kwargs)
|
336
336
|
if "errors" in data:
|
337
337
|
raise Exception(data["errors"][0]["message"])
|
338
338
|
return data["data"]["models"]['items']
|
339
339
|
|
340
340
|
@staticmethod
|
341
|
-
def fetch(rid):
|
341
|
+
def fetch(rid,**kwargs):
|
342
342
|
"""
|
343
343
|
获取项目
|
344
344
|
|
@@ -349,7 +349,7 @@ class Model(object):
|
|
349
349
|
>>> model=Model.fetch('model/Demo/test')
|
350
350
|
|
351
351
|
"""
|
352
|
-
data = graphql_request(Model.__model_query, {"rid": rid})
|
352
|
+
data = graphql_request(Model.__model_query, {"rid": rid},**kwargs)
|
353
353
|
if "errors" in data:
|
354
354
|
raise Exception(data["errors"][0]["message"])
|
355
355
|
return Model(data["data"]["model"])
|
@@ -464,7 +464,7 @@ class Model(object):
|
|
464
464
|
|
465
465
|
|
466
466
|
@staticmethod
|
467
|
-
def create(model):
|
467
|
+
def create(model,**kwargs):
|
468
468
|
"""
|
469
469
|
新建项目
|
470
470
|
|
@@ -506,12 +506,13 @@ class Model(object):
|
|
506
506
|
},
|
507
507
|
}
|
508
508
|
},
|
509
|
+
**kwargs
|
509
510
|
)
|
510
511
|
|
511
512
|
|
512
513
|
|
513
514
|
@staticmethod
|
514
|
-
def update(model):
|
515
|
+
def update(model,**kwargs):
|
515
516
|
"""
|
516
517
|
更新项目
|
517
518
|
|
@@ -555,7 +556,7 @@ class Model(object):
|
|
555
556
|
'tags': tags,
|
556
557
|
"permissions": permissions,
|
557
558
|
}
|
558
|
-
})
|
559
|
+
},**kwargs)
|
559
560
|
if "errors" in r:
|
560
561
|
raise Exception(r["errors"][0]["message"])
|
561
562
|
return r
|
cloudpss/model/revision.py
CHANGED
@@ -75,7 +75,8 @@ class ModelRevision(object):
|
|
75
75
|
|
76
76
|
>>> revision.run(revision,job,config,'')
|
77
77
|
"""
|
78
|
-
|
78
|
+
|
79
|
+
revision= ModelRevision.create(self,**kwargs)
|
79
80
|
if stop_on_entry is not None:
|
80
81
|
job['args']['stop_on_entry'] = stop_on_entry
|
81
82
|
return Job.create(
|
@@ -84,7 +85,7 @@ class ModelRevision(object):
|
|
84
85
|
|
85
86
|
|
86
87
|
@staticmethod
|
87
|
-
def create(revision, parentHash=None):
|
88
|
+
def create(revision, parentHash=None, **kwargs):
|
88
89
|
"""
|
89
90
|
创建一个新版本
|
90
91
|
|
@@ -95,12 +96,11 @@ class ModelRevision(object):
|
|
95
96
|
>>> ModelRevision.create(model.revision)
|
96
97
|
{hash:'4043acbddb9ce0c6174be65573c0380415bc48186c74a459f88865313743230c'}
|
97
98
|
"""
|
98
|
-
|
99
99
|
r = revision.toJSON()
|
100
100
|
if 'hash' in r:
|
101
101
|
del r['hash']
|
102
102
|
variables = {'a': {**r, 'parent': parentHash}}
|
103
|
-
r = graphql_request(ModelRevision.__createModelRevisionQuery, variables)
|
103
|
+
r = graphql_request(ModelRevision.__createModelRevisionQuery, variables,**kwargs)
|
104
104
|
if 'errors' in r:
|
105
105
|
raise Exception(r['errors'])
|
106
106
|
|
cloudpss/runner/result.py
CHANGED
cloudpss/runner/runner.py
CHANGED
@@ -12,10 +12,12 @@ from .MessageStreamReceiver import MessageStreamReceiver
|
|
12
12
|
from .result import IESLabSimulationResult, PowerFlowResult, EMTResult, Result, IESResult
|
13
13
|
from .IESLabPlanResult import IESLabPlanResult, IESLabOptResult
|
14
14
|
from .IESLabEvaluationResult import IESLabEvaluationResult, IESLabPlanEvaluationResult, IESLabOptEvaluationResult
|
15
|
-
from .IESLabTypicalDayResult import IESLabTypicalDayResult
|
15
|
+
# from .IESLabTypicalDayResult import IESLabTypicalDayResult
|
16
|
+
from ..job.result.IESLabTypicalDayResult import IESLabTypicalDayResult
|
16
17
|
from .storage import Storage
|
17
18
|
from ..utils import request
|
18
19
|
from typing import TypeVar, Generic
|
20
|
+
from .DSLabResult import DSLabResult
|
19
21
|
import re
|
20
22
|
|
21
23
|
RECEIVER = {
|
@@ -35,7 +37,9 @@ IES_LAB_OPT_RESULT = {
|
|
35
37
|
'function/ieslab/evaluation': IESLabOptEvaluationResult,
|
36
38
|
}
|
37
39
|
|
38
|
-
|
40
|
+
DS_LAB_RESULT = {
|
41
|
+
'function/ieslab/evaluation': DSLabResult
|
42
|
+
}
|
39
43
|
|
40
44
|
RESULT_DB = {
|
41
45
|
'function/CloudPSS/emtp': EMTResult,
|
@@ -256,6 +260,15 @@ class HttpRunner(Runner[T]):
|
|
256
260
|
return False
|
257
261
|
return self.result.status() # type: ignore
|
258
262
|
|
263
|
+
class DSLabRunner(Runner[T]):
|
264
|
+
def __init__(self, job, simulationId, **kwargs):
|
265
|
+
self.simulationId = simulationId
|
266
|
+
self.job = job
|
267
|
+
result = DS_LAB_RESULT.get(job.get('rid', ''), DSLabResult)
|
268
|
+
self.result: T = result(self.simulationId, **kwargs)
|
269
|
+
|
270
|
+
def status(self):
|
271
|
+
return self.result.status()
|
259
272
|
|
260
273
|
class HttpOPTRunner(Runner[T]):
|
261
274
|
|
cloudpss/utils/graphqlUtil.py
CHANGED
@@ -3,9 +3,9 @@ import json
|
|
3
3
|
from cloudpss.utils import request
|
4
4
|
|
5
5
|
|
6
|
-
def graphql_request(query, variables=None,
|
6
|
+
def graphql_request(query, variables=None, baseUrl=None,token=None,**kwargs):
|
7
7
|
payload = {'query': query, 'variables': variables}
|
8
8
|
|
9
|
-
r = request('POST', 'graphql', data=json.dumps(payload), **kwargs)
|
9
|
+
r = request('POST', 'graphql', data=json.dumps(payload),baseUrl=baseUrl,token=token, **kwargs)
|
10
10
|
|
11
11
|
return json.loads(r.text)
|
cloudpss/utils/httprequests.py
CHANGED
@@ -12,7 +12,8 @@ def request(method, uri, baseUrl=None, params={}, token=None, **kwargs):
|
|
12
12
|
if baseUrl == None:
|
13
13
|
baseUrl = os.environ.get('CLOUDPSS_API_URL', 'https://cloudpss.net/')
|
14
14
|
url = requests.compat.urljoin(baseUrl,uri)
|
15
|
-
token
|
15
|
+
if token is None:
|
16
|
+
token = os.environ.get('CLOUDPSS_TOKEN', None)
|
16
17
|
|
17
18
|
if token:
|
18
19
|
headers = {
|
@@ -29,7 +30,7 @@ def request(method, uri, baseUrl=None, params={}, token=None, **kwargs):
|
|
29
30
|
del kwargs['xToken']
|
30
31
|
|
31
32
|
r = requests.request(method, url, params=params, headers=headers, **kwargs)
|
32
|
-
|
33
|
+
|
33
34
|
if (uri.startswith('graphql')):
|
34
35
|
if 'X-Cloudpss-Version' not in r.headers:
|
35
36
|
raise Exception(
|
cloudpss/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '4.5.
|
1
|
+
__version__ = '4.5.15'
|
@@ -1,6 +1,6 @@
|
|
1
|
-
cloudpss/__init__.py,sha256=
|
1
|
+
cloudpss/__init__.py,sha256=xnA-UjehYOzH6KV7vOXHwdbGEiw6g_OPKzrbZA9Fuc8,858
|
2
2
|
cloudpss/verify.py,sha256=KF4Gd59DGvCyIEkRD7rNnekWw22XxJpi3DW6keb6j4c,1498
|
3
|
-
cloudpss/version.py,sha256=
|
3
|
+
cloudpss/version.py,sha256=tSsepOcbNt8DX4JgJ-Dlwbcts2PAeUK69aReQTlWCkM,23
|
4
4
|
cloudpss/asyncio/__init__.py,sha256=CJGopQl_vz3z3fJsK7NjMX5uzkzfrJrbqKVhyYqlYWc,198
|
5
5
|
cloudpss/asyncio/job/__init__.py,sha256=3UIFZYjJTzuckM61o8kim1c3PWt2SSHTL72jrGu5IzI,51
|
6
6
|
cloudpss/asyncio/job/job.py,sha256=Bn2BEERw1J8YarFauTzVrGJK7nmaoMsdlrFUqiHRth4,3897
|
@@ -24,9 +24,9 @@ cloudpss/function/__init__.py,sha256=TNzChB-gQF6oB62F423evpUlgcp6s03D4pKKs89Lz4Q
|
|
24
24
|
cloudpss/function/function.py,sha256=llomkfnTmKMiFJYJ2mKnmAEoIjTNVCnjCUUyiJMOV1s,29
|
25
25
|
cloudpss/function/functionExecution.py,sha256=YM2hS0Ao3jhMJodqFfxk0JAK7ZR00MPh-U2foBWshT0,16897
|
26
26
|
cloudpss/function/job.py,sha256=LdzaTyjvBcMZIyLstSZnt79d2eREljx2HnNoilDp03A,13162
|
27
|
-
cloudpss/ieslab/DataManageModel.py,sha256=
|
27
|
+
cloudpss/ieslab/DataManageModel.py,sha256=k0ZLToBuIKl2Kj8LDvMUUaGc3wLE1CgZ8BmRKNDm7tk,26024
|
28
28
|
cloudpss/ieslab/EvaluationModel.py,sha256=hGZmuaB8lL9LVti_TCG-qCfK_bA-HJgdxYt7oMmVrXY,9399
|
29
|
-
cloudpss/ieslab/IESLabOpt.py,sha256=
|
29
|
+
cloudpss/ieslab/IESLabOpt.py,sha256=D2iDbi80ohvU7wKelb-Uk6FP_S0rbZyHfWwlBbQYYPc,9379
|
30
30
|
cloudpss/ieslab/IESLabPlan.py,sha256=rEf1W2pT_J3C8-TFFHVm8Llli9ySSXbBeRpd6Yz9Glk,8345
|
31
31
|
cloudpss/ieslab/IESLabSimulation.py,sha256=-EJFkhklN9ao-nbfk7Lz6JCHboFCSDcn5R2jr3_Z7_A,4046
|
32
32
|
cloudpss/ieslab/PlanModel.py,sha256=fLWzVnRiyYRHchG2xsfUH-oCUmnF1uwbDuWNC750dWw,12612
|
@@ -34,47 +34,47 @@ cloudpss/ieslab/__init__.py,sha256=gr1rXYw9vIAGOe60eg7LyMHP7QDXvNf4dJ5GTR_kj1Y,2
|
|
34
34
|
cloudpss/job/TemplateCompiler.py,sha256=MuJDTQ54wRo5bGSvBJBJjXJ7u463dwpRkaLwIwm_hLE,9936
|
35
35
|
cloudpss/job/TemplateManager.py,sha256=uOvctmE3P17aGWt_26d940FbRUSEs6iovFBb8T5xjd4,1115
|
36
36
|
cloudpss/job/__init__.py,sha256=3UIFZYjJTzuckM61o8kim1c3PWt2SSHTL72jrGu5IzI,51
|
37
|
-
cloudpss/job/job.py,sha256=
|
37
|
+
cloudpss/job/job.py,sha256=vLJ7mIbrVfTWgQsUlk5bjM995wzu1q_Mee2AoW_MViM,8467
|
38
38
|
cloudpss/job/jobReceiver.py,sha256=PNYxcN33LiXZVyc4tzhPlpWxKnyWO_ElKjJ9wsxsroI,925
|
39
|
-
cloudpss/job/messageStreamReceiver.py,sha256=
|
40
|
-
cloudpss/job/messageStreamSender.py,sha256=
|
41
|
-
cloudpss/job/result/EMTResult.py,sha256=
|
39
|
+
cloudpss/job/messageStreamReceiver.py,sha256=Yjrg8_dIq4MoqbNoQHX8LbCe916od8C1NxHa0xpWJmg,5509
|
40
|
+
cloudpss/job/messageStreamSender.py,sha256=8I3h-y2zQQnI8zgS4NKVV2E9YmPPApX-kAzpauy0uOs,2396
|
41
|
+
cloudpss/job/result/EMTResult.py,sha256=T4LQdFMQoA1gtpw7twageYdTIf0Onb3O4tvTOMn-bkM,8334
|
42
42
|
cloudpss/job/result/IESLabSimulationResult.py,sha256=a47Ic1vvfHTK_vEokOZxJBnQReqYOWux_aePPic_Hrs,84
|
43
|
-
cloudpss/job/result/IESLabTypicalDayResult.py,sha256=
|
43
|
+
cloudpss/job/result/IESLabTypicalDayResult.py,sha256=tpWfN3G34l3qSXaTDDdPRSTXR4p7jY3AlP7o9e-A3VI,9554
|
44
44
|
cloudpss/job/result/IESResult.py,sha256=sLTdwZLE2HyZZNvJATgibsOPm3lqYquvLyOJjEgfog0,4027
|
45
45
|
cloudpss/job/result/PowerFlowResult.py,sha256=KoImlmsEEZyMriuoE_MSHBQu4k9MSDUuZ8E2SRLndWE,2097
|
46
46
|
cloudpss/job/result/__init__.py,sha256=dRWZNoX33cukgrNl6sMkQM3hdQrGHCpwIktoayrpP_4,1594
|
47
|
-
cloudpss/job/result/result.py,sha256=
|
47
|
+
cloudpss/job/result/result.py,sha256=UvtHWNPhVq1NsmuE4m-iy9BywacgLCYRfQMEBusFdpc,4290
|
48
48
|
cloudpss/model/__init__.py,sha256=SNq-bfwcQtDHtTNBYppfUEs8wkjfrQfGeywx7igmvOs,151
|
49
49
|
cloudpss/model/jobDefinitions.py,sha256=uuTwpqStlg3YDmfxbU2PVi_Tf18opa0kYLCMGaOP-qA,3749
|
50
|
-
cloudpss/model/model.py,sha256=
|
51
|
-
cloudpss/model/revision.py,sha256=
|
50
|
+
cloudpss/model/model.py,sha256=ee4CNtaLxXHD-T3jTGmqDpPC2nlCKs0wtuo_1FGvZSk,26866
|
51
|
+
cloudpss/model/revision.py,sha256=E3H-FOXsiwy1MDZC-Ky-QkzvOb5HApYSXP0llf8yJXQ,4038
|
52
52
|
cloudpss/model/topology.py,sha256=MJF3rQBLWus4RVO6L3Zwih7SWYjRWsLMcrcIBxCmIwM,2617
|
53
53
|
cloudpss/model/implements/__init__.py,sha256=88L_wF9SSzxsbtqwStWIPH4LxaKq7TVcssHQ62YBnls,67
|
54
54
|
cloudpss/model/implements/component.py,sha256=uNSpkZKChdXLiO40Ev4P3oQ1di2Hu4YjcBOb0I8Bf0c,734
|
55
|
-
cloudpss/model/implements/diagram.py,sha256
|
55
|
+
cloudpss/model/implements/diagram.py,sha256=-r9tTAIT_ET8ClPjcefAlBsMf2f1BytUi2F0L8pfdVc,6115
|
56
56
|
cloudpss/model/implements/implement.py,sha256=Uld96tjXVDbVUNV8xscyy_nZWLHr3iP2DqA6S3p-XJE,954
|
57
57
|
cloudpss/project/__init__.py,sha256=fpskY-cJGmMcTg1naVzNPtJaRG1xmSc2CFjDTin64Cw,51
|
58
58
|
cloudpss/project/project.py,sha256=uFhOnM8ngo1_ZYz2uArtORKZquYNdOIVLXU_q1MDFI4,17698
|
59
59
|
cloudpss/runner/DSLabResult.py,sha256=xJqKA3e1KSXQmLDe9_T6fG1exdE9j7EjfIfvBMmqiJ8,3422
|
60
60
|
cloudpss/runner/IESLabEvaluationResult.py,sha256=rsKbSJ9zsgyMYP-oIWsJlSXGxs7Y-44rj45Fn6NJXMA,5998
|
61
61
|
cloudpss/runner/IESLabPlanResult.py,sha256=pbUq2YCPBE01Sy9e9X5Wp8OZ4PJhUkUb-28b5CEzqxc,8874
|
62
|
-
cloudpss/runner/IESLabTypicalDayResult.py,sha256
|
62
|
+
cloudpss/runner/IESLabTypicalDayResult.py,sha256=lr8ID_Wk4zJagirReFoBJdedXoxUYt4CSQH9uZD6kKo,8179
|
63
63
|
cloudpss/runner/MessageStreamReceiver.py,sha256=dT-rKslQbRt3bMTGXupa1YrocHl2zTWOCHlsXcbgfhs,2812
|
64
64
|
cloudpss/runner/__init__.py,sha256=FxiYYmssbZgRjieySzi43yPiWEF6eNos2UsoFQeD2H8,341
|
65
65
|
cloudpss/runner/receiver.py,sha256=QU0RsbCt0EK7sCLHzfj8_QQsuPNfqXxpZi5JKm6roxA,4162
|
66
|
-
cloudpss/runner/result.py,sha256=
|
67
|
-
cloudpss/runner/runner.py,sha256=
|
66
|
+
cloudpss/runner/result.py,sha256=Q8RcfUnvilxPo6yvtjH6dXePaCqrBjQCljur3rem2pU,13290
|
67
|
+
cloudpss/runner/runner.py,sha256=oCK1PdDNArk25v9S7xvE5r6xfQu0EKHKuxKQN0CLUHE,10093
|
68
68
|
cloudpss/runner/storage.py,sha256=zFET_zwPIOF2Cnh9sgFiS0HFxV1OmVsU34bGUQ6PpkA,4162
|
69
69
|
cloudpss/runner/transform.py,sha256=krOgTZiJSJAb5QSwerAqlbC4Ma0PKi__0WOZlAxw4O8,11613
|
70
70
|
cloudpss/utils/IO.py,sha256=FsFp3V8I1-P0YiBGmjKwbMalBrVKMHUxTjFZFOtv0CQ,5357
|
71
71
|
cloudpss/utils/__init__.py,sha256=jWVHSOqJQWU0fpg2UbWSEQoLCb2Uys-vH5Uqkb0ihNA,326
|
72
72
|
cloudpss/utils/dataEncoder.py,sha256=5PUPb844eOGgFnYrMM8bdjdKH_MZz0lk-67uo8TvwEo,885
|
73
|
-
cloudpss/utils/graphqlUtil.py,sha256=
|
74
|
-
cloudpss/utils/httprequests.py,sha256=
|
73
|
+
cloudpss/utils/graphqlUtil.py,sha256=_bdHFlusvZd5p4I1iVq5nEKqeC2RdyiXbnfv7oQBvQA,332
|
74
|
+
cloudpss/utils/httprequests.py,sha256=5FXdXU5GUrsmreL7nEnJe1eD564HyrT9_379SRzwjrU,1907
|
75
75
|
cloudpss/utils/matlab.py,sha256=SLwVt790BjklJK2XNELt9R2n_1ej9Y8QsTIdFkKXLWE,795
|
76
76
|
cloudpss/utils/yamlLoader.py,sha256=bv_vPDK_e0n_vZ5FwpDJ_NJWqMAwfU3AbhkvQIxPCy4,2677
|
77
|
-
cloudpss-4.5.
|
78
|
-
cloudpss-4.5.
|
79
|
-
cloudpss-4.5.
|
80
|
-
cloudpss-4.5.
|
77
|
+
cloudpss-4.5.15.dist-info/METADATA,sha256=KOqxUSwk2EAQaYAS8rdF8ksGhxjSHkRji366qm6Zqpg,2402
|
78
|
+
cloudpss-4.5.15.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
79
|
+
cloudpss-4.5.15.dist-info/top_level.txt,sha256=wS9qPU4-aWM9ouzMOx34Nlq-GkdQKpr9vBskwut1BD8,9
|
80
|
+
cloudpss-4.5.15.dist-info/RECORD,,
|