Skip to content

Commit

Permalink
Merge pull request #2968 from BOINC/dpa_job_counts
Browse files Browse the repository at this point in the history
remote job submission: add API for getting job counts
  • Loading branch information
lfield authored Apr 11, 2019
2 parents e57f835 + 371e2ce commit 4886070
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 7 deletions.
28 changes: 22 additions & 6 deletions html/user/server_status.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,14 +457,30 @@ function get_job_status() {
return $s;
}

function show_counts_xml() {
xml_header();
echo "<job_counts>\n";
item_xml('results_ready_to_send', BoincResult::count("server_state=2"));
item_xml('results_in_progress', BoincResult::count("server_state=4"));
item_xml('results_need_file_delete', BoincResult::count("file_delete_state=1"));
item_xml('wus_need_validate', BoincWorkunit::count("need_validate=1"));
item_xml('wus_need_assimilate', BoincWorkunit::count("assimilate_state=1"));
item_xml('wus_need_file_delete', BoincWorkunit::count("file_delete_state=1"));
echo "</job_counts>\n";
}

function main() {
$x = new StdClass;
$x->daemons = get_daemon_status();
$x->jobs = get_job_status();
if (get_int('xml', true)) {
show_status_xml($x);
if (get_int('counts', true)) {
show_counts_xml();
} else {
show_status_html($x);
$x = new StdClass;
$x->daemons = get_daemon_status();
$x->jobs = get_job_status();
if (get_int('xml', true)) {
show_status_xml($x);
} else {
show_status_html($x);
}
}
}

Expand Down
12 changes: 12 additions & 0 deletions lib/submit_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,3 +283,15 @@ def upload_files(upload_files_req):
reply = requests.post(url, data=req, files=files)
#print "reply text: ", reply.text
return ET.fromstring(reply.text)

# returns an XML object with various job counts
# results_ready_to_send
# results_in_progress
# results_need_file_delete
# wus_need_validate
# wus_need_assimilate
# wus_need_file_delete
# see tools/submit_api_test.py
#
def get_job_counts(req):
return do_http_post('', req.project, 'server_status.php?counts=1');
8 changes: 7 additions & 1 deletion tools/submit_api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,12 @@ def test_get_output_files():
r = get_output_files(req)
print(r)

def test_get_job_counts():
req = REQUEST()
req.project = 'http://isaac.ssl.berkeley.edu/test/'
x = get_job_counts(req)
print x.find('results_ready_to_send').text

#test_query_batch(328)
test_submit_batch('batch_43')
#test_submit_batch('batch_39')
#test_create_batch('batch_33')

0 comments on commit 4886070

Please sign in to comment.