Skip to content

Commit

Permalink
Uploader can now specify a workingdir
Browse files Browse the repository at this point in the history
  • Loading branch information
zagganas committed May 16, 2022
1 parent d979a9d commit 486bf95
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 27 deletions.
2 changes: 1 addition & 1 deletion models/Software.php
Original file line number Diff line number Diff line change
Expand Up @@ -822,7 +822,7 @@ public function runJob()
$executor=[];
$executor['image']=$this->image;
$executor['command']=$this->container_command;
$executor['workdir']=empty($this->omountpoint) ? $this->imountpoint : $this->omountpoint;
$executor['workdir']=empty($this->workingdir) ? $this->omountpoint : $this->workingdir;
$data['executors']=[$executor];
// var_dump($data);
// exit(0);
Expand Down
8 changes: 4 additions & 4 deletions models/SoftwareUpload.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function attributeLabels()
'visibility' => 'Visible to',
'imountpoint'=>'Input folder mount point (where users can provide input data inside the container). Leave empty if no mount is required',
'omountpoint'=>'Output folder mount point (folder inside the container where users can find the output). Leave empty if no mount is required',
'workingdir'=>'Working directory (inside the container). If left empty, /data will be used.',
'workingdir'=>'Working directory (inside the container). If left empty, the output mountpoint will be used.',
'description'=> 'Software description * ',
'imageInDockerHub'=>'Image exists in DockerHub and is specified in the CWL file',
'iomount' => 'Image requires disk I/O',
Expand Down Expand Up @@ -180,18 +180,18 @@ public function upload()
$imageFileName=$this->quotes($imageFileName);
$this->name=$this->quotes($this->name);
$this->version=$this->quotes($this->version);
$mpi=($this->mpi=='1') ? $this->quotes('t') : $this->quotes('f');
$this->workingdir=$this->quotes($this->workingdir);
$username=$this->quotes($username);

$arguments=[$this->name, $this->version, $imageFileName, $imageFileExt, $cwlFileName,
$username, $this->visibility, $this->imountpoint, $this->omountpoint,
$this->description, $this->biotools, $doiFile, $mpi, $this->covid19, $this->instructions,$this->gpu];
$this->description, $this->biotools, $doiFile, $this->workingdir, $this->covid19, $this->instructions,$this->gpu];


$command=Software::sudoWrap(Yii::$app->params['scriptsFolder'] . "imageUploader.py ");
$command.= implode(" ", $arguments) . " ";
$command.= "2>&1";

print_r($command);exit(0);
Software::exec_log($command,$out,$ret);

$errors='';
Expand Down
8 changes: 4 additions & 4 deletions models/SoftwareUploadExisting.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function attributeLabels()
'visibility' => 'Visible to',
'imountpoint'=>'Input folder mount point (where users can provide input data inside the container). Leave empty if no mount is required',
'omountpoint'=>'Output folder mount point (folder inside the container where users can find the output). Leave empty if no mount is required',
'workingdir'=>'Working directory (inside the container). If left empty, /data will be used.',
'workingdir'=>'Working directory (inside the container). If left empty, the output mountpoint a will be used.',
'description'=> 'Software description * ',
'imageInDockerHub'=>'Image exists in DockerHub and is specified in the CWL file',
'iomount' => 'Image requires disk I/O',
Expand All @@ -140,12 +140,13 @@ public function upload()
$workingdir=$previous->workingdir;
$original=$previous->original_image;
$dockerhub=($previous->docker_or_local) ? "'t'" : "'f'";
$workingdir=$this->quotes($workingdir);
$this->workingdir=$this->quotes($this->workingdir);
$original=$this->quotes($original);
$this->covid19=($this->covid19=='1') ? "'t'" : "'f'";
$this->biotools=$this->quotes($this->biotools);
$this->instructions=$this->quotes($this->instructions);
$this->gpu=$this->quotes($this->gpu);
$this->workingdir=$this->quotes($this->workingdir);

