Skip to content

Commit 75eb503

Browse files
authored
feat: 修复docker下运行失败问题 (#466)
1 parent 9dd8d69 commit 75eb503

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

runtime/python-executor/datamate/common/utils/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@ def decrypt(enc_pass):
5757
dec_pass = K.API().decrypt(0)
5858
os.environ['KMC_PYTHON_ENCRYPT_DATA'] = ""
5959
return dec_pass
60+
61+
62+
def is_k8s():
63+
return "KUBERNETES_SERVICE_HOST" in os.environ

runtime/python-executor/datamate/wrappers/data_juicer_wrapper.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@ async def submit(task_id, config_path):
99

1010
await cmd_scheduler.submit(task_id, f"python {os.path.join(current_dir, 'data_juicer_executor.py')} "
1111
f"--config_path={config_path}")
12+
13+
def cancel(task_id):
14+
return cmd_scheduler.cancel_task(task_id)

runtime/python-executor/datamate/wrappers/datamate_wrapper.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
11
# -*- coding: utf-8 -*-
22
import os
33

4+
from datamate.common.utils import is_k8s
5+
from datamate.scheduler import cmd_scheduler
46
from datamate.scheduler import ray_job_scheduler
57

68

79
async def submit(task_id, config_path, retry_count: int = 0):
810
current_dir = os.path.dirname(__file__)
11+
12+
if not is_k8s():
13+
await cmd_scheduler.submit(task_id, f"python {os.path.join(current_dir, 'datamate_executor.py')} "
14+
f"--config_path={config_path}")
15+
return
16+
917
script_path = os.path.join(current_dir, "datamate_executor.py")
1018

1119
# 根据 retry_count 设置日志路径
@@ -20,4 +28,6 @@ async def submit(task_id, config_path, retry_count: int = 0):
2028

2129

2230
def cancel(task_id):
31+
if not is_k8s():
32+
return cmd_scheduler.cancel_task(task_id)
2333
return ray_job_scheduler.cancel_task(task_id)

0 commit comments

Comments
 (0)