LUMC / pytest-workflow

Configure workflow/pipeline tests using yaml files.
https://pytest-workflow.readthedocs.io/en/stable/
GNU Affero General Public License v3.0
63 stars 9 forks source link

option to disable copying of project directory #185

Closed ahvigil closed 10 months ago

ahvigil commented 1 year ago

The project directory gets copied into the tmp working directory of each test, but this clutters up the test workspace and doesn't always reflect how a workflow gets run. Add an option to disable this copy so each test can start from a clean slate.

Our use case is that we're testing nextflow workflows executed via nextflow run <github repo name>. When you do this nextflow handles the checkout from git for you, but puts that checkout in $HOME/.nextflow by default.

To make this useful, you'd probably still need to be able to specify select files (test inputs and such) to copy in so its probably not as simple as putting the copy inside an if. We'd also need a way to tell nextflow where the project code lives, so our test could do nextflow run $PROJECT_ROOT or something similar.

rhpvorderman commented 1 year ago

You immediately touch on the difficulty of this step. In git repos only relative paths make sense because the repo can be checked out anywhere. So that leaves us with two options:

Because test results in your git repository are ignoring the second option was chosen.

The option you propose adds a lot of complexity because the paths need to be resolved absolutely, rather than relatively. This is very hard to implement properly as it not only goes for the workflow but also all the input files used for testing. In our use case at the LUMC the test file paths are in json files which are used as input for the workflow engine. It would be very hard to write something since these files would have to be dynamically generated with the correct paths.

What I think you can do for your specific use case is make use of the power of bash:

- name: my workflow
  command: |- 
     bash -c '
       WORKFLOW_DIR=$(pwd)
       RUN_DIR=$(mktemp -d)
       cd $RUN_DIR
       nextflow run $WORKFLOW_DIR/workflow

Or something similar.