Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate job if fail too much #206

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions docker/k8s_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ def fetch_trainer_id():
return i
return None

def fetch_job_fail_count():
batch_client = client.BatchV1Api()
job_list = batch_client.list_namespaced_job(NAMESPACE)
for j in job_list.items:
if j.metadata.name == PADDLE_JOB_NAME:
failed_count = j.status.failed
break
if not failed_count:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

failed_count没有定义?

return 0
else:
return failed_count

if __name__ == "__main__":
command = sys.argv[1]
Expand All @@ -62,3 +73,5 @@ def fetch_trainer_id():
print fetch_trainer_id()
elif command == "wait_pods_running":
wait_pods_running(sys.argv[2], sys.argv[3])
elif command == "fetch_job_fail_count":
print fetch_job_fail_count()
4 changes: 4 additions & 0 deletions docker/paddle_k8s
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ check_trainer_ret() {
echo "Program Abort" > /dev/termination-log
fi
echo "termination log wroted..."
FAILED_COUNT=$(python /root/k8s_tools.py fetch_pserver_ips)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The arguments should be fetch_job_fail_count

if [ $FAILED_COUNT -ge $PADDLE_INIT_NUM_GRADIENT_SERVERS ]; then
exit 0
fi
exit $ret
}

Expand Down