Skip to content

Commit 7d0d9ea

Browse files
authored
Merge pull request #12 from z275748353/main
fix bug
2 parents 329b848 + 5c22eff commit 7d0d9ea

14 files changed

Lines changed: 905 additions & 816 deletions

File tree

data_celery/job/tasks.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,14 @@ def run_pipline_job_task(config,job,session,user_id, user_name, user_token):
151151
with tempfile.NamedTemporaryFile(mode='w', delete=False) as tmpfile:
152152
tmpfile.write(yaml_content)
153153
temp_dir_str = tmpfile.name
154-
cfg = init_configs(['--config', temp_dir_str, '--user_id', user_id,
155-
'--user_name', user_name, '--user_token', user_token],redirect=False)
154+
155+
try:
156+
cfg = init_configs(['--config', temp_dir_str, '--user_id', user_id,
157+
'--user_name', user_name, '--user_token', user_token], redirect=False)
158+
except:
159+
insert_pipline_job_run_task_log_error(job.uuid, f"{job.uuid} :Config initialization failed")
160+
raise
161+
156162
# return
157163
temp_filename = os.path.basename(temp_dir_str)
158164

@@ -164,8 +170,10 @@ def run_pipline_job_task(config,job,session,user_id, user_name, user_token):
164170
os.remove(temp_work_file)
165171
except FileNotFoundError:
166172
insert_pipline_job_run_task_log_error(job.uuid, f"{job.uuid} :not exists yaml config - {temp_work_file}")
173+
raise
167174
except PermissionError:
168175
insert_pipline_job_run_task_log_error(job.uuid, f"{job.uuid} :Permission denied. You cannot remove - {temp_work_file}")
176+
raise
169177

170178
with open(config_file, mode='w') as file:
171179
file.write(config.yaml())

data_engine/config/config.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -631,12 +631,15 @@ def update_op_process(cfg, parser):
631631
action.dest for action in parser._actions
632632
if hasattr(action, 'dest') and isinstance(action, ActionTypeHint)
633633
])
634-
635-
temp_args = namespace_to_arg_list(temp_cfg,
636-
includes=recognized_args,
637-
excludes=['config'])
638-
temp_args = ['--config', temp_cfg.config[0].absolute] + temp_args
639-
temp_parser.parse_args(temp_args)
634+
try:
635+
temp_args = namespace_to_arg_list(temp_cfg,
636+
includes=recognized_args,
637+
excludes=['config'])
638+
temp_args = ['--config', temp_cfg.config[0].absolute] + temp_args
639+
temp_parser.parse_args(temp_args)
640+
except:
641+
logger.error('Config initialization failed')
642+
raise "Config initialization failed"
640643
return cfg
641644

642645

data_engine/core/data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ def process(self,
204204
except: # noqa: E722
205205
logger.error(f'An error occurred during Op [{op._name}].')
206206
traceback.print_exc()
207-
exit(1)
207+
# exit(1)
208208
finally:
209209
if checkpointer and dataset is not self:
210210
logger.info('Writing checkpoint of dataset processed by '

data_engine/core/executor_tools.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, *, tool_def: Tool_def, params: ExecutedParams):
4040
redirect=self.tool_def.executor_type == 'default')
4141

4242
def run(self):
43+
4344
"""
4445
Running the dataset process pipeline.
4546
@@ -48,7 +49,9 @@ def run(self):
4849
"""
4950
# 1. setup tool
5051
logger.info('Preparing tool...')
52+
5153
tool_obj: TOOL = load_tool(self.tool_def, self.executed_params)
54+
5255
with TRACE_HELPER_TOOL.trace_block(
5356
"start"
5457
):

data_server/algo_templates/utils/parse_algo_dslText.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,37 @@ def convert_raw_to_processed(raw_yaml: str) -> str:
7676
except Exception as e:
7777
print(f"查询operator_config_select_options失败: {e}")
7878
pass
79+
# handle_string_array_format_like_"['1','2']"_or_"[''1'', ''2'']"
80+
elif param_value and isinstance(param_value, str) and param_value.startswith('[') and param_value.endswith(']'):
81+
try:
82+
import ast
83+
# try_to_parse_the_string_array
84+
# First, handle the double single quote escape format [" 1 ", "2"] -> [" 1 ", "2"]
85+
normalized_value = param_value.replace("''", "'")
86+
parsed_list = ast.literal_eval(normalized_value)
87+
if isinstance(parsed_list, list):
88+
from data_server.operator.mapper.operator_mapper import get_operator_config_select_option_by_id
89+
from data_server.database.session import get_sync_session
90+
converted_list = []
91+
for item in parsed_list:
92+
if isinstance(item, str) and item.isdigit():
93+
try:
94+
db = get_sync_session()
95+
option_record = get_operator_config_select_option_by_id(db, int(item))
96+
if option_record and hasattr(option_record, 'name'):
97+
converted_list.append(option_record.name)
98+
else:
99+
converted_list.append(item)
100+
db.close()
101+
except Exception as e:
102+
print(f"查询operator_config_select_options失败: {e}")
103+
converted_list.append(item)
104+
else:
105+
converted_list.append(item)
106+
param_value = converted_list
107+
except (ValueError, SyntaxError) as e:
108+
print(f"解析字符串数组失败: {e}")
109+
pass
79110
# handle_the_numeric_id_of_list_type
80111
elif param_value and isinstance(param_value, list):
81112
from data_server.operator.mapper.operator_mapper import get_operator_config_select_option_by_id
@@ -135,8 +166,13 @@ def convert_string_list_to_yaml(match):
135166
return f"{param_name}: {list_content}"
136167

137168
# regular_expressions_match_lists_in_string_format
138-
pattern = r"(\s+\w+):\s*'(\[.*?\])'"
139-
yaml_str = re.sub(pattern, convert_string_list_to_yaml, yaml_str)
169+
# 匹配单引号包裹的字符串数组:'[...]'
170+
pattern1 = r"(\s+\w+):\s*'(\[.*?\])'"
171+
yaml_str = re.sub(pattern1, convert_string_list_to_yaml, yaml_str)
172+
173+
# 匹配双引号包裹的字符串数组:"[...]"
174+
pattern2 = r'(\s+\w+):\s*"(\[.*?\])"'
175+
yaml_str = re.sub(pattern2, convert_string_list_to_yaml, yaml_str)
140176

141177
yaml_str = yaml_str.replace(": {}", ":")
142178

@@ -207,7 +243,7 @@ def convert_string_list_to_yaml(match):
207243
default_value: '18'
208244
is_required: false
209245
is_spinner: false
210-
final_value: '18'
246+
final_value: '[''41'', ''42'', ''43'', ''44'', ''45'']'
211247
display_name: 模型名称
212248
edges: []
213249

data_server/api/endpoints/operator_permission.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ def read_permissions_by_operator_api(operator_id: int, db: Session = Depends(get
141141
def read_permissions_by_user_api(uuid: str, db: Session = Depends(get_sync_session)):
142142

143143
try:
144+
144145
permissions = get_permissions_by_user(db, uuid)
146+
145147
return response_success(data=permissions, msg="获取用户权限成功")
146148
except Exception as e:
147149
return response_fail(msg=f"获取用户权限失败: {str(e)}")

0 commit comments

Comments
 (0)