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

Bug: using an alias in module names #139

Closed
Joon-Klaps opened this issue Oct 18, 2023 · 3 comments
Closed

Bug: using an alias in module names #139

Joon-Klaps opened this issue Oct 18, 2023 · 3 comments

Comments

@Joon-Klaps
Copy link

Nf-test (nf-test 0.8.1) doesn't support the aliassing of modules in the setup step correctly.

To create a test for bbmap/bbsplit I run the same module twice (as was done for the original pytest).

The problem here is that I need to create an alias for the module.

include {BBMAP_BBSPLIT as BBMAP_BBSPLIT_INDEX}  ...

It is correctly importing this but not correctly calling it see the mock.nf for the complete script

...
BBMAP_BBSPLIT as BBMAP_BBSPLIT_INDEX(*input)
...
Nextflow stdout:
  
  ERROR ~ No such variable: as
  
   -- Check script 'meta/mock.nf' at line: 47 or see '/workspace/modules/.nf-test/tests/883826a09088b68f2eb51c0096a941d8/meta/nextflow.log' file for more details
  Nextflow stderr:

Archive.zip

or see the PR nf-core/modules#4131

@apeltzer
Copy link

Yes would be really helpful to reduce the amount of code you have to duplicate. Example would be umicollapse in nf-core, where I just had to copy two identical setup() blocks for stub testing and PE testing into the respective tests as otherwise their import names were conflicting with the one from the SE test.

nf-core/modules#4799

@jasmezz
Copy link

jasmezz commented Jan 26, 2024

Agree that aliasing should be implemented asap ✋
E.g. for this module we need to untar 3 archives from its test data which is now impossible (and a module update is critical for the funcscan pipeline 🥺)

@lukfor
Copy link
Collaborator

lukfor commented Jan 26, 2024

Thanks @apeltzer for the feedback! What do you think about using an optional alias property in the run method? This would be more robust than parsing run("GENERATE_DATA as LUKAS"). Would this help in eliminating duplicate code?

nextflow_process {

    name "Test process data"

    script "./process_data.nf"
    process "PROCESS_DATA"

    test("Should use process GENERATE_DATA with alias LUKAS to generate input data") {

        setup {
            run("GENERATE_DATA", alias: "LUKAS") {
                script "./generate_data.nf"
                process {
                    """
                    input[0] = "nf-core"
                    """
                }
            }
        }

        when {
            process {
                """
                input[0] = "Hey "
                input[1] = LUKAS.out.results
                """
            }
        }

        then {
            assert process.success
            assert snapshot(process.out.results).match()
        }
    }

}

I am not sure if the same mechanism makes sense for the process/workflow name it self (see #96). Do you have a usecase in mind where it makes sense to give the test subject a different alias?

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

4 participants