-
Notifications
You must be signed in to change notification settings - Fork 744
Add platform-related metadata in Lineage records #6545
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
Draft
jorgee
wants to merge
6
commits into
master
Choose a base branch
from
add-platform-meta-in-lineage
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
26e7dc7
add platform metadata in workflow metadata
jorgee f6c5c0e
Add workflow metadata in lineage
jorgee 62b08f7
change inheritance by composition
jorgee 20f2bab
include test to decode without metadata
jorgee bbb1453
remove not defined workflow metadata properties and add path normaliz…
jorgee b4a524b
fix test failure
jorgee File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
113 changes: 113 additions & 0 deletions
113
modules/nextflow/src/main/groovy/nextflow/script/PlatformMetadata.groovy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| /* | ||
| * Copyright 2013-2025, Seqera Labs | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package nextflow.script | ||
|
|
||
| import groovy.transform.Canonical | ||
| import groovy.transform.CompileStatic | ||
| import groovy.transform.EqualsAndHashCode | ||
| import groovy.transform.ToString | ||
| import groovy.util.logging.Slf4j | ||
|
|
||
| /** | ||
| * Store the workflow platform-related metadata | ||
| * | ||
| * @author Jorge Ejarque <[email protected]> | ||
| */ | ||
| @Slf4j | ||
| @CompileStatic | ||
| @ToString(includeNames = true, includePackage = false) | ||
| @EqualsAndHashCode | ||
| class PlatformMetadata { | ||
|
|
||
| @Canonical | ||
| static class User { | ||
| String id | ||
| String userName | ||
| String email | ||
| String firstName | ||
| String lastName | ||
| String organization | ||
|
|
||
| User(Map opts) { | ||
| id = opts.id as String | ||
| userName = opts.userName as String | ||
| email = opts.email as String | ||
| firstName = opts.firstName as String | ||
| lastName = opts.lastName as String | ||
| organization = opts.organization as String | ||
| } | ||
| } | ||
|
|
||
| @Canonical | ||
| static class Workspace { | ||
| String id | ||
| String name | ||
| String fullName | ||
| String organization | ||
|
|
||
| Workspace(Map opts) { | ||
| id = opts.workspaceId as String | ||
| name = opts.workspaceName as String | ||
| fullName = opts.workspaceFullName | ||
| organization = opts.orgName as String | ||
| } | ||
| } | ||
|
|
||
| @Canonical | ||
| static class ComputeEnv { | ||
| String id | ||
| String name | ||
| String platform | ||
|
|
||
| ComputeEnv(Map opts) { | ||
| id = opts.id as String | ||
| name = opts.name as String | ||
| platform = opts.platform as String | ||
| } | ||
| } | ||
|
|
||
| @Canonical | ||
| static class Pipeline { | ||
| String id | ||
| String name | ||
| String revision | ||
| String commitId | ||
|
|
||
| Pipeline(Map opts) { | ||
| id = opts.id as String | ||
| name = opts.name as String | ||
| revision = opts.revision as String | ||
| commitId = opts.commitId as String | ||
| } | ||
| } | ||
|
|
||
| String workflowId | ||
| User user | ||
| Workspace workspace | ||
| ComputeEnv computeEnv | ||
| Pipeline pipeline | ||
| List labels | ||
|
|
||
| PlatformMetadata(String id, User user, Workspace workspace, ComputeEnv computeEnv, Pipeline pipeline, List labels) { | ||
| this.workflowId = id | ||
| this.user = user | ||
| this.workspace = workspace | ||
| this.computeEnv = computeEnv | ||
| this.pipeline = pipeline | ||
| this.labels = labels | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -60,10 +60,40 @@ class LinEncoderTest extends Specification{ | |
| given: | ||
| def encoder = new LinEncoder() | ||
| and: | ||
| def config = [ | ||
| process: [ | ||
| container : "quay.io/nextflow/bash", | ||
| executor : "local", | ||
| resourceLabels: ["owner": "xxx"], | ||
| scratch : false | ||
| ] | ||
| ] | ||
| def metadata = [ | ||
| runName : "big_kare", | ||
| start : "2025-11-06T13:35:42.049135334Z", | ||
| container : "quay.io/nextflow/bash", | ||
| commandLine : "nextflow run 'https://github.com/nextflow-io/hello' -name big_kare -with-tower -r master", | ||
| nextflow : [version: "25.10.0", enable: [dsl: 2.0]], | ||
| containerEngine: "docker", | ||
| wave : [enabled: true], | ||
| fusion : [enabled: true, version: "2.4"], | ||
| seqeraPlatform : [ | ||
| workflowId: "wf1234", | ||
| user : [id: "xxx", userName: "john-smith", email: "[email protected]", firstName: "John", lastName: "Smith", organization: "acme"], | ||
| workspace : [id: "1234", name: "test-workspace", fullName: "Test workspace", organization: "acme"], | ||
| computeEnv: [id: "ce3456", name: "test-ce", platform: "aws-cloud"], | ||
| pipeline : [id: "pipe294", name: "https://github.com/nextflow-io/hello", revision: "master", commitId: null], | ||
| labels : [] | ||
| ], | ||
| failOnIgnore : false | ||
| ] | ||
| def uniqueId = UUID.randomUUID() | ||
| def mainScript = new DataPath("file://path/to/main.nf", new Checksum("78910", "nextflow", "standard")) | ||
| def workflow = new Workflow([mainScript], "https://nextflow.io/nf-test/", "123456") | ||
| def wfRun = new WorkflowRun(workflow, uniqueId.toString(), "test_run", [new Parameter("String", "param1", "value1"), new Parameter("String", "param2", "value2")]) | ||
| def wfRun = new WorkflowRun(workflow, uniqueId.toString(), "test_run", | ||
| [new Parameter("String", "param1", "value1"), new Parameter("String", "param2", "value2")], | ||
| config, metadata | ||
| ) | ||
|
|
||
| when: | ||
| def encoded = encoder.encode(wfRun) | ||
|
|
@@ -82,6 +112,68 @@ class LinEncoderTest extends Specification{ | |
| result.name == "test_run" | ||
| result.params.size() == 2 | ||
| result.params.get(0).name == "param1" | ||
| result.config.process.container == "quay.io/nextflow/bash" | ||
| result.config.process.executor == "local" | ||
| result.metadata.seqeraPlatform.workflowId == "wf1234" | ||
|
|
||
| } | ||
|
|
||
| def 'should decode WorkflowRuns without metadata'(){ | ||
| given: | ||
| def encoder = new LinEncoder() | ||
| def wfRunStr = ''' | ||
| { | ||
| "version": "lineage/v1beta1", | ||
| "kind": "WorkflowRun", | ||
| "spec": { | ||
| "workflow": { | ||
| "scriptFiles": [ | ||
| { | ||
| "path": "https://github.com/nextflow-io/hello/main.nf", | ||
| "checksum": { | ||
| "value": "78910", | ||
| "algorithm": "nextflow", | ||
| "mode": "standard" | ||
| } | ||
| } | ||
| ], | ||
| "repository": "https://github.com/nextflow-io/hello", | ||
| "commitId": "2ce0b0e2943449188092a0e25102f0dadc70cb0a" | ||
| }, | ||
| "sessionId": "4f02559e-9ebd-41d8-8ee2-a8d1e4f09c67", | ||
| "name": "test_run", | ||
| "params": [], | ||
| "config": { | ||
| "process": { | ||
| "container": "quay.io/nextflow/bash", | ||
| "executor": "local", | ||
| "resourceLabels": { | ||
| "owner": "xxx" | ||
| }, | ||
| "scratch": false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ''' | ||
| when: | ||
| def object = encoder.decode(wfRunStr) | ||
|
|
||
| then: | ||
| object instanceof WorkflowRun | ||
| def result = object as WorkflowRun | ||
| result.workflow instanceof Workflow | ||
| result.workflow.scriptFiles.first instanceof DataPath | ||
| result.workflow.scriptFiles.first.path == "https://github.com/nextflow-io/hello/main.nf" | ||
| result.workflow.scriptFiles.first.checksum instanceof Checksum | ||
| result.workflow.scriptFiles.first.checksum.value == "78910" | ||
| result.workflow.commitId == "2ce0b0e2943449188092a0e25102f0dadc70cb0a" | ||
| result.sessionId == "4f02559e-9ebd-41d8-8ee2-a8d1e4f09c67" | ||
| result.name == "test_run" | ||
| result.params.size() == 0 | ||
| result.config.process.container == "quay.io/nextflow/bash" | ||
| result.config.process.executor == "local" | ||
| result.metadata == null | ||
| } | ||
|
|
||
| def 'should encode and decode WorkflowOutputs'(){ | ||
|
|
||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.