Skip to content

Commit

Permalink
[mcxcloud] update docker image to v2024.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Mar 17, 2024
1 parent 08bfe11 commit 7902a4e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
22 changes: 19 additions & 3 deletions mcxcloud/backend/mcxcloudd
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,17 @@ $savetime=time();
# delete all jobs running over 1 min, if --kill is attached

if(grep(/--kill/,@ARGV)){
my @joblist=`docker service ls | grep 'fangqq/mcx:v20'| cut -f 1 -d" " | xargs docker service ps | grep 'Running [0-9a-z ]* minute' | cut -f 1,4 -d" "`;
my @alljobs=`docker service ls | grep 'fangqq/mcx:v20'| cut -f 1 -d" "`;
chomp @alljobs;

if(@alljobs==0){
exit;
}
my $jobid=join(" ", @alljobs);

my @joblist=`docker service ps $jobid | grep 'Running [0-9a-z ]* minute' | cut -f 1,4 -d" "`;
chomp @joblist;

if(@joblist>0){
my @jobid;
foreach my $job (@joblist){
Expand Down Expand Up @@ -123,6 +132,13 @@ if(defined $sth->[0]){
my ($savetime,$jobid,$json,$jobhash)=@$rec;
tprint("updating job $jobid");

if(length($json) < 3) {
my $jsonsth=$dbh->selectall_arrayref("select json from $dbname where hash='$jobhash' and json<>'' limit 1;");
if(defined $jsonsth->[0]){
($json)=@{$jsonsth->[0]};
}
}

if(-d "workspace/_${jobhash}" && not -d "workspace/$jobid"){
tprint("cached job found $jobhash $jobid, skip");
$status=10;
Expand Down Expand Up @@ -154,9 +170,9 @@ if(defined $sth->[0]){
my $seedflag='';
$seedflag=' --seed -1 ' if $jobid =~/_\d+$/;
$dockercmd='docker service create --user "$(id -u):$(id -g)" --restart-condition=none --mount '
.'type=bind,src=/space/kwafoo/2/users/mcxone/workspace/'.$jobid.',dst=/data '
.'type=bind,src=/space/wazu/1/users/mcxone/workspace/'.$jobid.',dst=/data '
.'--update-monitor 1s '
.'--name '.$jobid.' --generic-resource "NVIDIA_GPU=1" "fangqq/mcx:v2020" '
.'--name '.$jobid.' --generic-resource "NVIDIA_GPU=1" "fangqq/mcx:v2024.2" '
."/bin/bash -c 'sleep 1; CUDA_VISIBLE_DEVICES=\$DOCKER_RESOURCE_NVIDIA_GPU mcx -f /data/input.json -s output -F jnii --log $seedflag &> /data/error.txt; touch /data/done' "
.'> workspace/'.$jobid.'/docker.txt';
system($dockercmd);
Expand Down
22 changes: 15 additions & 7 deletions mcxcloud/backend/mcxserver.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,22 @@ if(&V("hash") ne '' && &V("id") ne ''){ # loading simulation JSON when one clic
# if you are building a private mcx cloud, please disable the below if-block
# by adding "&& false" in the condition

if(&V('json') =~/"Photons"/){
if($dbh->selectrow_array("select count(*) from mcxpub where hash = '".$md5key."'")==0){
checklimit(decode_json(&V('json')));
}
# if(&V('json') =~/"Photons"/){
# if($dbh->selectrow_array("select count(*) from mcxpub where hash = '".$md5key."'")==0){
# checklimit(decode_json(&V('json')));
# }
# }

$sth=$dbh->selectall_arrayref("select json from $dbname where hash='$md5key' and json <> '' limit 1;");

if(defined $sth->[0]){
$sth=$dbh->prepare("insert into $dbname (time,name,inst,email,netname,json,jobid,hash,status,priority,ip) values (?,?,?,?,?,?,?,?,?,?,?)");
$sth->execute($savetime,&V("fullname"),&V("inst"),&V("email"),&V("netname"),'',$jobid,$md5key,0,50,$ENV{"REMOTE_ADDR"});
} else {
$sth=$dbh->prepare("insert into $dbname (time,name,inst,email,netname,json,jobid,hash,status,priority,ip) values (?,?,?,?,?,?,?,?,?,?,?)");
$sth->execute($savetime,&V("fullname"),&V("inst"),&V("email"),&V("netname"),&V("json"),$jobid,$md5key,0,50,$ENV{"REMOTE_ADDR"});
}

$sth=$dbh->prepare("insert into $dbname (time,name,inst,email,netname,json,jobid,hash,status,priority,ip) values (?,?,?,?,?,?,?,?,?,?,?)");
$sth->execute($savetime,&V("fullname"),&V("inst"),&V("email"),&V("netname"),&V("json"),$jobid,$md5key,0,50,$ENV{"REMOTE_ADDR"});
$html =$callback.'({"status":"success","jobid":"'.$jobid.'","hash":"'.$md5key.'","dberror":"'.$DBI::errstr.'"})'."\n";

# update library
Expand Down Expand Up @@ -202,7 +210,7 @@ if(&V("hash") ne '' && &V("id") ne ''){ # loading simulation JSON when one clic
my %response=('status'=>$jobstatus{$status}, 'jobid'=>$jobid);
$html =$callback.'('.JSON::PP->new->utf8->encode(\%response).")\n";
}
}elsif(-e "$workspace/$jobid/done" && not -z "$workspace/$jobid/error.txt"){ # MCX encountered an error
}elsif(-e "$workspace/$jobid/done" && not -s "$workspace/$jobid/error.txt"){ # MCX encountered an error
$status=6;
open FF, "<$workspace/$jobid/error.txt" || die("can not open error file");
chomp(my @lines = <FF>);
Expand Down
10 changes: 9 additions & 1 deletion mcxcloud/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2472,7 +2472,9 @@ <h3>Backend</h3>
jsonpCallback: 'addlog',
success: function( data ){},
error: function(xhr,status,error) {
$("#run-log").val($("#run-log").val()+"\n"+"jobstatus error: "+status);
if(xhr.getResponseHeader("Content-Length") != null) {
$("#run-log").val($("#run-log").val()+"\n"+"jobstatus error: "+status);
}
}
});
}
Expand Down Expand Up @@ -2888,6 +2890,9 @@ <h3>Backend</h3>
if(isWebGL2Available()){
let jd=new jdata(cfg.Shapes,{});
let vol=jd.decode().data;
if(cfg.Shapes.hasOwnProperty('_ArrayOrder_') && cfg.Shapes._ArrayOrder_.match(/^[cC]/)) {
vol.colmajor=1;
}
lastvolume=drawvolume(vol);
boundingbox.add( lastvolume );
}
Expand All @@ -2912,6 +2917,9 @@ <h3>Backend</h3>
if(isWebGL2Available()){
let jd=new jdata(cfg.NIFTIData,{});
let vol=jd.decode().data;
if(cfg.NIFTIData.hasOwnProperty('_ArrayOrder_') && cfg.NIFTIData._ArrayOrder_.match(/^[cC]/)) {
vol.colmajor=1;
}
lastvolume=drawvolume(nj.log(nj.clip(vol, 1e-16, 1/0)) );
boundingbox.add( lastvolume );
}
Expand Down

0 comments on commit 7902a4e

Please sign in to comment.