Skip to content

Commit

Permalink
Merge pull request #5432 from BOINC/dpa_server_demo
Browse files Browse the repository at this point in the history
Updates and bug fixes for project creation
  • Loading branch information
AenBleidd authored Nov 22, 2023
2 parents 453f56b + 73d23fd commit b978d5c
Show file tree
Hide file tree
Showing 14 changed files with 90 additions and 68 deletions.
10 changes: 5 additions & 5 deletions apps/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
include $(top_srcdir)/Makefile.incl

exampledir = $(libexecdir)/boinc-apps-examples
example_PROGRAMS = upper_case concat 1sec
example_PROGRAMS = uppercase concat 1sec

upper_case_SOURCES = upper_case.cpp
upper_case_CXXFLAGS = $(PTHREAD_CFLAGS)
upper_case_LDFLAGS = -static-libtool-libs $(PTHREAD_CFLAGS)
upper_case_LDADD = $(APPLIBS)
uppercase_SOURCES = uppercase.cpp
uppercase_CXXFLAGS = $(PTHREAD_CFLAGS)
uppercase_LDFLAGS = -static-libtool-libs $(PTHREAD_CFLAGS)
uppercase_LDADD = $(APPLIBS)

concat_SOURCES = concat.cpp
concat_CXXFLAGS = $(PTHREAD_CFLAGS)
Expand Down
File renamed without changes.
9 changes: 9 additions & 0 deletions apps/uppercase_in
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<input_template>
<file_info>
</file_info>
<workunit>
<file_ref>
<open_name>in</open_name>
</file_ref>
</workunit>
</input_template>
15 changes: 15 additions & 0 deletions apps/uppercase_out
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<output_template>
<file_info>
<name><OUTFILE_0/></name>
<generated_locally/>
<upload_when_present/>
<max_nbytes>5000000</max_nbytes>
<url><UPLOAD_URL/></url>
</file_info>
<result>
<file_ref>
<file_name><OUTFILE_0/></file_name>
<open_name>out</open_name>
</file_ref>
</result>
</output_template>
6 changes: 6 additions & 0 deletions apps/version.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<version>
<file>
<physical_name>uppercase</physical_name>
<main_program/>
</file>
</version>
5 changes: 2 additions & 3 deletions html/inc/db_ops.inc
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,6 @@ function admin_show_app_version($app_version) {
row("min_core_version", $app_version->min_core_version);
row("max_core_version", $app_version->max_core_version);
row("deprecated", $app_version->deprecated);
row("plan_class", $app_version->plan_class);
end_table();
}

