cloudpss 4.5.1a4__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.
@@ -278,6 +278,10 @@ class DataManageModel(object):
278
278
 
279
279
  :return: list<dict>类型,返回该种类下所有数据项的列表
280
280
  '''
281
+ # 检查extra是否为空
282
+ if not data['extra']:
283
+ raise ValueError("extra 不能为空,必须包含有效的数据")
284
+
281
285
  url = f"{self._baseUri}rest/{kind}"
282
286
  r = {
283
287
  'id': data.get('id', ''),
cloudpss/dslab/dslab.py CHANGED
@@ -168,6 +168,20 @@ class DSLab(object):
168
168
  if job['rid'] != rid:
169
169
  raise Exception("不是短路电流计算方案内核运行生成算法的计算方案")
170
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('获取项目组列表失败')
171
185
 
172
186
  @staticmethod
173
187
  def createProjectGroup(name, description=None, createById=None):
@@ -196,18 +210,19 @@ class DSLab(object):
196
210
  if r.ok:
197
211
  r = request('GET', 'api/dslab/rest/group')
198
212
  groupList = json.loads(r.text)
199
- id = groupList[len(groupList) -1].get('id', None)
213
+ id = groupList[len(groupList) -1].get('id', None)\
214
+
200
215
  return id
201
216
  except Exception as e:
202
217
  raise Exception('创建项目组失败')
203
218
 
204
219
  @staticmethod
205
- def createProject(name, gid, description=None, initialTerm=None, build=None, operate=None, yearsInOperation=None):
220
+ def createProject(name, groupName, description=None, initialTerm=None, build=None, operate=None, yearsInOperation=None):
206
221
  '''
207
222
  创建项目
208
223
 
209
224
  :params name: String 项目名称
210
- :params gid: Int 父项目组id,
225
+ :params groupName: String 父项目组名称,
211
226
  :params description: String 项目描述, 可选参数
212
227
  :params initialTerm: String 项目起始年限,可选参数
213
228
  :params build: String 项目建设期(年),可选参数
@@ -217,6 +232,14 @@ class DSLab(object):
217
232
  :return: Int 返回创建的项目id
218
233
  '''
219
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 字段")
220
243
  payload = {
221
244
  'name': name,
222
245
  'gid': gid,
@@ -233,4 +256,4 @@ class DSLab(object):
233
256
  project = json.loads(r.text)
234
257
  return project.get('resource', None)
235
258
  except Exception as e:
236
- raise Exception('创建项目失败')
259
+ raise Exception(f'创建项目失败: {e}')
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
- result = RESULT_DB.get(rid, Result)
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
- receiverclass = RECEIVER['default']
101
+ receiver = RECEIVER['default']
99
102
  else:
100
- receiverclass = RECEIVER[receiver]
101
- if receiverclass is None:
103
+ receiver = RECEIVER[receiver]
104
+ if receiver is None:
102
105
  raise Exception('not find receiver')
103
- self.receiver = receiverclass(self.taskId, self.db, **kwargs)
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.4'
1
+ __version__ = '4.5.1-alpha.5'
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cloudpss
3
- Version: 4.5.1a4
3
+ Version: 4.5.1a5
4
4
  Summary: cloudpss sdk
5
5
  Home-page: https://www.cloudpss.net
6
6
  Author: cloudpss
@@ -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=eGA062vl8AmZfcIp-LER6wH9XoJb0sNElWP_UI1RVzg,30
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=NeG2YbIappMxAOCZGfFUcOBwo2Kyhh27kHMFK37re60,12711
18
- cloudpss/dslab/dslab.py,sha256=K__KohK6w6Alj3WCmLJQ2pr_RPFvvtnce2C6tdLhTIE,9914
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
@@ -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=DPMiG_M-baWUAX7o9vL7p_Zr-r9nnTky5OYjig_yenU,9613
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.1a4.dist-info/METADATA,sha256=w_5acTa5b8_g4khe4TZB2P00TwOfowToLtpDNIkiu7E,2403
78
- cloudpss-4.5.1a4.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
79
- cloudpss-4.5.1a4.dist-info/top_level.txt,sha256=wS9qPU4-aWM9ouzMOx34Nlq-GkdQKpr9vBskwut1BD8,9
80
- cloudpss-4.5.1a4.dist-info/RECORD,,
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,,