//add dois string in a file and pass it on to python
$dataFolder=Yii::$app->params['tmpImagePath'] . $username . '/' . str_replace(' ','-',$this->name) . '/' . str_replace(' ','-',$this->version) . '/';
Expand Down Expand Up @@ -178,13 +179,12 @@ public function upload()

$this->name=$this->quotes($this->name);
$this->version=$this->quotes($this->version);
$mpi=($this->mpi=='1') ? $this->quotes('t') : $this->quotes('f');
$username=$this->quotes($username);

$arguments=[
$this->name, $this->version, $this->image, $cwlFileName,
$username, $this->visibility, $this->imountpoint, $this->omountpoint,
$this->description, $this->biotools, $doiFile, $mpi, $workingdir,
$this->description, $this->biotools, $doiFile, $this->workingdir,
$original,$dockerhub,$this->covid19, $this->instructions,$this->gpu];

$command=Software::sudoWrap(Yii::$app->params['scriptsFolder'] . "existingImageUploader.py ");
Expand Down
22 changes: 13 additions & 9 deletions scheduler_files/existingImageUploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,12 @@
description=sys.argv[9]
biotools=sys.argv[10]
doiFile=sys.argv[11]
mpi=sys.argv[12]
workingDir=sys.argv[13]
original=sys.argv[14]
docker_or_local=sys.argv[15]
covid19=sys.argv[16]
instructions=sys.argv[17]
gpu=sys.argv[18]
workingDir=sys.argv[12]
original=sys.argv[13]
docker_or_local=sys.argv[14]
covid19=sys.argv[15]
instructions=sys.argv[16]
gpu=sys.argv[17]

def quoteEnclose(string):
return "'" + string + "'"
Expand Down Expand Up @@ -77,11 +76,16 @@ def quoteEnclose(string):
workingDir='/'

uf.imageStore(softName,softVersion, image,script,user,visibility,
workingDir,imountPoint,omountPoint,description,cwlPath,biotools,doiFile,mpi,original,docker_or_local,covid19,instructions,gpu)
workingDir,imountPoint,omountPoint,description,cwlPath,biotools,doiFile,original,docker_or_local,covid19,instructions,gpu)

if 'inputs' not in cwlContent:
cwlContent['inputs']=[];

exit_value=uf.inputStore(softName,softVersion, cwlContent['inputs'])
if isinstance(cwlContent['inputs'],dict):
exit_value=uf.inputStoreDict(softName,softVersion, cwlContent['inputs'])
elif isinstance(cwlContent['inputs'],list):
exit_value=uf.inputStoreList(softName,softVersion, cwlContent['inputs'])
else:
exit_value=100
exit(exit_value)

5 changes: 2 additions & 3 deletions scheduler_files/imageUploader.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
description=sys.argv[10]
biotools=sys.argv[11]
doiFile=sys.argv[12]
mpi=sys.argv[13]
workingDir=sys.argv[13]
covid19=sys.argv[14]
instructions=sys.argv[15]
gpu=sys.argv[16]
Expand Down Expand Up @@ -121,7 +121,6 @@ def quoteEnclose(string):
# imageName=softName.lower()
# imageVersion=softVersion.lower()

workingDir='/'


if (dockerHub=='t'):
Expand Down Expand Up @@ -161,7 +160,7 @@ def quoteEnclose(string):
conn.commit()

uf.imageStore(softName,softVersion, imageFull,script,user,visibility,
workingDir,imountPoint,omountPoint,description,cwlPath,biotools,doiFile,mpi,original,dockerHub,covid19,instructions,gpu)
workingDir,imountPoint,omountPoint,description,cwlPath,biotools,doiFile,original,dockerHub,covid19,instructions,gpu)

