Closed al3x609 closed 6 years ago
This looks like a bug because you aren't providing the "run" command with named arguments, so it's interpreting the third one (the date) as the app. What command are you trying to run? Can you walk me through your arguments to "run" ?
My recipe
BootStrap: docker
From: centos:latest
%labels
name "Proyect YAJE noVNC 1.0"
Description "Imagen base + noVNC 1.0 "
MAINTAINER "------"
vendor "UIS <Universidad Industiral de Santander>"
build-date "---"
license "GPLv3"
version "0.5"
%runscript
exec /mnt/setup.sh "${@}"
%environment
export PATH=/mnt/noVNC:/mnt/websockify:${PATH}
%files
setup.sh /mnt
UIS.pem /mnt
mod.tgz /mnt
%post
cd /mnt
yum -y update; yum clean all
yum install -y \
numpy \
wget \
git \
xkeyboard-config \
unzip \
which \
net-tools
chmod +xwr setup.sh
ln -sf /usr/share/zoneinfo/America/Bogota /etc/localtime
#configuracion novnc
git clone https://github.com/kanaka/noVNC.git
git clone https://github.com/kanaka/websockify
tar -xvf mod.tgz --strip-components=1 -C /mnt/noVNC
# sed -i 's/$host:/unix:/g' /opt/TurboVNC/bin/vncserver
# Clean Seccion
chmod -R +rwx /mnt
yum remove -y git
rm -r /usr/share/info/*
rm -r /usr/share/man/*
rm -r /usr/share/doc/*
yum clean all
rm -rf /var/cache/yum
my runscript setup.sh take 3 args
# Copyright (c) 2018, CESAR A. BERNAL - UIS 2018. All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# ...
port_vnc="$1"
urlVnv="$2"
endTime=`date -d"$3" +"%s"`
...
Thank you! Please try:
args = ['6080','localhost:5901','2018-09-01T00:20:00']
run=cl.run(args=args ,stream=True)
And let me know what you get!
singularity --version
2.6.0-dist
distro centos 7
Linux yaje 4.16.11-1.el7.elrepo.x86_64 #1 SMP Tue May 22 15:34:16 EDT 2018 x86_64 x86_64 x86_64 GNU/Linux ```
It works!! :D ... =| Why before no?
Woohoo!
Before you were providing all of the arguments to the runscript as different arguments to the run function. So for example, here is what the function looks like:
def run(self,
image = None,
args = None,
app = None,
sudo = False,
writable = False,
contain = False,
bind = None,
stream = False):
So you were essentially doing:
run(image = '6080',
args='localhost:5901',
app='2018-09-01T00:20:00',
stream=True)
and if you look at the error, that's why it was processing the command like this, with app as the timestamp, and then args as localhost and the "image" as 6080
['singularity', '--quiet', 'run', '--app', '2018-09-01T00:20:00', '6080', 'localhost:5901']'
which strangely enough, sort of looks ok? Haha. So what we actually wanted to do is provide the args as a list
run(image = None,
args = ["6080", "localhost:5901", "2018-09-01T00:20:00"],
stream=True)
and then you get the result that you see above, because the command is parsed as you would on the command line, like singularity --quiet run <container> <args>
. The image is defined for the function when you load it.
I see your code, the defined function run take keyword arguments, but with this lines become on positional args, maybe need be more explicit on help of run function. Maybe?
# Does the user want to run an app?
if app is not None:
cmd = cmd + ['--app', app]
cmd = cmd + [image]
I'm new to python so I can not contribute much, but before I used the docker API for python, maybe you can see this example, here is the run function in this API.
That's not technically the documentation for the user, did you see here? --> https://singularityhub.github.io/singularity-cli/commands-images
Would you like to do a PR to just the docstring in the function with your suggestion to make it better? Would be greatly appreciated!
And also notice the repo has 298 contributors, so there are a few more hands than this @vsoch dinosaur has :)
Closing, since original issue resolved. Thanks @al3x609 !
testing
from spython.main import Client as cl
cl.load('/data/YAJE/yaje/novnc/novnc.simg')
run=cl.run('6080','localhost:5901','2018-09-01T00:20:00' ,stream=True)
Then ->
for line in run:
print(line)
the output subprocess.CalledProcessError: Command '['singularity', '--quiet', 'run', '--app', '2018-09-01T00:20:00', '6080', 'localhost:5901']' returned non-zero exit status 255.
I don't have any %app.. defined on my Singularity recipe, only a script on %runscript that take 3 args, How I can call Run method without call --app arg?