ep-sdk-4pd 1.0.2__tar.gz → 1.0.4__tar.gz
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.
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/PKG-INFO +1 -1
- ep_sdk_4pd-1.0.4/ep_sdk_4pd/__init__.py +1 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd/ep_system.py +50 -2
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd/models.py +28 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd.egg-info/PKG-INFO +1 -1
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/setup.py +1 -1
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/tests/test_predict_data.py +1 -1
- ep_sdk_4pd-1.0.2/ep_sdk_4pd/__init__.py +0 -1
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/README.md +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd/ep_data.py +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd.egg-info/SOURCES.txt +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd.egg-info/dependency_links.txt +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd.egg-info/requires.txt +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/ep_sdk_4pd.egg-info/top_level.txt +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/setup.cfg +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/tests/test_call_train_done.py +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/tests/test_get_run_strategy.py +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/tests/test_get_system_date.py +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/tests/test_history_data.py +0 -0
- {ep_sdk_4pd-1.0.2 → ep_sdk_4pd-1.0.4}/tests/test_model_output_dir.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ep_sdk_4pd
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.4
|
4
4
|
Summary: 4paradigm Electricity Platform Service SDK Library for Python
|
5
5
|
Home-page: https://gitlab.4pd.io/electricityproject/electricity-platform-sdk
|
6
6
|
Author: 4paradigm Electricity Platform SDK
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = '1.0.4'
|
@@ -1,13 +1,14 @@
|
|
1
1
|
import json
|
2
2
|
import logging
|
3
3
|
import os
|
4
|
-
|
4
|
+
import rsa
|
5
|
+
import base64
|
5
6
|
import requests
|
6
7
|
|
7
8
|
from ep_sdk_4pd import models as ep_sdk_4pd_models
|
8
9
|
from datetime import datetime
|
9
10
|
|
10
|
-
from ep_sdk_4pd.models import ModelOutputDirRequest, RunStrategyRequest, CallTrainDoneRequest
|
11
|
+
from ep_sdk_4pd.models import ModelOutputDirRequest, RunStrategyRequest, CallTrainDoneRequest, RsaKeyRequest
|
11
12
|
|
12
13
|
# test 地址
|
13
14
|
# endpoint = 'http://172.27.88.56:6001'
|
@@ -20,6 +21,9 @@ endpoint = 'http://82.157.231.254:6001'
|
|
20
21
|
|
21
22
|
Authorization = 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJlbGVjdHJpY2l0eS1wbGF0Zm9ybSIsInN1YiI6IjEyMyIsImlhdCI6MTc0NjYwNjQ4NSwianRpIjoiMTIzXzE3NDY1Nzc2ODUxNDYiLCJ0eXBlIjoiYWNjZXNzIn0.Clrz_8j3aJlXTWPX-4DS0NxXN9idTcUIc0AtXOMIjd8'
|
22
23
|
|
24
|
+
def rsa_decrypt(privkey, ciphertext):
|
25
|
+
decrypted = rsa.decrypt(base64.b64decode(ciphertext), privkey)
|
26
|
+
return decrypted.decode('utf-8')
|
23
27
|
|
24
28
|
class EpSystem:
|
25
29
|
|
@@ -73,6 +77,16 @@ class EpSystem:
|
|
73
77
|
if is_online:
|
74
78
|
# 线上环境,随着真实调用运行时间变化
|
75
79
|
system_date = datetime.now().strftime('%Y-%m-%d')
|
80
|
+
|
81
|
+
target_date = os.environ.get('TARGET_DATE')
|
82
|
+
# target_date = 'JgAgrcfaQBI0h5YtLGGCjH92snKB3pUBOQs8yy0/mxMBdur0jNvAz6LzpU+Vq3QXsf36jy79WCrgVFo+0RwfUN338VJ9Qe+HwPfe0eq29De6eLD3nOl8xORj339dtSEdXq4dwc2mTaIxQc+erpv4acgQ7YVSDX6AuprwfW7c7qxthziqCqHxVm/qZwUkMsQ1fgzVLeICdscbCJbCD5GFYSpohaP5hRebutoa5FqyhYURA/4kxus98lJsENhnOZAACFdnCWDklpkKZyyOq0aKMd8Vv9SWX1LAZVTRjQ1GGuUPyOYjvnhUyNeRo3D85ODGBFeEju8rjDEB8LFSvX5d3Q=='
|
83
|
+
if target_date is not None:
|
84
|
+
rsa_data = EpSystem.get_rsa_key()
|
85
|
+
if rsa_data:
|
86
|
+
rsa_private_key = rsa_data['rsa_private_key']
|
87
|
+
loaded_privkey = rsa.PrivateKey.load_pkcs1(rsa_private_key.encode('utf-8'))
|
88
|
+
decrypted_data = rsa_decrypt(loaded_privkey, target_date)
|
89
|
+
system_date = decrypted_data
|
76
90
|
else:
|
77
91
|
# 线下环境
|
78
92
|
system_date = "2024-12-31"
|
@@ -167,3 +181,37 @@ class EpSystem:
|
|
167
181
|
return True
|
168
182
|
else:
|
169
183
|
return False
|
184
|
+
|
185
|
+
@staticmethod
|
186
|
+
def get_rsa_key():
|
187
|
+
request = RsaKeyRequest()
|
188
|
+
response = EpSystem.rsa_key(request=request)
|
189
|
+
|
190
|
+
if response.code == 200:
|
191
|
+
return response.data
|
192
|
+
else:
|
193
|
+
return None
|
194
|
+
|
195
|
+
@staticmethod
|
196
|
+
def rsa_key(
|
197
|
+
request: ep_sdk_4pd_models.RsaKeyRequest = None,
|
198
|
+
) -> ep_sdk_4pd_models.RsaKeyResponse:
|
199
|
+
|
200
|
+
full_url = f'{endpoint}{request.api}'
|
201
|
+
headers = {
|
202
|
+
'content-type': request.content_type,
|
203
|
+
'Authorization': Authorization
|
204
|
+
}
|
205
|
+
|
206
|
+
response = requests.request(
|
207
|
+
method=request.method,
|
208
|
+
url=full_url,
|
209
|
+
headers=headers,
|
210
|
+
)
|
211
|
+
|
212
|
+
base_resp = ep_sdk_4pd_models.BaseResponse(
|
213
|
+
code=response.json().get('code', None),
|
214
|
+
data=response.json().get('data', None),
|
215
|
+
message=response.json().get('message', None),
|
216
|
+
)
|
217
|
+
return ep_sdk_4pd_models.RsaKeyResponse(response=base_resp)
|
@@ -202,6 +202,34 @@ class CallTrainDoneResponse(BaseResponse):
|
|
202
202
|
Model for CallTrainDoneResponse
|
203
203
|
"""
|
204
204
|
|
205
|
+
def __init__(self, response: BaseResponse = None, **kwargs):
|
206
|
+
super().__init__(
|
207
|
+
code=response.code if response else None,
|
208
|
+
data=response.data if response else None,
|
209
|
+
message=response.message if response else None,
|
210
|
+
**kwargs,
|
211
|
+
)
|
212
|
+
|
213
|
+
class RsaKeyRequest(BaseRequest):
|
214
|
+
"""
|
215
|
+
Model for RsaKeyRequest
|
216
|
+
"""
|
217
|
+
|
218
|
+
def __init__(
|
219
|
+
self
|
220
|
+
):
|
221
|
+
|
222
|
+
super().__init__()
|
223
|
+
self.api = f'/ep/api/sdk/get_rsa_key'
|
224
|
+
self.method = 'GET'
|
225
|
+
self.content_type = 'application/json'
|
226
|
+
|
227
|
+
|
228
|
+
class RsaKeyResponse(BaseResponse):
|
229
|
+
"""
|
230
|
+
Model for RsaKeyResponse
|
231
|
+
"""
|
232
|
+
|
205
233
|
def __init__(self, response: BaseResponse = None, **kwargs):
|
206
234
|
super().__init__(
|
207
235
|
code=response.code if response else None,
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: ep_sdk_4pd
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.4
|
4
4
|
Summary: 4paradigm Electricity Platform Service SDK Library for Python
|
5
5
|
Home-page: https://gitlab.4pd.io/electricityproject/electricity-platform-sdk
|
6
6
|
Author: 4paradigm Electricity Platform SDK
|
@@ -8,7 +8,7 @@ DESCRIPTION = '4paradigm Electricity Platform Service SDK Library for Python'
|
|
8
8
|
AUTHOR = '4paradigm Electricity Platform SDK'
|
9
9
|
AUTHOR_EMAIL = ''
|
10
10
|
URL = 'https://gitlab.4pd.io/electricityproject/electricity-platform-sdk'
|
11
|
-
VERSION = '1.0.
|
11
|
+
VERSION = '1.0.4'
|
12
12
|
REQUIRES = ['requests']
|
13
13
|
|
14
14
|
LONG_DESCRIPTION = ''
|
@@ -4,7 +4,7 @@ from ep_sdk_4pd.ep_data import EpData
|
|
4
4
|
def test_predict_data():
|
5
5
|
print('-------------test_predict_data-------------')
|
6
6
|
|
7
|
-
data = EpData.get_predict_data(scope="plant"
|
7
|
+
data = EpData.get_predict_data(scope="plant")
|
8
8
|
print(data)
|
9
9
|
print('-------------------------------------')
|
10
10
|
|
@@ -1 +0,0 @@
|
|
1
|
-
__version__ = '1.0.2'
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|