cloudpss 4.5.1a3__py3-none-any.whl → 4.5.1a5__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 +23 -0
- cloudpss/dslab/dslab.py +50 -4
- cloudpss/job/TemplateManager.py +1 -0
- cloudpss/runner/runner.py +10 -7
- cloudpss/utils/parseDebugArgs.py +93 -0
- cloudpss/version.py +1 -1
- {cloudpss-4.5.1a3.dist-info → cloudpss-4.5.1a5.dist-info}/METADATA +1 -1
- {cloudpss-4.5.1a3.dist-info → cloudpss-4.5.1a5.dist-info}/RECORD +10 -9
- {cloudpss-4.5.1a3.dist-info → cloudpss-4.5.1a5.dist-info}/WHEEL +0 -0
- {cloudpss-4.5.1a3.dist-info → cloudpss-4.5.1a5.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
from ..utils import request, fileLoad, graphql_request
|
2
2
|
import json
|
3
3
|
import time, datetime
|
4
|
+
import urllib.parse
|
4
5
|
import copy
|
5
6
|
import os
|
6
7
|
from cloudpss.dslab.files import getCurveData
|
@@ -268,6 +269,28 @@ class DataManageModel(object):
|
|
268
269
|
if data.get('extra', None) is None:
|
269
270
|
return None
|
270
271
|
return data.get('extra', None).get('data', None)
|
272
|
+
|
273
|
+
def UpdateItemExtra(self, kind, data):
|
274
|
+
'''
|
275
|
+
更新kind类型对应数据项的基准出力曲线、负荷曲线、策略曲线数据
|
276
|
+
:params: kind str类型,数据的种类标识,包含:光伏、光伏曲线、风机、风机曲线、燃气、燃气曲线、水电、水电曲线、火电、火电曲线、生物质发电、生物质发电曲线、垃圾电厂、垃圾电厂曲线、传输线、变压器、开关、负荷分类、负荷用户、储能设备、储能运行策略、上网电价、输配电价、常数电价、阶梯电价、分时电价、分时阶梯电价
|
277
|
+
:params: data dict类型,表示添加的数据内容,其数据结构应满足对应数据项的结构要求,形如:{'data': {}, 'extra': [], 'id': ""}
|
278
|
+
|
279
|
+
:return: list<dict>类型,返回该种类下所有数据项的列表
|
280
|
+
'''
|
281
|
+
# 检查extra是否为空
|
282
|
+
if not data['extra']:
|
283
|
+
raise ValueError("extra 不能为空,必须包含有效的数据")
|
284
|
+
|
285
|
+
url = f"{self._baseUri}rest/{kind}"
|
286
|
+
r = {
|
287
|
+
'id': data.get('id', ''),
|
288
|
+
'data': data.get('data', {}),
|
289
|
+
'extra': data.get('extra', []),
|
290
|
+
}
|
291
|
+
|
292
|
+
self._updateItemData(url, r)
|
293
|
+
return self._fetchItemData(url)
|
271
294
|
|
272
295
|
class DSLabDataManageModel(DataManageModel):
|
273
296
|
_baseUri = 'api/dslab/'
|
cloudpss/dslab/dslab.py
CHANGED
@@ -146,6 +146,43 @@ class DSLab(object):
|
|
146
146
|
raise Exception("不是储能规划方案内核运行生成算法的计算方案")
|
147
147
|
return self.run(job=job, name=name)
|
148
148
|
|
149
|
+
def runIESShortCurrent(self,job=None,name=None, **kwargs)->Runner[IESResult]:
|
150
|
+
'''
|
151
|
+
运行 短路电流计算 内核,如果当前 model 没有创建 Job 时报错,默认使用第一个计算方案,进行仿真。
|
152
|
+
|
153
|
+
:param: job 计算方案名称,可选,字符串类型或者字典类型,默认使用第一个计算方案,如果同名使用最靠前一个
|
154
|
+
:params name: 任务名称,为空时使用项目的参数方案名称和计算方案名称
|
155
|
+
|
156
|
+
:return: runner Runner[IESResult]
|
157
|
+
'''
|
158
|
+
rid = 'function/CloudPSS/short-circuit-current-calculation'
|
159
|
+
if job is None:
|
160
|
+
currentJob = self.model.context['currentJob']
|
161
|
+
job = self.model.jobs[currentJob]
|
162
|
+
if job['rid'] != rid:
|
163
|
+
for j in self.model.jobs:
|
164
|
+
if j['rid'] == rid:
|
165
|
+
job = j
|
166
|
+
if job is None:
|
167
|
+
raise Exception("找不到短路电流计算方案内核运行的计算方案")
|
168
|
+
if job['rid'] != rid:
|
169
|
+
raise Exception("不是短路电流计算方案内核运行生成算法的计算方案")
|
170
|
+
return self.run(job=job, name=name)
|
171
|
+
|
172
|
+
@staticmethod
|
173
|
+
def getProjectGroupList():
|
174
|
+
'''
|
175
|
+
获取项目组列表
|
176
|
+
|
177
|
+
:return: List[Dict] 返回项目组列表
|
178
|
+
'''
|
179
|
+
try:
|
180
|
+
r = request('GET', 'api/dslab/rest/group')
|
181
|
+
groupList = json.loads(r.text)
|
182
|
+
return groupList
|
183
|
+
except Exception as e:
|
184
|
+
raise Exception('获取项目组列表失败')
|
185
|
+
|
149
186
|
@staticmethod
|
150
187
|
def createProjectGroup(name, description=None, createById=None):
|
151
188
|
'''
|
@@ -173,18 +210,19 @@ class DSLab(object):
|
|
173
210
|
if r.ok:
|
174
211
|
r = request('GET', 'api/dslab/rest/group')
|
175
212
|
groupList = json.loads(r.text)
|
176
|
-
id = groupList[len(groupList) -1].get('id', None)
|
213
|
+
id = groupList[len(groupList) -1].get('id', None)\
|
214
|
+
|
177
215
|
return id
|
178
216
|
except Exception as e:
|
179
217
|
raise Exception('创建项目组失败')
|
180
218
|
|
181
219
|
@staticmethod
|
182
|
-
def createProject(name,
|
220
|
+
def createProject(name, groupName, description=None, initialTerm=None, build=None, operate=None, yearsInOperation=None):
|
183
221
|
'''
|
184
222
|
创建项目
|
185
223
|
|
186
224
|
:params name: String 项目名称
|
187
|
-
:params
|
225
|
+
:params groupName: String 父项目组名称,
|
188
226
|
:params description: String 项目描述, 可选参数
|
189
227
|
:params initialTerm: String 项目起始年限,可选参数
|
190
228
|
:params build: String 项目建设期(年),可选参数
|
@@ -194,6 +232,14 @@ class DSLab(object):
|
|
194
232
|
:return: Int 返回创建的项目id
|
195
233
|
'''
|
196
234
|
try:
|
235
|
+
groupList = DSLab.getProjectGroupList()
|
236
|
+
matchedGroup = next((g for g in groupList if g.get('name') == groupName), None)
|
237
|
+
if not matchedGroup:
|
238
|
+
gid = DSLab.createProjectGroup(groupName)
|
239
|
+
else:
|
240
|
+
gid = matchedGroup.get('id')
|
241
|
+
if gid is None:
|
242
|
+
raise Exception(f"项目组 {groupName} 缺少 id 字段")
|
197
243
|
payload = {
|
198
244
|
'name': name,
|
199
245
|
'gid': gid,
|
@@ -210,4 +256,4 @@ class DSLab(object):
|
|
210
256
|
project = json.loads(r.text)
|
211
257
|
return project.get('resource', None)
|
212
258
|
except Exception as e:
|
213
|
-
raise Exception('
|
259
|
+
raise Exception(f'创建项目失败: {e}')
|
cloudpss/job/TemplateManager.py
CHANGED
cloudpss/runner/runner.py
CHANGED
@@ -65,7 +65,11 @@ class Runner(Generic[T]):
|
|
65
65
|
self.taskId = taskId
|
66
66
|
self.db = Storage(taskId, name, job, config, revision, modelRid)
|
67
67
|
rid =job['rid'].replace('job-definition/','function/').replace('/cloudpss/','/CloudPSS/')
|
68
|
-
|
68
|
+
resultClass = kwargs.get('RESULT_DB', None)
|
69
|
+
if resultClass is not None:
|
70
|
+
result = resultClass
|
71
|
+
else:
|
72
|
+
result = RESULT_DB.get(rid, Result)
|
69
73
|
self.result: T = result(self.db)
|
70
74
|
self.receiver = kwargs.get('receiver', None)
|
71
75
|
|
@@ -92,15 +96,14 @@ class Runner(Generic[T]):
|
|
92
96
|
def __listen(self, **kwargs):
|
93
97
|
|
94
98
|
receiver = kwargs.get('RECEIVER', 'default')
|
95
|
-
receiverclass = None
|
96
99
|
if type(receiver) is str:
|
97
100
|
if receiver not in RECEIVER:
|
98
|
-
|
101
|
+
receiver = RECEIVER['default']
|
99
102
|
else:
|
100
|
-
|
101
|
-
if
|
103
|
+
receiver = RECEIVER[receiver]
|
104
|
+
if receiver is None:
|
102
105
|
raise Exception('not find receiver')
|
103
|
-
self.receiver =
|
106
|
+
self.receiver = receiver(self.taskId, self.db, **kwargs)
|
104
107
|
self.receiver.connect()
|
105
108
|
|
106
109
|
def terminate(self):
|
@@ -148,7 +151,7 @@ class Runner(Generic[T]):
|
|
148
151
|
tres[k] = float(v) # type: ignore
|
149
152
|
policy["tres"] = tres
|
150
153
|
function = job["rid"].replace("job-definition/cloudpss/", "function/CloudPSS/")
|
151
|
-
implement = kwargs.get("implement", None)
|
154
|
+
implement = kwargs.get("implement", kwargs.get("topology", None))
|
152
155
|
debug = job["args"].get("@debug", None )
|
153
156
|
debugargs={}
|
154
157
|
if debug is not None:
|
@@ -0,0 +1,93 @@
|
|
1
|
+
def parse_debug_args(debug=None):
|
2
|
+
if not debug or not isinstance(debug, str):
|
3
|
+
return None
|
4
|
+
|
5
|
+
tokens = []
|
6
|
+
|
7
|
+
# 1. 先按照非转义的空格拆分字符串,获取每个 token
|
8
|
+
current_token = ''
|
9
|
+
escaping = False # 表示当前是否在处理转义字符
|
10
|
+
|
11
|
+
for char in debug:
|
12
|
+
if escaping:
|
13
|
+
# 如果上一个字符是 '\',则把当前字符直接添加到 token,并保留 '\' 以供二阶段使用
|
14
|
+
current_token += '\\' + char
|
15
|
+
escaping = False
|
16
|
+
elif char == '\\':
|
17
|
+
# 开始转义
|
18
|
+
escaping = True
|
19
|
+
elif char.isspace():
|
20
|
+
# 如果遇到空格 (并且不在转义状态),说明一个 token 结束
|
21
|
+
if current_token:
|
22
|
+
tokens.append(current_token)
|
23
|
+
current_token = ''
|
24
|
+
else:
|
25
|
+
# 普通字符,直接添加
|
26
|
+
current_token += char
|
27
|
+
|
28
|
+
# 最后一个 token 加入数组(如果有的话)
|
29
|
+
if current_token:
|
30
|
+
tokens.append(current_token)
|
31
|
+
|
32
|
+
if not tokens:
|
33
|
+
return None
|
34
|
+
|
35
|
+
# 2. 对每个 token,找第一个非转义的 '=' 分割 key/value
|
36
|
+
entries = []
|
37
|
+
|
38
|
+
for token in tokens:
|
39
|
+
key = ''
|
40
|
+
value = ''
|
41
|
+
has_equal = False
|
42
|
+
escaping = False
|
43
|
+
|
44
|
+
# 我们只需要区分第一处真正的 '='
|
45
|
+
for char in token:
|
46
|
+
if escaping:
|
47
|
+
# 处理转义字符
|
48
|
+
if char == 'b':
|
49
|
+
escaped_char = '\b'
|
50
|
+
elif char == 'f':
|
51
|
+
escaped_char = '\f'
|
52
|
+
elif char == 'n':
|
53
|
+
escaped_char = '\n'
|
54
|
+
elif char == 'r':
|
55
|
+
escaped_char = '\r'
|
56
|
+
elif char == 't':
|
57
|
+
escaped_char = '\t'
|
58
|
+
elif char == 'v':
|
59
|
+
escaped_char = '\v'
|
60
|
+
else:
|
61
|
+
escaped_char = char
|
62
|
+
|
63
|
+
# 直接添加当前字符
|
64
|
+
if not has_equal:
|
65
|
+
key += escaped_char
|
66
|
+
else:
|
67
|
+
if escaped_char in ['\\', '$']:
|
68
|
+
# 保留转义字符
|
69
|
+
value += '\\' + escaped_char
|
70
|
+
else:
|
71
|
+
value += escaped_char
|
72
|
+
escaping = False
|
73
|
+
elif char == '\\':
|
74
|
+
escaping = True
|
75
|
+
elif char == '=' and not has_equal:
|
76
|
+
# 遇到第一个非转义的 '=' 时,视为 key/value 分隔
|
77
|
+
has_equal = True
|
78
|
+
else:
|
79
|
+
# 普通字符
|
80
|
+
if not has_equal:
|
81
|
+
key += char
|
82
|
+
else:
|
83
|
+
value += char
|
84
|
+
|
85
|
+
# 添加 key 和 value 到 entries 列表
|
86
|
+
entries.append((key, value))
|
87
|
+
|
88
|
+
return dict(entries)
|
89
|
+
|
90
|
+
# 示例用法
|
91
|
+
# debug_str = r"TASK_CMD=cloudpssrun:mkl DOCKER_MOUNT=/dev/disk/by-id:/dev/disk/by-id:ro\n/home/cloudpss/NR_ADPSS_HVDC37.key:/usr/include/NR_ADPSS_HVDC37.key:ro\n"
|
92
|
+
# result = parse_debug_args(debug_str)
|
93
|
+
# print(result)
|
cloudpss/version.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = '4.5.1-alpha.
|
1
|
+
__version__ = '4.5.1-alpha.5'
|
@@ -1,6 +1,6 @@
|
|
1
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=WQQpTkl0Fv5kum9EfUBunVFJl-fchr774Np_AamkokQ,30
|
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
|
@@ -14,8 +14,8 @@ cloudpss/asyncio/utils/AsyncIterable.py,sha256=AIWYrTnmjsIfOowE3asZlexdHNhpK2gm7
|
|
14
14
|
cloudpss/asyncio/utils/__init__.py,sha256=F-rCvgRAGcV-fFO7o-dsXwooyhcVpElWoBEQM67kO7c,84
|
15
15
|
cloudpss/asyncio/utils/httpAsyncRequest.py,sha256=KIck-3uQwGcHMIJ6632_Zo0syc4GnNG2EoUXmQh54ck,2692
|
16
16
|
cloudpss/dslab/__init__.py,sha256=UdLDA9OArvLndHtumYAMMHdr5h8S6DrZCYkXIi2Mb4Y,45
|
17
|
-
cloudpss/dslab/dataManageModel.py,sha256=
|
18
|
-
cloudpss/dslab/dslab.py,sha256=
|
17
|
+
cloudpss/dslab/dataManageModel.py,sha256=iOtpQ2uG4nK2pXztf_wnDnn4OAvX4yokGvXbbSQjqAw,12857
|
18
|
+
cloudpss/dslab/dslab.py,sha256=HTr8dKy6UNbQfX9NlCxmgL7OTwuBoHIwF9kW7PjcoXU,10751
|
19
19
|
cloudpss/dslab/financialAnalysisModel.py,sha256=t9cZ03yWvLN5ojVeLp-UGgFBIFVU5wbnn5E0UHZA0ws,5062
|
20
20
|
cloudpss/dslab/files/__init__.py,sha256=l2g0VadtTiMW39zwCwHPHUC01Kbklb_nFUPVeQ16FwM,58
|
21
21
|
cloudpss/dslab/files/curveData.py,sha256=GU_DTTKjVn_ln9Hx0q9CFgfmNtokZi7b4DYSzGeP5dk,4291778
|
@@ -32,7 +32,7 @@ cloudpss/ieslab/IESLabSimulation.py,sha256=-EJFkhklN9ao-nbfk7Lz6JCHboFCSDcn5R2jr
|
|
32
32
|
cloudpss/ieslab/PlanModel.py,sha256=WHvXWNFgi7fO_M-sL9empRgHR5riCj1jeThBRT-oqEc,14088
|
33
33
|
cloudpss/ieslab/__init__.py,sha256=gr1rXYw9vIAGOe60eg7LyMHP7QDXvNf4dJ5GTR_kj1Y,232
|
34
34
|
cloudpss/job/TemplateCompiler.py,sha256=MuJDTQ54wRo5bGSvBJBJjXJ7u463dwpRkaLwIwm_hLE,9936
|
35
|
-
cloudpss/job/TemplateManager.py,sha256=
|
35
|
+
cloudpss/job/TemplateManager.py,sha256=uOvctmE3P17aGWt_26d940FbRUSEs6iovFBb8T5xjd4,1115
|
36
36
|
cloudpss/job/__init__.py,sha256=3UIFZYjJTzuckM61o8kim1c3PWt2SSHTL72jrGu5IzI,51
|
37
37
|
cloudpss/job/job.py,sha256=pV-J0VBnyExIabzt2hMnIvLFdowWz-QT0DuR80Gv9AE,8297
|
38
38
|
cloudpss/job/jobReceiver.py,sha256=PNYxcN33LiXZVyc4tzhPlpWxKnyWO_ElKjJ9wsxsroI,925
|
@@ -64,7 +64,7 @@ cloudpss/runner/MessageStreamReceiver.py,sha256=dT-rKslQbRt3bMTGXupa1YrocHl2zTWO
|
|
64
64
|
cloudpss/runner/__init__.py,sha256=FxiYYmssbZgRjieySzi43yPiWEF6eNos2UsoFQeD2H8,341
|
65
65
|
cloudpss/runner/receiver.py,sha256=QU0RsbCt0EK7sCLHzfj8_QQsuPNfqXxpZi5JKm6roxA,4162
|
66
66
|
cloudpss/runner/result.py,sha256=Q8RcfUnvilxPo6yvtjH6dXePaCqrBjQCljur3rem2pU,13290
|
67
|
-
cloudpss/runner/runner.py,sha256=
|
67
|
+
cloudpss/runner/runner.py,sha256=fBsJEzquXP87ynWBfW9zynH9EzK9aLCaZHu1GqnbI7w,9727
|
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=sm6p53AFgE1b56Bh0qt_E2TFP5tLr0WQDzIVRlsNgFA,5321
|
@@ -73,8 +73,9 @@ cloudpss/utils/dataEncoder.py,sha256=5PUPb844eOGgFnYrMM8bdjdKH_MZz0lk-67uo8TvwEo
|
|
73
73
|
cloudpss/utils/graphqlUtil.py,sha256=zGEhRZvy5JMipFKFxjDmbc-HQP3aPZ5noDwi-RTXWSk,280
|
74
74
|
cloudpss/utils/httprequests.py,sha256=KYE8iIqaBEN6gTdxFgUyvdKf3kbSizxxgmNN8_1BQjQ,1850
|
75
75
|
cloudpss/utils/matlab.py,sha256=SLwVt790BjklJK2XNELt9R2n_1ej9Y8QsTIdFkKXLWE,795
|
76
|
+
cloudpss/utils/parseDebugArgs.py,sha256=r8EptSHG9D-U7dT3pHFDclL-8G2La9w4GEjUAY-rsMc,3174
|
76
77
|
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.
|
78
|
+
cloudpss-4.5.1a5.dist-info/METADATA,sha256=MSrlV6VoOl_i2PFTjg1Lb9ySbBYtzol2zQoa73tEuus,2403
|
79
|
+
cloudpss-4.5.1a5.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
80
|
+
cloudpss-4.5.1a5.dist-info/top_level.txt,sha256=wS9qPU4-aWM9ouzMOx34Nlq-GkdQKpr9vBskwut1BD8,9
|
81
|
+
cloudpss-4.5.1a5.dist-info/RECORD,,
|
File without changes
|
File without changes
|