-
-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to write to file using script in container #222
Comments
It's probably something to do with how the command is executed - perhaps try running that via a script instead? |
You mean a bash script ? That's a good idea. I'll also try running the
python command from the python shell.
…On Thu, 15 Aug 2024, 02:14 Vanessasaurus, ***@***.***> wrote:
It's probably something to do with how the command is executed - perhaps
try running that via a script instead?
—
Reply to this email directly, view it on GitHub
<#222 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/APA6REP3UZHGFQHIYAIMPO3ZRPXGFAVCNFSM6AAAAABMQFWARGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJQGEYTEMJXHA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Hello all,
As stated before, I originally ran a python script.
The problem remains when running a test case on the command line with the
-c option.
I wrote a one liner bash script looking like `python3 -c "with open(..."`.
This script produces a file when running `singularity exec` on it and
doesn't, without raising an error, if ran using `Client.execute` from the
spython library.
I have no clue where this could be coming from. The commands are supposed
to be identical...
On Thu, 15 Aug 2024, 09:04 Quentin Chevalier, ***@***.***>
wrote:
… You mean a bash script ? That's a good idea. I'll also try running the
python command from the python shell.
On Thu, 15 Aug 2024, 02:14 Vanessasaurus, ***@***.***>
wrote:
> It's probably something to do with how the command is executed - perhaps
> try running that via a script instead?
>
> —
> Reply to this email directly, view it on GitHub
> <#222 (comment)>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/APA6REP3UZHGFQHIYAIMPO3ZRPXGFAVCNFSM6AAAAABMQFWARGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJQGEYTEMJXHA>
> .
> You are receiving this because you authored the thread.Message ID:
> ***@***.***>
>
|
As suggested, you need to write into a script. The library here uses subprocess, which expects a list of commands (using shlex split) and here is what is happening: # From the command line
python -c "print('hello')" hello From Python import subprocess
p = subprocess.Popen(['python', '-c', "'print(\"hello\")'"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.communicate()
# note that there is no output
(b'', b'') The function is here: singularity-cli/spython/utils/terminal.py Lines 158 to 167 in 2b22233
os.system('python -c \"print(\'hello\')\"')
hello But that is doing os.system and would not be good to put into the library. Thanks. |
Expected Behavior
I'm expecting
spython.main.Client.execute
to behave exactly likesingularity exec
from the command line when running a dummy python script to write to a file.Actual Behavior
I can create a file using the command line but not using
spython.main.Client.execute
from inside apython
script.Steps to Reproduce
Consider running
singularity exec --bind ./local_dir:instance_dir
any_image_with_python.sif python -c "with open('instance_dir/test.tx','w') as f: f.write('test')" and compare the result with the same command in a python script :I am confident these are supposed to be identical because I've run the above with the
quiet
optional argument set toFalse
. Yet one created a file, the other doesn't.Context
Failure Logs
I would love to have those. The
python
script just continues without a sound...Possible Fix
My guess is this is a permission issue which requires increasing permissions for the script ?
The text was updated successfully, but these errors were encountered: