dts-dance 0.2.0__py3-none-any.whl → 0.2.1__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dts-dance
3
- Version: 0.2.0
3
+ Version: 0.2.1
4
4
  Summary: dts dance lib
5
5
  Keywords: observation,tools
6
6
  Requires-Python: >=3.12
@@ -1,14 +1,14 @@
1
1
  dtsdance/__init__.py,sha256=Yl_jEZ5weYfcrklnDvwB4wSgCOvMBLRRgWx0gHs3qfM,49
2
2
  dtsdance/bytecloud.py,sha256=SN82KIYAfq16s06-HUoj37PbgSbUa7MoFFcah2kaXOk,5213
3
- dtsdance/dflow.py,sha256=WtD3AbDgGRraddJIxzZs8Bd6Ts56XtqJcjb0UrhnWFQ,5097
3
+ dtsdance/dflow.py,sha256=N9u7uB9UyUbB2FswBezXB9SbwmlDr3PWhY_eUZJeQ-8,7064
4
4
  dtsdance/dsyncer.py,sha256=X59sKDvK6rDeumCajepcqSSJysDfvJByYZAhcdOyNLw,11179
5
5
  dtsdance/feishu_base.py,sha256=2j4ZM4PFqJ-9EhC6DQ1OmAg--3VBGZyyRuxyjL0j6OU,3733
6
6
  dtsdance/feishu_table.py,sha256=ZUeoKrM4nmm5hFhc3vWOVYeLP390orm-284Od92G4iQ,8424
7
7
  dtsdance/metrics_fe.py,sha256=hzIl5BJmuCrkqJOHELVzXm3YAqrPttbyVkKBglS4mgQ,18978
8
8
  dtsdance/s3.py,sha256=Bh-cwLksfO5PewNtIzE_Md3rRLDLI1DUVoOD7Pou5T8,1294
9
- dtsdance/spacex.py,sha256=lVhDfGzFZsfeYhWGT-8AE3JM5ZksJdBWRQ-GRL0ymqY,2342
9
+ dtsdance/spacex.py,sha256=eYPx3-VKgPK6-IO8-HPuX0-mxsM6kt1HMZqyDA_KPbw,2340
10
10
  dtsdance/tcc_inner.py,sha256=xy3N1N3BNl1oc2oMNHKhnsj47rAKOOJ-aXw8GtA2De8,1621
11
- dtsdance/tcc_open.py,sha256=wjUh56_CDb15s0qXw61fb5JehgIVcySUf0hTaF7V92Y,6674
12
- dts_dance-0.2.0.dist-info/METADATA,sha256=7IBiJk2ubNRRx2p6gjWnSxqYXa1PzQ_HLTf3DFwSkCI,793
13
- dts_dance-0.2.0.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
- dts_dance-0.2.0.dist-info/RECORD,,
11
+ dtsdance/tcc_open.py,sha256=Qb_ue3xH0CSsoReItdFKuvW7JsDTfFkDNIB_4zjzSQI,6893
12
+ dts_dance-0.2.1.dist-info/METADATA,sha256=QQohyobEcAlWjdpCDwPBXzYlSRBZxeGcV-xfN9_ladU,793
13
+ dts_dance-0.2.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
14
+ dts_dance-0.2.1.dist-info/RECORD,,
dtsdance/dflow.py CHANGED
@@ -4,6 +4,14 @@ from .bytecloud import ByteCloudClient
4
4
  import requests
5
5
 
6
6
 
7
+ class TaskNotFound(Exception):
8
+ pass
9
+
10
+
11
+ class DFlowNotFound(Exception):
12
+ pass
13
+
14
+
7
15
  class DFlowClient:
8
16
 
9
17
  def __init__(self, bytecloud_client: ByteCloudClient) -> None:
@@ -44,7 +52,7 @@ class DFlowClient:
44
52
  logger.warning(error_msg)
45
53
  raise
46
54
 
