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

consider docker release cycle #37

Open
kelly-sovacool opened this issue Oct 29, 2024 · 2 comments
Open

consider docker release cycle #37

kelly-sovacool opened this issue Oct 29, 2024 · 2 comments

Comments

@kelly-sovacool
Copy link
Member

kelly-sovacool commented Oct 29, 2024

idea found by @kopardev: modifiers on tags for dev, feature, bug, main

how can we automate this to reduce maintenance overhead?

nextflow modules can use if/else statements to search for main/dev/feature tags

@kopardev
Copy link
Member

kopardev commented Nov 4, 2024

@kelly-sovacool i was thinking of something like this

process exampleProcess {
    // Define the container images in priority order for both Singularity and Docker
    def containerPaths = [
        'xyz': [
            docker: 'xyz:v2'
        ],
        'xyzdev': [
            docker: 'xyz:v2-dev'
        ],
        'xyzfeat': [
           docker: 'xyz:v2-feat'
        ]
    ]

    // Find the first available container image
    def selectedImage = containerPaths.find { image, paths ->
        def testImage = workflow.containerEngine == 'singularity' ? paths.singularity : paths.docker
        "singularity pull ${testImage}".execute().waitFor() == 0
    }

    // Error handling if no image is found
    if (!selectedImage) {
        throw new RuntimeException("No suitable container image found.")
    }

    // Use the appropriate image based on the container engine
    container "${workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ?
        selectedImage.value.singularity :
        selectedImage.value.docker }"

    script:
    """
blah blah blah
    """
}

will this work? what do you think??

@kelly-sovacool
Copy link
Member Author

kelly-sovacool commented Nov 4, 2024

@kopardev I think something like your code will work.

To reduce code repetition, I think we would want to put most of this code in a groovy function in lib/ (in the nextflow template repo), then the process definition could pass along the default container tag. So the structure would be something like:

modules/blah/example/main.nf:

process exampleProcess {

  container "${ Containers.select('xyz:v2') }"

  script:
  """
  ...
}

lib/Containers.groovy:

class Containers {
  public static String select(image) {
    // logic for selecting appropriate container goes here
    return image
  }
}

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