Skip to content

Commit 4ea8d52

Browse files
edmundmillerFloWuenne
authored andcommitted
feat: add optional platform and token_env fields to input samplesheet (SE-107)
Allow mixing runs from different Seqera Platform instances in a single benchmark by adding two optional columns to the input CSV: - platform: Seqera Platform API URL override (falls back to --seqera_api_endpoint) - token_env: env-var name holding the bearer token (falls back to TOWER_ACCESS_TOKEN) Both fields are fully backward-compatible. The per-row overrides are honoured in the benchmark report path (SeqeraApi.fetchRunData); the tw CLI path (SEQERA_RUNS_DUMP) still uses global config.
1 parent 8e9ef29 commit 4ea8d52

3 files changed

Lines changed: 36 additions & 7 deletions

File tree

assets/schema_input.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@
3030
"pattern": "^\\S+$",
3131
"errorMessage": "Please provide a valid file path to your Seqera Platform logs.",
3232
"meta": ["logs"]
33+
},
34+
"platform": {
35+
"type": "string",
36+
"pattern": "^https?://.*$",
37+
"errorMessage": "Please provide a valid Seqera Platform API URL (e.g. https://api.cloud.seqera.io)",
38+
"meta": ["platform"]
39+
},
40+
"token_env": {
41+
"type": "string",
42+
"pattern": "^[A-Za-z_][A-Za-z0-9_]*$",
43+
"errorMessage": "Please provide a valid environment variable name (e.g. TOWER_PROD_TOKEN)",
44+
"meta": ["token_env"]
3345
}
3446
},
3547
"required": ["id", "workspace"]

lib/SeqeraApi.groovy

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,28 @@ class SeqeraApi {
6464

6565
/**
6666
* Fetch all data for a single run. Returns map with workflow, metrics, tasks, progress.
67+
*
68+
* Per-row overrides (from the input samplesheet):
69+
* meta.platform – Seqera Platform API URL; falls back to the global apiEndpoint
70+
* meta.token_env – env-var name holding the bearer token; falls back to TOWER_ACCESS_TOKEN
6771
*/
6872
static Map fetchRunData(Map meta, String apiEndpoint) {
69-
def token = System.getenv("TOWER_ACCESS_TOKEN")
73+
def effectiveEndpoint = meta.platform ?: apiEndpoint
74+
def tokenEnvVar = meta.token_env ?: "TOWER_ACCESS_TOKEN"
75+
def token = System.getenv(tokenEnvVar)
76+
if (!token) {
77+
throw new RuntimeException(
78+
"Environment variable '${tokenEnvVar}' is not set (required for run ${meta.id})"
79+
)
80+
}
7081
def headers = ["Authorization": "Bearer ${token}"]
71-
def wsId = resolveWorkspaceId(meta.workspace, apiEndpoint, headers)
72-
def base = "${apiEndpoint}/workflow/${meta.id}?workspaceId=${wsId}"
82+
def wsId = resolveWorkspaceId(meta.workspace, effectiveEndpoint, headers)
83+
def base = "${effectiveEndpoint}/workflow/${meta.id}?workspaceId=${wsId}"
7384

7485
def workflow = apiGet(base, headers)
75-
def metrics = apiGet("${apiEndpoint}/workflow/${meta.id}/metrics?workspaceId=${wsId}", headers)
76-
def tasks = apiGetAllTasks("${apiEndpoint}/workflow/${meta.id}/tasks?workspaceId=${wsId}", headers)
77-
def progress = apiGet("${apiEndpoint}/workflow/${meta.id}/progress?workspaceId=${wsId}", headers)
86+
def metrics = apiGet("${effectiveEndpoint}/workflow/${meta.id}/metrics?workspaceId=${wsId}", headers)
87+
def tasks = apiGetAllTasks("${effectiveEndpoint}/workflow/${meta.id}/tasks?workspaceId=${wsId}", headers)
88+
def progress = apiGet("${effectiveEndpoint}/workflow/${meta.id}/progress?workspaceId=${wsId}", headers)
7889

7990
return [
8091
workflow: workflow?.workflow,

workflows/nf_aggregate/main.nf

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,13 @@ workflow NF_AGGREGATE {
7575
Thread.sleep(sleepMs)
7676
}
7777
}
78-
data.meta = [id: meta.id, workspace: meta.workspace, group: meta.group ?: 'default']
78+
data.meta = [
79+
id: meta.id,
80+
workspace: meta.workspace,
81+
group: meta.group ?: 'default',
82+
platform: meta.platform ?: null,
83+
token_env: meta.token_env ?: null,
84+
]
7985
def tmpDir = java.nio.file.Files.createTempDirectory("nf-agg-run-${meta.id}-")
8086
def json_file = file(tmpDir.resolve("${meta.id}.json"))
8187
json_file.text = groovy.json.JsonOutput.toJson(data)

0 commit comments

Comments
 (0)