47
- def get_dflow_info(self, site: str, task_id: str) -> dict[str, Any]:
55
+ def get_task_info(self, site: str, task_id: str) -> dict[str, Any]:
48
56
  """
49
57
  获取 DFlow 任务信息
50
58
 
@@ -64,7 +72,11 @@ class DFlowClient:
64
72
 
65
73
  response_data = self._make_request("POST", url, self.bytecloud_client.build_request_headers(site), json_data)
66
74
 
67
- logger.info(f"get_dflow_info {site} {task_id}, message: {response_data.get('message')}")
75
+ message = response_data.get("message")
76
+ # logger.debug(f"get_task_info {site} {task_id}, message: {message}")
77
+
78
+ if message == "task not exists":
79
+ raise TaskNotFound(f"获取 DFlow 任务信息失败,站点: {site}, 任务 ID: {task_id} 不存在")
68
80
 
69
81
  try:
70
82
  data = cast(dict, response_data.get("data", {}))
@@ -82,6 +94,49 @@ class DFlowClient:
82
94
  except (KeyError, AttributeError, Exception) as e:
83
95
  raise Exception(f"无法从响应中提取 DFlow 任务信息数据: {str(e)}")
84
96
 
97
+ def get_dflow_info(self, site: str, dflow_id: str) -> dict[str, Any]:
98
+ """
99
+ 获取 DFlow 进程信息
100
+
101
+ Args:
102
+ site: 站点名称
103
+ dflow_id: DFlow 进程 ID
104
+
105
+ Returns:
106
+ dict[str, Any]: DFlow 进程信息,包含 create_time 等字段
107
+ """
108
+ # 构建 API URL
109
+ site_info = self.bytecloud_client.get_site_info(site)
110
+ url = f"{site_info.endpoint}/api/v1/bytedts/api/bytedts/v3/DescribeDFlowDetail"
111
+
112
+ # 构建请求数据
113
+ json_data = {"dflow_id": int(dflow_id)}
114
+
115
+ response_data = self._make_request("POST", url, self.bytecloud_client.build_request_headers(site), json_data)
116
+
117
+ message = response_data.get("message", "")
118
+ # logger.debug(f"get_dflow_info {site} {dflow_id}, message: {message}")
119
+
120
+ if "dflow not found" in message:
121
+ raise DFlowNotFound(f"获取 DFlow 进程信息失败,站点: {site}, 进程 ID: {dflow_id} 不存在")
122
+
123
+ try:
124
+ data = cast(dict, response_data.get("data", {}))
125
+ dflow = cast(dict, data.get("dflow", {}))
126
+ # 提取核心信息
127
+ filtered_data = {
128
+ "dflow_id": dflow.get("id", ""),
129
+ "task_id": dflow.get("task_id", ""),
130
+ "app": dflow.get("app", ""),
131
+ "schedule_plan_name": dflow.get("schedule_plan_name", ""),
132
+ "running_state.healthy_status": dflow.get("running_state", {}).get("healthy_status", ""),
133
+ }
134
+
135
+ return filtered_data
136
+
137
+ except (KeyError, AttributeError, Exception) as e:
138
+ raise Exception(f"无法从响应中提取 DFlow 进程信息数据: {str(e)}")
139
+
85
140
  def generate_task_url(self, site: str, task_id: str) -> str:
86
141
  """
87
142
  获取 DFlow 任务详情页面的 URL
dtsdance/spacex.py CHANGED
@@ -5,7 +5,7 @@ from loguru import logger
5
5
 
6
6
 
7
7
  class GatewayInfo(NamedTuple):
8
- mgr_name: str
8
+ mgr_env: str
9
9
  ctrl_name: str
10
10
  gateway_endpoint: str
11
11
  auth_user: str
@@ -40,11 +40,11 @@ class SpaceXClient:
40
40
  logger.warning(f"do quest queryServerMeta exception: {e}")
41
41
  raise
42
42
 
43
- def registry_gateway(self, site: str, gateway_info: GatewayInfo) -> bool:
43
+ def register_gateway(self, site: str, gateway_info: GatewayInfo) -> bool:
44
44
  site_info = self.bytecloud_client.get_site_info(site)
45
45
  url = f"{site_info.endpoint_bytedts_spacex}/bytedts/v1/registryGateway"
46
46
  data_raw = {
47
- "server_region": gateway_info.mgr_name,
47
+ "server_region": gateway_info.mgr_env,
48
48
  "cluster_region": gateway_info.ctrl_name,
49
49
  "cluster_name": gateway_info.ctrl_name,
50
50
  "server_domain": gateway_info.gateway_endpoint,
dtsdance/tcc_open.py CHANGED
@@ -16,8 +16,10 @@ class TCCConfigItem:
16
16
 
17
17
 
18
18
  class TCCError(Exception):
19
- """TCC API error."""
19
+ pass
20
+
20
21
 
22
+ class TCCItemNotFound(Exception):
21
23
  pass
22
24
 
23
25
 
@@ -229,7 +231,11 @@ class TCCClient:
229
231
  # Check for errors in response
230
232
  base_resp = result.get("base_resp", {})
231
233
  if base_resp.get("error_code", 0) != 0:
232
- raise TCCError(f"TCC API error: {base_resp.get('error_message', 'Unknown error')}")
234
+ error_message = base_resp.get("error_message", "Unknown error")
235
+ if "reason:RESOURCE_NOT_FOUND" in error_message:
236
+ raise TCCItemNotFound(f"TCC Item not found error: {error_message}")
237
+
238
+ raise TCCError(f"TCC API error: {error_message}")
233
239
 
234
240
  return result.get("data", {})
235
241