Skip to content

Need the ability to skip md5 check for some files in snapshot #211

@stevekm

Description

@stevekm

I am trying to avoid taking the md5sum for some files in my snapshot.

I found this example of one potential method that was shared online here, which I have modified as such;

nextflow_pipeline {
    name "Test main Pipeline"
    script "main.nf"

    test("Should run without failures") {

        when {
            params {
                // NOTE: make sure 'outdir' is defined inside the JSON!
                load("$baseDir/examples/params.small.json")
            }
        }

        then {
            assert workflow.success

            def exclude_suffix = [".html", "_complete", "_invocation",
            "_outs", "_vdrkill", "_args","_complete",
            "_jobinfo","_log","_outs","_stderr","_stdout",
            "_chunk_defs", "_stage_defs", "_disabled",
            "_cmdline", "_filelist", "_finalstate", "_jobmode", "_mrosource", "_perf", "_sitecheck",
            "_tags", "_timestamp", "_uuid", "_versions"]

            assert snapshot(
                workflow,
                path("${params.outdir}")
                        .list()
                        .collect { getRecursiveFileNames(it, "${params.outdir}") }
                        .flatten()
                        .findAll {
                            def keep = true
                            exclude_suffix.each { suffix ->
                                if (it.toString().endsWith(suffix)) {
                                    keep = false
                                    // println "${it} : ${keep}"
                                    return keep // Exit the loop early if a match is found
                                }
                            }
                            // println "${it} : ${keep}"
                            return keep
                        }
            ).match()


        }

    }
}

def getRecursiveFileNames(fileOrDir, outputDir) {
    if(file(fileOrDir.toString()).isDirectory()) {
        return fileOrDir.list().collect { getRecursiveFileNames(it, outputDir) }
    }
    return fileOrDir.toString().replace("${outputDir}/", "")
}

It works to exclude the files with the listed suffixes, but the snapshot now only contains a list of files, no md5's for the remaining files in the list. Also, I realized that what I really wanted was to just exclude only the md5 from the files with inconsistent hashes, instead of removing them entirely. Not sure how to implement that. Can we have a feature that just builds this in to the nf-test directly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions