Skip to content

Commit

Permalink
pass unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
drernie committed Oct 30, 2024
1 parent bdbb79c commit 666f80a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ keys to extract only the metadata you need, if present. For example:
```groovy
quilt {
meta = [pipeline: 'nf-core/rnaseq']
msg = "${meta['config']['runName']}: ${meta['cmd']}"
msg = "${meta['config']?.get('runName')}: ${meta['cmd']}"
readme = '''
# ${pkg}
Expand Down
11 changes: 7 additions & 4 deletions plugins/nf-quilt/src/main/nextflow/quilt/QuiltProduct.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -173,20 +173,23 @@ ${nextflow}
}
Map<String, Map<String,Object>> cf = session.config
println("addSessionMeta.cf: ${cf}")
Map qf = cf.navigate('quilt') as Map<String, Map<String, Object>>
Map qf = cf.navigate('quilt') as Map<String, Object>
qf['package_id'] = pkg.toString()
qf['uri'] = path.toUriString()
println("addSessionMeta.qf: ${qf}")
Map<String, Object> cmeta = qf.navigate('meta') as Map<String, Object>
println("addSessionMeta.cmeta: ${cmeta}")

try {
Map smeta = getMetadata(cf)
// println("addSessionMeta.smeta: ${smeta}")
smeta['quilt'] = [package_id: pkg.toString(), uri: path.toUriString()]
msg = "${smeta['config']['runName']}: ${smeta['cmd']}"
smeta['quilt'] = qf
smeta.remove('config')
meta += smeta + cmeta
msg = "${cf.get('runName')}: ${meta['cmd']}"
} catch (Exception e) {
log.error("addSessionMeta.getMetadata failed: ${e.getMessage()}\n{$e}", pkg.meta)
println("addSessionMeta.getMetadata failed: $e")
log.error("addSessionMeta.getMetadata failed: ${e.getMessage()}", pkg.meta)
return false
}
writeNextflowMetadata(meta, 'metadata')
Expand Down
10 changes: 5 additions & 5 deletions plugins/nf-quilt/src/main/nextflow/quilt/jep/QuiltPackage.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -281,15 +281,15 @@ class QuiltPackage {
})
}
// https://docs.quiltdata.com/v/version-5.0.x/examples/gitlike#install-a-package
Manifest push(String msg = 'update', Map meta = [:]) {
Manifest push(String msg = 'update', Map meta = [:], String pkg = null) {
if (isNull()) {
log.debug('null bucket: no need to push')
return null
}

String pkgName = pkg ?: packageName
S3PhysicalKey registryPath = new S3PhysicalKey(bucket, '', null)
Registry registry = new Registry(registryPath)
Namespace namespace = registry.getNamespace(packageName)
Namespace namespace = registry.getNamespace(pkgName)

Manifest.Builder builder = Manifest.builder()

Expand All @@ -309,10 +309,10 @@ class QuiltPackage {
builder.setMetadata((ObjectNode)mapper.valueToTree(fullMeta))

Manifest m = builder.build()
log.debug("push[${this.parsed}]: ${m}")
log.debug("push[${pkgName}]: ${m}")
try {
Manifest manifest = m.push(namespace, "nf-quilt:${today()}-${msg}", parsed.workflowName)
log.debug("pushed[${this.parsed}]: ${manifest}")
log.debug("pushed[${pkgName}]: ${manifest}")
return manifest
} catch (Exception e) {
log.error('ERROR: Failed to push manifest', e)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class QuiltProductTest extends QuiltSpecification {
getWorkflowMetadata() >> wf_meta
getParams() >> [outdir: url]
isSuccess() >> success
config >> [quilt: [metadata: [cfkey: 'cfval']], runName: 'my-run', publishing: false]
config >> [quilt: [meta: [cfkey: 'cfval']], runName: 'my-run', publishing: false]
}
return new QuiltProduct(pathify, session)
}
Expand Down Expand Up @@ -187,7 +187,7 @@ class QuiltProductTest extends QuiltSpecification {
}

@Ignore('Not implemented yet: pushes previous metadata')
void 'pushes previous metadata if metadata=SKIP'() {
void 'pushes previous metadata if meta=SKIP'() {
given:
Map meta = [
'Name': 'QuiltPackageTest',
Expand All @@ -196,7 +196,7 @@ class QuiltProductTest extends QuiltSpecification {
'Type': 'NGS'
]
Map bad_meta = meta + ['Type': 'Workflow']
Map skip_meta = ['metadata': 'SKIP']
Map skip_meta = ['meta': 'SKIP']

when:
makeWriteProduct() // no metadata
Expand Down

0 comments on commit 666f80a

Please sign in to comment.