Skip to content
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

Error when using XARGS #32

Closed
kabilov opened this issue May 24, 2023 · 6 comments
Closed

Error when using XARGS #32

kabilov opened this issue May 24, 2023 · 6 comments

Comments

@kabilov
Copy link

kabilov commented May 24, 2023

I try to use spring througth xargs.

function my_func() {
# arg1 = R1
# arg2 = options

R1=$(basename $1)
R2=${R1/_R1/_R2}
name=${R1%_R1*}
options=$2

spring -c -g $options -o $name.spring -i $R1 $R2; echo

}

export -f my_funct

options="--num-threads 8"
echo ${files[*]} |xargs -d" " -I{} -n1 -P$num bash -c 'my_func "$@"' _ {} "$options"

And for some fastq.gz files the following error is thrown:
terminate called after throwing an instance of 'std::runtime_error'
what(): Cannot create temporary directory.
environment: line 1: 25179 Aborted (core dumped) spring -c -g $options -o $name.spring -i $R1 $R2

It appears that this issue only occurs when running the script on a remote drive.
The same fastq files on the local drive don't throw the error.

@shubhamchandak94
Copy link
Owner

Hi @kabilov, can you try using the -w flag that allows you to set the working directory where Spring creates the temporary directory it works in? Any directory where you have read/write access is good (perhaps don't use /tmp/ since it's on RAM and might use too much of it).

@kabilov
Copy link
Author

kabilov commented May 26, 2023

Hi @shubhamchandak94
Thank you for reply.

I tried using the -w flag to set the working folder to the local drive, but that didn't help.
I also want to add that sometimes this error does not appear.

Is there a possibility that the name of tmp folder is the same for different files?

@shubhamchandak94
Copy link
Owner

I think this is due to a race condition situation in the Spring code where it generates a random string and checks if it exists, and if not it tries to create a directory. If multiple instances are running it's possible that a directory of the same name is created between the check and the creation of the directory. I will look into this and try to fix over the next few days (will need a few more days after that to get the update into conda).

Quick question: how many files are you working with?

@kabilov
Copy link
Author

kabilov commented May 27, 2023

In the test, 3 pairs of fastq files were compressed.

I usually use tmp name with nanoseconds time: tmp_$(date +%H:%M:%S:%N)

@shubhamchandak94
Copy link
Owner

I just pushed a fix attempt, can you try it out and see if it fixes the issue? If so, I will also update on bioconda. Thanks!

@kabilov
Copy link
Author

kabilov commented May 28, 2023

I checked the corrected Spring, the error disappeared.
Thank you for your help.

@kabilov kabilov closed this as completed May 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants