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

charliecloud registry, docs #5017

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ The following settings are available:
### Scope `charliecloud`

The `charliecloud` scope controls how [Charliecloud](https://hpc.github.io/charliecloud/) containers are executed by Nextflow.
If `charliecloud.writeFake` is unset / `false`, charliecloud will create a copy of the container in the process working directory.

The following settings are available:

Expand All @@ -497,6 +498,15 @@ The following settings are available:
`charliecloud.temp`
: Mounts a path of your choice as the `/tmp` directory in the container. Use the special value `auto` to create a temporary directory each time a container is created.

`charliecloud.registry`
: The registry from where images are pulled. It should be only used to specify a private registry server. It should NOT include the protocol prefix i.e. `http://`.

`charliecloud.writeFake`
: Enable `writeFake` with charliecloud. This allows to run containers from storage in writeable mode, using overlayfs, see [charliecloud documentation](https://hpc.github.io/charliecloud/ch-run.html#ch-run-overlay) for details

`charliecloud.useSquash`
: Create a temporary squashFS container image in the process work directory instead of a folder.

Read the {ref}`container-charliecloud` page to learn more about how to use Charliecloud containers with Nextflow.

(config-conda)=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import groovy.util.logging.Slf4j
* @author Paolo Di Tommaso <paolo.ditommaso@gmail.com>
* @author Patrick Hüther <patrick.huether@gmail.com>
* @author Laurent Modolo <laurent.modolo@ens-lyon.fr>
* @author Niklas Schandry <niklas@bio.lmu.de>
*/
@CompileStatic
@Slf4j
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import nextflow.util.Duration
*
* @author Paolo Di Tommaso <paolo.ditommaso@gmail.com>
* @author Patrick Hüther <patrick.huether@gmail.com>
* @author Niklas Schandry <niklas@bio.lmu.de>
*/
@Slf4j
@CompileStatic
Expand Down Expand Up @@ -79,11 +80,14 @@ class CharliecloudCache {
String simpleName(String imageUrl) {
def p = imageUrl.indexOf('://')
def name = p != -1 ? imageUrl.substring(p+3) : imageUrl

// add registry
if( registry )
name = registry + name

// add registry
if( registry ) {
if( !registry.endsWith('/') ) {
registry += '/'
}
imageUrl = registry + imageUrl
}
name = name.replace(':','+').replace('/','%')
return name
}
Expand Down Expand Up @@ -207,8 +211,9 @@ class CharliecloudCache {
if( missingCacheDir )
log.warn1 "Charliecloud cache directory has not been defined -- Remote image will be stored in the path: $targetPath.parent.parent -- Use the charliecloud.cacheDir config option or set the NXF_CHARLIECLOUD_CACHEDIR variable to specify a different location"


log.info "Charliecloud pulling image $imageUrl [cache $targetPath]"

String cmd = "ch-image pull -s $targetPath.parent.parent $imageUrl > /dev/null"
try {
runCommand( cmd, targetPath )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,15 @@ class ContainerHandler {
return Escape.path(result)
}
if( engine == 'charliecloud' ) {
final normalizedImageName = normalizeCharliecloudImageName(imageName)
if( !config.isEnabled() || !normalizedImageName )
return normalizedImageName
// if the imagename starts with '/' it's an absolute path
// otherwise we assume it's in a remote registry and pull it from there
final requiresCaching = !imageName.startsWith('/')
if( ContainerInspectMode.active() && requiresCaching )
return imageName
final result = requiresCaching ? createCharliecloudCache(this.config, imageName) : imageName
final result = requiresCaching ? createCharliecloudCache(this.config, normalizedImageName) : normalizedImageName
return Escape.path(result)
}
// fallback to docker
Expand Down Expand Up @@ -271,4 +274,32 @@ class ContainerHandler {
// prefix it with the `docker://` pseudo protocol used by apptainer to download it
return "docker://${normalizeDockerImageName(img)}"
}

/**
* Normalize charliecloud image name resolving the absolute path
*
* @param imageName The container image name
* @return Image name in canonical format
*/
@PackageScope
String normalizeCharliecloudImageName(String img) {
if( !img )
return null

// when starts with `/` it's an absolute image file path, just return it
if( img.startsWith("/") )
return img

// check if matches a protocol scheme such as `docker://xxx`
if( img =~ IMAGE_URL_PREFIX ) {
return img
}
// if it's the path of an existing image file return it
def imagePath = baseDir.resolve(img)
if( imagePath.exists() ) {
return imagePath.toString()
}
// in all other case it's supposed to be the name of an image
return "${normalizeDockerImageName(img)}"
}
}
Loading