Expand Down Expand Up @@ -976,7 +975,7 @@ function admin_show_workunit($wu) {
row("Canonical credit", $wu->canonical_credit);
//row("Timeout check time", time_str($wu->timeout_check_time));
row("Delay bound", "$wu->delay_bound" . " = " . time_diff($wu->delay_bound) );
row("Error mask", wu_error_mask_str($wu->error_mask));
row("Error mask", wu_error_mask_str($wu->error_mask, true));
row("File delete state", file_delete_state_str($wu->file_delete_state)." [".$wu->file_delete_state."]");
row("Assimilation state", assimilate_state_str($wu->assimilate_state)." [".$wu->assimilate_state."]");
// row("","<a href=db_action.php?table=result&workunitid=$wu->id&detail=low>Show associated results</a>");
Expand Down Expand Up @@ -1028,7 +1027,7 @@ function admin_show_workunit_short($wu) {
$wu->id,
$wu->id
);
$e = wu_error_mask_str($wu->error_mask);
$e = wu_error_mask_str($wu->error_mask, true);
$f = file_delete_state_str($wu->file_delete_state);
$a = assimilate_state_str($wu->assimilate_state);
echo "
Expand Down
12 changes: 7 additions & 5 deletions html/inc/result.inc
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,11 @@ function file_delete_state_str($s) {
}
return "Unknown";
}
function wu_error_mask_str($s) {

// convert WU error bitmask to str.
// If $color, add HTML red color
//
function wu_error_mask_str($s, $color=false) {
$x = "";
if ($s & WU_ERROR_COULDNT_SEND_RESULT) {
$x = $x." ".tra("Couldn't send result");
Expand Down Expand Up @@ -339,10 +343,8 @@ function wu_error_mask_str($s) {
if ($s) {
$x = $x." ".tra("Unrecognized Error: %1", $s);
}
if (strlen($x)) {
$x="<font color=\"#ff3333\">".$x."</font>";
} else {
$x="";
if ($color) {
return sprintf('<font color="#ff3333">%s</font>', $x);
}
return $x;
}
Expand Down
2 changes: 1 addition & 1 deletion html/inc/util_ops.inc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function print_text_field($text,$name,$value) {
}

function row($x, $y) {
echo "<tr><td valign=\"top\" align=\"right\">$x</td>\n<td>$y</td>\n</tr>\n";
echo "<tr><td width=30% valign=\"top\" align=\"right\">$x &nbsp;&nbsp; </td>\n<td>$y</td>\n</tr>\n";
}

function c_row2($color, $x, $y) {
Expand Down
1 change: 0 additions & 1 deletion lib/boinc_stdio.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ namespace boinc {
inline int fscanf(FILE *fp, const char *format, ...) {
char buf[BUFSIZ];
boinc::fgets(buf,BUFSIZ,fp);
buf[strlen(buf)-1]=0;
va_list va;
va_start(va, format);
int i=::vsscanf(buf,format,va);
Expand Down
4 changes: 2 additions & 2 deletions py/Boinc/boincxml.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ def read(self, failopen_ok=False):
self.xml = xml.dom.minidom.parse(self.filename)
strip_white_space(self.xml)
except:
print("Warning: couldn't parse XML file:", self.filename, file=sys.stderr)
if not failopen_ok:
raise Exception("Couldn't parse XML config\n")
print("Warning: couldn't parse XML file", file=sys.stderr)
raise Exception("Couldn't parse XML file\n")
self._init_empty_xml()
try:
self._get_elements()
Expand Down
4 changes: 2 additions & 2 deletions tools/backend_lib.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@

// default job parameters
//
#define DEFAULT_MIN_QUORUM 2
#define DEFAULT_TARGET_NRESULTS 2
#define DEFAULT_MIN_QUORUM 1
#define DEFAULT_TARGET_NRESULTS 1
#define DEFAULT_MAX_ERROR_RESULTS 3
#define DEFAULT_MAX_TOTAL_RESULTS 10
#define DEFAULT_MAX_SUCCESS_RESULTS 6
Expand Down
43 changes: 25 additions & 18 deletions tools/demo_query
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@
<?php
// query a job created with demo_submit
//
// usage: demo_query jobname
// usage: bin/demo_query jobname

if ($argc != 2) {
die("usage: demo_query jobname\n");
}

$wu_name = $argv[1];
chdir("html/ops");
require_once("../inc/boinc_db.inc");
$wu = BoincWorkunit::lookup("name='$wu_name'");
require_once("../inc/common_defs.inc");
require_once("../inc/result.inc");
chdir("../..");

if (!$wu) {
die("no such job: $wu_name\n");
}

echo "Waiting for job to finish\n";
function main($wu_name) {
$wu = BoincWorkunit::lookup("name='$wu_name'");
if (!$wu) {
die("no such job: $wu_name\n");
}

while (1) {
if ($wu->error_mask) {
echo "job error: $wu->error_mask\n";
break;
echo sprintf("Job error: %s\n",
wu_error_mask_str($wu->error_mask)
);
return;
}
if ($wu->assimilate_state == 2) {
switch ($wu->assimilate_state) {
case ASSIMILATE_INIT:
echo "Job is in progress.\n";
break;
case ASSIMILATE_READY:
echo "Job waiting for assimilation.\n";
break;
case ASSIMILATE_DONE:
$result = BoincResult::lookup_id($wu->canonical_resultid);
$host = BoincHost::lookup_id($result->hostid);
$user = BoincUser::lookup_id($result->userid);
Expand All @@ -38,12 +43,14 @@ while (1) {
if (!is_file($outfile)) {
die("output file is missing: $outfile\n");
}
echo "output file:\n";
echo "Output file (sample_result/$wu_name):\n";
readfile($outfile);
break;
}
sleep(5);
$wu = BoincWorkunit::lookup("name='$wu_name'");
}

if ($argc != 2) {
die("usage: demo_query jobname\n");
}
main($argv[1]);
?>
19 changes: 5 additions & 14 deletions tools/demo_submit
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@
//
// usage: demo_submit appname infile
//
// Submit a job, show its name, wait for it to complete
// (or you can use demo_query to query status later)
// Submit a job and show its name.
// Use demo_query to query its status and get output file.
//
// This is for demo use, not production. It assumes:
// - template files are appname_in.xml and appname_out.xml
// - template files are appname_in and appname_out
// - the app uses sample_trivial_validator
// - the app uses sample_assimilator
// (which puts output files in sample_results/)
// - app has 1 input file and 1 output file
Expand All @@ -34,21 +35,11 @@ if (!is_file($fname)) {
die("no such file: $fname\n");
}

$in_template = "templates/".$appname."_in.xml";
if (!is_file($in_template)) {
die("no input template: $in_template\n");
}
$out_template = "templates/".$appname."_out.xml";
if (!is_file($out_template)) {
die("no output template: $out_template\n");
}

system("cp $fname `bin/dir_hier_path $fname`");

$wu_name = $appname."_".$fname."_".(string)time();
system("bin/create_work --appname $appname --wu_name $wu_name --wu_template $in_template --result_template $out_template $fname");
system("bin/create_work --appname $appname --wu_name $wu_name $fname");

echo "Job name: $wu_name\n";

system("bin/demo_query $wu_name");
?>
28 changes: 11 additions & 17 deletions tools/make_project
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,11 @@ if options.test_app:
pf.write()


httpd_conf_template_filename = os.path.join(
httpd_conf_template_filename = project_shortname+'.httpd.conf'
httpd_conf_template_path = os.path.join(
options.project_root,
project_shortname+'.httpd.conf'
)
httpd_conf_template_filename
)

content ='''
## Settings for BOINC project %(project_longname)s
Expand Down Expand Up @@ -404,7 +405,7 @@ content ='''
</Directory>
''' % locals()
f = open(httpd_conf_template_filename,'w')
f = open(httpd_conf_template_path,'w')
f.write(content)
f.close()

Expand Down Expand Up @@ -468,19 +469,12 @@ html_ops_url = options.html_ops_url

content = '''Steps to complete installation:
- Change Apache configuration (as root):
If you are using Apache 2.4, edit the %(httpd_conf_template_filename)s
(see file for specific instructions).
cat %(httpd_conf_template_filename)s >> /etc/apache/httpd.conf
(path to httpd.conf varies; try /etc/httpd/ or /etc/apache2)
Then restart the web server:
/usr/sbin/apache2ctl restart
(or /usr/sbin/apachectl restart)
- Update Apache configuration (as root):
(make sure you have apache2 2.4 or later)
install config file:
cp %(httpd_conf_template_filename)s /etc/apache2/sites-enabled
restart apache:
apache2ctl restart
- Add to crontab (as %(USER)s)
Expand Down

0 comments on commit b978d5c

Please sign in to comment.