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

Function to get MD5sums of all files in directory that is an emitted element from a channel #30

Open
jfy133 opened this issue Jan 16, 2025 · 6 comments

Comments

@jfy133
Copy link
Member

jfy133 commented Jan 16, 2025

Example:

        then {
            def stablefiles = []
            file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (!["database-build.log", "database.report.tsv", "timestamp", "taxonomy"].find {file.toString().endsWith(it)}) {stablefiles.add(file)} }
            assertAll(
                { assert process.success },
                { assert snapshot(
                        stablefiles
                    ).match()
                }
            )
        }

Where the process.out.db contains a directory and subdirectories with multiple files, and I want to exclude database-build.log, database.report.tsv, and timestamp because they are variable files

@jfy133
Copy link
Member Author

jfy133 commented Jan 16, 2025

One downside is you get both files in subdirectories twice: once for the files themsleves, but also because eachFileRecurse includes directories in it's output. Then nf-test(?) will itself pull the files again from that directory, if the directory is in the list of stablefiles.

IT might be worth to update the function that it by default removes directories and only ever check just files

@maxulysse
Copy link
Member

maxulysse commented Jan 16, 2025

Basically you'd want something like this?

        then {
            def stablefiles = getAllFilesFromProcess(process.out.db, ignore["database-build.log", "database.report.tsv", "timestamp", "taxonomy"])
            assertAll(
                { assert process.success },
                { assert snapshot(stablefiles).match()
                }
            )
        }

or even:

        then {
            def stablefiles = getAllFilesFromProcess(process.out.db, ignore["database-build.log", "database.report.tsv"], includeDir: false)
            assertAll(
                { assert process.success },
                { assert snapshot(stablefiles).match()
                }
            )
        }

@jfy133
Copy link
Member Author

jfy133 commented Jan 16, 2025

Yes! Pretty much!

@jfy133
Copy link
Member Author

jfy133 commented Jan 17, 2025

Slight improvement:

            file(process.out.db.get(0).get(1)).eachFileRecurse{ file -> if (!file.isDirectory() && !["database-build.log", "database.report.tsv", "timestamp"].find {file.toString().endsWith(it)}) {stablefiles.add(file)} }

Then I don't have to worry about picking up files in directories twice

@jfy133
Copy link
Member Author

jfy133 commented Jan 17, 2025

And all of this is coauthored (or mostly authorer) by @nvnieuwk !

@jfy133
Copy link
Member Author

jfy133 commented Jan 17, 2025

Also I've had to stablefiles.sort() because there seems to be variability in the order

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