i have a python script that uses the output dir (o...
# help
s
i have a python script that uses the output dir (once all processes are done), at the absolute end of a pipeline that contains analysis of genomes - the script creates visualizations comparing all samples to eachother (read quality, plasmids..etc). I understand that publishdir is asynchronous, but now I am stuck, is there anyway to wait until output dir publishdir is done? • Maybe check for amount of subdirectories/files in the outputdir would be a good workaround in my python script? • Maybe workflow.Oncomplete and make it sleep for a user-set amount of time before running the python script? ā—¦ The files that are being published aren't big so maybe sleeping would be okay?
p
Do you mean that your script is referencing files that have been published? eg. including the publishDir file path?
This is an anti-pattern, you should never do this in a Nextflow pipeline as it can break in all kinds of fun and exciting ways
Instead, always pass files to the process via channels
s
i run my python script in a separate process that uses the output directory set by the user -outputdir (where publishdir publishes process outputs).
so, not a good idea to check for the amount of files within the outputdir in my python script? I feel like that may be an okay workaround?
a
As Phil says, operating on published files within a pipeline is an anti-pattern. To be published they must be the outputs of another process, so is there a reason not to put them into a channel which can be used as input to this process?
s
Ah well, just wanted to use my python script as-is within the pipeline. If i use them as a channel, then i'd have to change multiple lines. Though, I understand now, probably in my best interest to collect the files as channels then use those in my script
šŸ‘šŸ» 1
p
It'll be less work in the long run šŸ™‚
a
Depending on the way the Python script is written you may not even have to change it, you may just need to setup your nextflow process in a slightly different way (eg using
stageAs
to put all the input files into a directory that can be passed to the script)
ā˜ļø 1
s
ah, I see, i'll look into that. thank you for the advice