ep-sdk-4pd 1.1.1__tar.gz → 1.1.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ep_sdk_4pd
3
- Version: 1.1.1
3
+ Version: 1.1.2
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.1.2'
@@ -1,14 +1,15 @@
1
+ import base64
1
2
  import json
2
3
  import logging
3
4
  import os
4
- import rsa
5
- import base64
5
+ from datetime import datetime
6
+ from pathlib import Path
7
+
6
8
  import requests
9
+ import rsa
7
10
 
8
11
  from ep_sdk_4pd import models as ep_sdk_4pd_models
9
- from datetime import datetime
10
-
11
- from ep_sdk_4pd.models import ModelOutputDirRequest, RunStrategyRequest, CallTrainDoneRequest, RsaKeyRequest
12
+ from ep_sdk_4pd.models import RunStrategyRequest, CallTrainDoneRequest, RsaKeyRequest
12
13
 
13
14
  # test 地址
14
15
  # endpoint = 'http://172.27.88.56:6001'
@@ -29,45 +30,29 @@ class EpSystem:
29
30
 
30
31
  @staticmethod
31
32
  def model_output_dir(is_online: bool = True):
33
+ user_home = os.path.expanduser('~')
34
+ base_dir = os.path.join(user_home, "modelResult")
35
+
32
36
  if is_online:
33
37
  # 从环境变量中获取策略id
34
- strategy_id = os.getenv('STRATEGY_ID')
38
+ # strategy_id = os.getenv('STRATEGY_ID')
39
+ strategy_id = 1
35
40
  logging.info(f'strategy_id: {strategy_id}')
36
41
 
37
42
  if strategy_id is None:
38
43
  raise Exception('STRATEGY_ID is not set')
44
+
45
+ target_dir = os.path.join(base_dir, f"{strategy_id}")
39
46
  else:
40
- # 线下环境,给固定的策略id
41
- strategy_id = 63
42
- request = ModelOutputDirRequest(strategy_id=strategy_id)
43
- full_url = f'{endpoint}{request.api}'
44
- headers = {
45
- 'content-type': request.content_type,
46
- 'Authorization': Authorization
47
- }
47
+ # 线下环境
48
+ target_dir = os.path.join(base_dir, "test")
48
49
 
49
- payload = {
50
- 'strategy_id': request.strategy_id
51
- }
50
+ Path(target_dir).mkdir(parents=True, exist_ok=True)
52
51
 
53
- response = requests.request(
54
- method=request.method,
55
- url=full_url,
56
- headers=headers,
57
- data=json.dumps(payload),
58
- )
52
+ abs_path = os.path.abspath(target_dir)
59
53
 
60
- base_resp = ep_sdk_4pd_models.BaseResponse(
61
- code=response.json().get('code', None),
62
- data=response.json().get('data', None),
63
- message=response.json().get('message', None),
64
- )
65
- response = ep_sdk_4pd_models.ModelOutputDirResponse(response=base_resp)
54
+ return abs_path
66
55
 
67
- if response.code == 200:
68
- return response.data
69
- else:
70
- return None
71
56
 
72
57
  @staticmethod
73
58
  def get_system_date(is_online: bool = True):
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ep_sdk_4pd
3
- Version: 1.1.1
3
+ Version: 1.1.2
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.1.1'
11
+ VERSION = '1.1.2'
12
12
  REQUIRES = ['requests']
13
13
 
14
14
  LONG_DESCRIPTION = ''
@@ -0,0 +1,24 @@
1
+ import datetime
2
+ from turtle import pd
3
+
4
+ from ep_sdk_4pd.ep_data import EpData
5
+ from ep_sdk_4pd.ep_system import EpSystem
6
+
7
+
8
+ def test_history_data():
9
+ print('-------------test_history_data-------------')
10
+
11
+ system_data = EpSystem.get_system_date()
12
+ dt1 = datetime.datetime.strptime("2024-01-01", "%Y-%m-%d")
13
+ dt2 = datetime.datetime.strptime(system_data, "%Y-%m-%d")
14
+ gaps = dt2 - dt1
15
+ gap_days = gaps.days
16
+ print("gap_days:", gap_days)
17
+
18
+ data = EpData.get_history_data(scope="market",days=gap_days)
19
+ print(data)
20
+ print('-------------------------------------')
21
+
22
+
23
+ if __name__ == '__main__':
24
+ test_history_data()
@@ -4,7 +4,9 @@ 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()
8
+ weather = data['weather']
9
+ plant = data['plant']
8
10
  print(data)
9
11
  print('-------------------------------------')
10
12
 
@@ -1 +0,0 @@
1
- __version__ = '1.1.1'
@@ -1,16 +0,0 @@
1
- from ep_sdk_4pd.ep_data import EpData
2
-
3
-
4
- def test_history_data():
5
- print('-------------test_history_data-------------')
6
-
7
- data = EpData.get_history_data(scope="market",days=1)
8
- # print(data)
9
- market = data.get("market")
10
- for m in market:
11
- print(m.get("day_ahead_tieline_power"))
12
- print('-------------------------------------')
13
-
14
-
15
- if __name__ == '__main__':
16
- test_history_data()
File without changes
File without changes