Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class ExecutorOpts implements ConfigScope {
static final Set<String> VALID_AUTO_LABELS = Collections.unmodifiableSet(new LinkedHashSet<>([
'projectName', 'userName', 'runName', 'sessionId', 'resume',
'revision', 'commitId', 'repository', 'manifestName',
'runtimeVersion', 'workflowId'
'runtimeVersion', 'workflowId', 'workspaceId', 'computeEnvId'
]))

final RetryOpts retryPolicy
Expand Down Expand Up @@ -87,7 +87,7 @@ class ExecutorOpts implements ConfigScope {
`['runName', 'projectName']` or `'runName,projectName'`
Valid names: `projectName`, `userName`, `runName`, `sessionId`, `resume`,
`revision`, `commitId`, `repository`, `manifestName`, `runtimeVersion`,
`workflowId`.
`workflowId`, `workspaceId`, `computeEnvId`.
""")
final Set<String> autoLabels

Expand Down
6 changes: 5 additions & 1 deletion plugins/nf-seqera/src/main/io/seqera/executor/Labels.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class Labels {
static final Set<String> ALL_AUTO_LABELS = Collections.unmodifiableSet(new LinkedHashSet<>([
'projectName', 'userName', 'runName', 'sessionId', 'resume',
'revision', 'commitId', 'repository', 'manifestName',
'runtimeVersion', 'workflowId'
'runtimeVersion', 'workflowId', 'workspaceId', 'computeEnvId'
]))

private final Map<String,String> entries = new LinkedHashMap<>(20)
Expand Down Expand Up @@ -78,6 +78,10 @@ class Labels {
entries.put('nextflow.io/runtimeVersion', NextflowMeta.instance.version.toString())
if( include.contains('workflowId') && workflow.platform?.workflowId )
entries.put('seqera.io/platform/workflowId', workflow.platform.workflowId)
if( include.contains('workspaceId') && workflow.platform?.workspace?.id )
entries.put('seqera.io/platform/workspaceId', workflow.platform.workspace.id)
if( include.contains('computeEnvId') && workflow.platform?.computeEnv?.id )
entries.put('seqera.io/platform/computeEnvId', workflow.platform.computeEnv.id)
return this
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,17 @@ class ExecutorOptsTest extends Specification {
config.autoLabels == ['runName', 'projectName'] as Set
}

def 'should accept workspaceId and computeEnvId in auto labels' () {
when:
def config = new ExecutorOpts([
endpoint: 'https://sched.example.com',
autoLabels: ['workspaceId', 'computeEnvId']
])

then:
config.autoLabels == ['workspaceId', 'computeEnvId'] as Set
}

def 'should trim whitespace in auto labels list entries' () {
when:
def config = new ExecutorOpts([
Expand Down
23 changes: 23 additions & 0 deletions plugins/nf-seqera/src/test/io/seqera/executor/LabelsTest.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ class LabelsTest extends Specification {
!labels.entries.containsKey('seqera:sched:clusterId')
}

def 'should include platform workspaceId and computeEnvId when available'() {
given:
def platform = new PlatformMetadata('wf-abc123')
platform.workspace = new PlatformMetadata.Workspace(workspaceId: '1234')
platform.computeEnv = new PlatformMetadata.ComputeEnv(id: 'ce-abc')
def workflow = Mock(WorkflowMetadata) {
getRunName() >> 'happy_turing'
getSessionId() >> UUID.randomUUID()
isResume() >> false
getManifest() >> new Manifest([:])
getPlatform() >> platform
}

when:
def labels = new Labels()
.withWorkflowMetadata(workflow, ['workspaceId', 'computeEnvId'] as Set)

then:
labels.entries.keySet() == ['seqera.io/platform/workspaceId', 'seqera.io/platform/computeEnvId'] as Set
labels.entries['seqera.io/platform/workspaceId'] == '1234'
labels.entries['seqera.io/platform/computeEnvId'] == 'ce-abc'
}
Comment thread
pditommaso marked this conversation as resolved.

def 'should include platform workflowId when available'() {
given:
def workflow = Mock(WorkflowMetadata) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ class SeqeraExecutorTest extends Specification {
new CreateRunResponse().runId('run-1')
}
}
def platform = new nextflow.script.PlatformMetadata('wf-abc123')
platform.workspace = new nextflow.script.PlatformMetadata.Workspace(workspaceId: '1234')
platform.computeEnv = new nextflow.script.PlatformMetadata.ComputeEnv(id: 'ce-abc')
def workflowMeta = Mock(WorkflowMetadata) {
getProjectName() >> 'my-project'
getUserName() >> 'alice'
Expand All @@ -195,7 +198,7 @@ class SeqeraExecutorTest extends Specification {
getCommitId() >> null
getRepository() >> null
getManifest() >> null
getPlatform() >> null
getPlatform() >> platform
}
def sessionConfig = [
process: [resourceLabels: [team: 'platform', priority: 3]],
Expand Down Expand Up @@ -223,11 +226,14 @@ class SeqeraExecutorTest extends Specification {
captured.getLabels()['priority'] == '3'
captured.getLabels()['nextflow.io/projectName'] == 'my-project'
captured.getLabels()['nextflow.io/runName'] == 'test-run'
captured.getLabels()['seqera.io/platform/workspaceId'] == '1234'
captured.getLabels()['seqera.io/platform/computeEnvId'] == 'ce-abc'

cleanup:
executor.batchSubmitter?.shutdown()
}


/**
* Builds a SchedClientConfig using the same logic as {@link SeqeraExecutor#createClient()}
*/
Expand Down
Loading