Expose the Seqera Platform username to the Nextflow run
Rob Syme
We can the use the
resourceLabels
directive to attach labels to runs which are extremely useful for higher resolution cost tracking. A common request is to be able to see the cost of runs per user
. At the moment this is impossible because the Platform does not pass the username
to Nextflow.A quick win would be to set the SP
username
as an environment variable in the head job. This can be read by Nextflow and used as a resourceLabel
tag (if the user provided the appropriate configuration)F
Flamingo pink Python
similar to these?
https://feedback.seqera.io/feature-requests/p/nextflow-needs-to-be-able-to-access-metadata-from-the-tower
https://feedback.seqera.io/feature-requests/p/template-resource-labels
> A quick win would be to set the SP username as an environment variable in the head job. This can be read by Nextflow and used as a resourceLabel tag (if the user provided the appropriate configuration)
Does this feature already exist? Or is that part of the feature request as well?
I think if we are going to start introducing environment variables that can supply extra resourceLabels to append to the current set of resourceLabels in the pipeline, then it might be something similar to the demo here;
https://github.com/stevekm/nextflow-demos/blob/master/resourceLabels/nextflow.config
Instead of making a Nextflow env var only for the Seqera Platform username, might as well just use some sort of syntax for embedding a collection of metadata to an env var for ingestion by Nextflow. In that linked demo, a JSON string is used. As per this current feature request, maybe it could be like this;
export NXF_RESOURCELABELS='{"PlatformUsername": "my-name", "PlatformRunID":"123456", ... }'
if it was implemented something like this, it could be usable both by Seqera Platform in the current feature request but also for other use cases. It seems like the effort needed to implement such a feature in an open-ended extensible manner might not be much greater.