From 7902a4eba8689cbf608dfd9fa3292bbb7ac1bbc0 Mon Sep 17 00:00:00 2001 From: Qianqian Fang Date: Sun, 17 Mar 2024 11:48:02 -0400 Subject: [PATCH] [mcxcloud] update docker image to v2024.2 --- mcxcloud/backend/mcxcloudd | 22 +++++++++++++++++++--- mcxcloud/backend/mcxserver.cgi | 22 +++++++++++++++------- mcxcloud/frontend/index.html | 10 +++++++++- 3 files changed, 43 insertions(+), 11 deletions(-) diff --git a/mcxcloud/backend/mcxcloudd b/mcxcloud/backend/mcxcloudd index a77d6f2e..336f5cfb 100755 --- a/mcxcloud/backend/mcxcloudd +++ b/mcxcloud/backend/mcxcloudd @@ -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){ @@ -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; @@ -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); diff --git a/mcxcloud/backend/mcxserver.cgi b/mcxcloud/backend/mcxserver.cgi index 1b4cd269..e23e7cb6 100755 --- a/mcxcloud/backend/mcxserver.cgi +++ b/mcxcloud/backend/mcxserver.cgi @@ -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 @@ -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 = ); diff --git a/mcxcloud/frontend/index.html b/mcxcloud/frontend/index.html index d4d2d08e..144cf650 100644 --- a/mcxcloud/frontend/index.html +++ b/mcxcloud/frontend/index.html @@ -2472,7 +2472,9 @@

Backend

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); + } } }); } @@ -2888,6 +2890,9 @@

Backend

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 ); } @@ -2912,6 +2917,9 @@

Backend

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 ); }