Skip to content

Commit

Permalink
Merge pull request #76 from felix5572/master
Browse files Browse the repository at this point in the history
fix script generation
  • Loading branch information
felix5572 committed Jun 30, 2021
2 parents 4654086 + f9340fd commit 6985514
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions dpdispatcher/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"""

script_env_template="""
echo 0 > {flag_job_task_fail}
REMOTE_ROOT={remote_root}
echo 0 > $REMOTE_ROOT/{flag_if_job_task_fail}
test $? -ne 0 && exit 1
{module_unload_part}
Expand All @@ -31,7 +31,7 @@
test $? -ne 0 && exit 1
if [ ! -f {task_tag_finished} ] ;then
{command_env} ( {command} ) {log_err_part}
if test $? -eq 0; then touch {task_tag_finished}; else echo 1 > {flag_job_task_fail};fi
if test $? -eq 0; then touch {task_tag_finished}; else echo 1 > $REMOTE_ROOT/{flag_if_job_task_fail};fi
fi &
"""

Expand All @@ -40,8 +40,8 @@
test $? -ne 0 && exit 1
wait
FLAG_JOB_TASK_FAIL=$(cat {flag_job_task_fail})
if test $FLAG_JOB_TASK_FAIL -eq 0; then touch {job_tag_finished}; else exit 1;fi
FLAG_IF_JOB_TASK_FAIL=$(cat {flag_if_job_task_fail})
if test $FLAG_IF_JOB_TASK_FAIL -eq 0; then touch {job_tag_finished}; else exit 1;fi
"""

class Machine(object):
Expand Down Expand Up @@ -197,10 +197,10 @@ def gen_script_env(self, job):
for k,v in envs.items():
export_envs_part += f"export {k}={v}\n"

flag_job_task_fail = job.job_hash + '_flag_job_task_fail'
flag_if_job_task_fail = job.job_hash + '_flag_if_job_task_fail'

script_env = script_env_template.format(
flag_job_task_fail=flag_job_task_fail,
flag_if_job_task_fail=flag_if_job_task_fail,
remote_root=self.context.remote_root,
module_unload_part=module_unload_part,
module_load_part=module_load_part,
Expand All @@ -225,9 +225,9 @@ def gen_script_command(self, job):
if task.errlog is not None:
log_err_part += f"2>>{task.errlog} "

flag_job_task_fail = job.job_hash + '_flag_job_task_fail'
flag_if_job_task_fail = job.job_hash + '_flag_if_job_task_fail'
single_script_command = script_command_template.format(
flag_job_task_fail=flag_job_task_fail,
flag_if_job_task_fail=flag_if_job_task_fail,
command_env=command_env,
task_work_path=task.task_work_path,
command=task.command,
Expand All @@ -240,10 +240,10 @@ def gen_script_command(self, job):

def gen_script_end(self, job):
job_tag_finished = job.job_hash + '_job_tag_finished'
flag_job_task_fail = job.job_hash + '_flag_job_task_fail'
flag_if_job_task_fail = job.job_hash + '_flag_if_job_task_fail'
script_end = script_end_template.format(
job_tag_finished=job_tag_finished,
flag_job_task_fail=flag_job_task_fail
flag_if_job_task_fail=flag_if_job_task_fail
)
return script_end

Expand Down

0 comments on commit 6985514

Please sign in to comment.