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

.trim() removed to keep new lines between collected versions #306

Merged
merged 1 commit into from
Sep 9, 2024

Conversation

SofiaDrobysheva
Copy link
Contributor

@SofiaDrobysheva SofiaDrobysheva commented Sep 8, 2024

On the page with 20.04 release highlights, in the Collecting version subsection, within an example code snippet, .trim() was removed to keep newline between recorded versions.

old:

workflow {
  Channel.topic('versions') 
    | unique()
    | map { process, name, version ->
      """
      ${process.tokenize(':').last()}:
        ${name}: ${version}
      """.stripIndent().trim()
    }
    | collectFile(name: 'collated_versions.yml')
    | CUSTOM_DUMPSOFTWAREVERSIONS
}

new:

workflow {
  Channel.topic('versions') 
    | unique()
    | map { process, name, version ->
      """\
      ${process.tokenize(':').last()}:
        ${name}: ${version}
      """.stripIndent()
    }
    | collectFile(name: 'collated_versions.yml')
    | CUSTOM_DUMPSOFTWAREVERSIONS
}

Output file example after .trim() is removed:

PREPROCESSING:
  cutadapt: 4.7
PREPROCESSING:
  ribodetector: 0.3.1
GET_SAMPLE_INFO:
  scd: 1.4.22

Copy link

netlify bot commented Sep 8, 2024

Deploy Preview for nextflow-staging ready!

Name Link
🔨 Latest commit 33cae85
🔍 Latest deploy log https://app.netlify.com/sites/nextflow-staging/deploys/66ddb97782e35b00087c96ed
😎 Deploy Preview https://deploy-preview-306--nextflow-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 70 (🔴 down 11 from production)
Accessibility: 95 (no change from production)
Best Practices: 83 (no change from production)
SEO: 85 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@@ -156,10 +156,10 @@ workflow {
Channel.topic('versions') // [!code ++]
| unique()
| map { process, name, version ->
"""
"""\
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think that we need this do we?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or rather, I should ask: was it intentional to add this and if so why?

Copy link
Contributor Author

@SofiaDrobysheva SofiaDrobysheva Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, we do not necessarily need the backslash here!
What it does is that it prevent Groovy from inserting a newline immediately after opening the triple quotes.

So this would be the output with the backslash:

PREPROCESSING:
  cutadapt: 4.7
PREPROCESSING:
  ribodetector: 0.3.1
GET_SAMPLE_INFO:
  scd: 1.4.22

... and this would be the output without the backslash:

PREPROCESSING:
  ribodetector: 0.3.1

PREPROCESSING:
  cutadapt: 4.7

GET_SAMPLE_INFO:
  scd: 1.4.22

Saw the backslash in Ben Sherman's slack reply, though it was cool way of removing extra newlines :) But the pipeline would run either way, so the backslash in this case is a preference thing, I guess.

image

Copy link
Contributor Author

@SofiaDrobysheva SofiaDrobysheva Sep 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ben also mentioned .leftTrim(), this would be the output (looks the same way as when adding the backslash):

PREPROCESSING:
  cutadapt: 4.7
PREPROCESSING:
  ribodetector: 0.3.1
GET_SAMPLE_INFO:
  scd: 1.4.22

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok great, let's leave it in then! I was worried that it would kill the newline and break the yaml, but if it's double spaced already then that's perfect.

Thanks for the explanation! 🙌🏻

Copy link
Member

@ewels ewels left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@ewels ewels merged commit 00d26e0 into nextflow-io:master Sep 9, 2024
6 checks passed
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

Successfully merging this pull request may close these issues.

2 participants