if 'inputs' not in cwlContent:
cwlContent['inputs']=[];
Expand Down
11 changes: 5 additions & 6 deletions scheduler_files/uploadFunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ def inputStoreList(softName,softVersion, inputs):
return 0

def imageStore(name,version,image,script,user,visibility,
workingDir,imountPoint,omountPoint, description,cwlPath,biotools,doiFile,mpi,original,docker_or_local,covid19,instructions,gpu):
workingDir,imountPoint,omountPoint, description,cwlPath,biotools,doiFile,original,docker_or_local,covid19,instructions,gpu):

softFull=name+ '-' + version
name=quoteEnclose(name)
Expand All @@ -437,7 +437,6 @@ def imageStore(name,version,image,script,user,visibility,
description=quoteEnclose(description)
cwlPath=quoteEnclose(cwlPath)
biotools=quoteEnclose(biotools)
mpi=quoteEnclose(mpi)
original=quoteEnclose(original)
docker_or_local=quoteEnclose(docker_or_local)
covid19=quoteEnclose(covid19)
Expand All @@ -459,19 +458,19 @@ def imageStore(name,version,image,script,user,visibility,
date="NOW()"

values=[name,version,image,script,user, date, visibility, workingDir, imountPoint,
omountPoint, description, cwlPath,biotools,dois,mpi,original,docker_or_local,covid19, instructions,gpu]
omountPoint, description, cwlPath,biotools,dois,original,docker_or_local,covid19, instructions,gpu]

sql1='INSERT INTO software_upload (name,version, image,script,uploaded_by, date, visibility, workingdir, imountpoint, omountpoint,\
description, cwl_path,biotools,dois,mpi,original_image,docker_or_local,covid19, instructions,gpu) '
description, cwl_path,biotools,dois,original_image,docker_or_local,covid19, instructions,gpu) '
sql1+='VALUES (' + ','.join(values) + ')'



values=[name,version,image,script,user, visibility, workingDir, imountPoint, omountPoint,description,cwlPath,biotools,
dois,mpi,original,docker_or_local,covid19, instructions,gpu]
dois,original,docker_or_local,covid19, instructions,gpu]
sql2='INSERT INTO software (name,version,image,script,uploaded_by,\
visibility, workingdir, imountpoint, omountpoint, description,\
cwl_path,biotools,dois,mpi,original_image,docker_or_local,covid19, instructions,gpu) '
cwl_path,biotools,dois,original_image,docker_or_local,covid19, instructions,gpu) '
sql2+='VALUES (' + ','.join(values) + ')'

# print()
Expand Down
1 change: 1 addition & 0 deletions views/software/software_edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
</div>

<?= ($superadmin)? $form->field($model, 'shared') -> checkbox(['id'=>'shared', "uncheck"=>'0',]):'' ?>
<?=$form->field($model, 'workingdir')?>
<?= $form->field($model, 'gpu') -> checkbox(['id'=>'gpu', "uncheck"=>'0']) ?>

<?=$form->field($model, 'biotools')->textInput() ?>
Expand Down
1 change: 1 addition & 0 deletions views/software/software_upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
<?= $form->field($model, 'imountpoint') ?>
<?= $form->field($model, 'omountpoint') ?>
</div>
<?=$form->field($model, 'workingdir')?>
<?= $form->field($model, 'gpu') -> checkbox(['id'=>'gpu', "uncheck"=>'0']) ?>

<?= $form->field($model, 'biotools') ?>
Expand Down
1 change: 1 addition & 0 deletions views/software/software_upload_existing.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<?= $form->field($model, 'imountpoint') ?>
<?= $form->field($model, 'omountpoint') ?>
</div>
<?=$form->field($model, 'workingdir')?>
<?= $form->field($model, 'gpu') -> checkbox(['id'=>'gpu', "uncheck"=>'0']) ?>
<?= $form->field($model, 'biotools') ?>
<div class="doi-container">
Expand Down

0 comments on commit 486bf95

Please sign in to comment.