Skip to content

Commit

Permalink
analysis: send token as an environment variable, #TASK-6445
Browse files Browse the repository at this point in the history
  • Loading branch information
pfurio committed Nov 12, 2024
1 parent fc9d19b commit 6a17eec
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;

@Tool(id = CustomToolExecutor.ID, resource = Enums.Resource.JOB, description = CustomToolExecutor.DESCRIPTION)
public class CustomToolExecutor extends OpenCgaDockerToolScopeStudy {
Expand Down Expand Up @@ -60,16 +62,19 @@ protected void check() throws Exception {
tags.add(this.dockerImage);
updateJobInformation(tags, toolInfoExecutor);

StringBuilder cliParamsBuilder = new StringBuilder()
.append(" --opencga-token ").append(refreshToken());
StringBuilder cliParamsBuilder = new StringBuilder();
processInputParams(runParams.getCommandLine(), cliParamsBuilder);
this.cliParams = cliParamsBuilder.toString();
}

@Override
protected void run() throws Exception {
StopWatch stopWatch = StopWatch.createStarted();
String cmdline = runDocker(dockerImage, cliParams);

Map<String, String> dockerParams = new HashMap<>();
dockerParams.put("-e", "OPENCGA_TOKEN=" + getExpiringToken());
String cmdline = runDocker(dockerImage, null, cliParams, dockerParams);

logger.info("Docker command line: " + cmdline);
logger.info("Execution time: " + TimeUtils.durationToString(stopWatch));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ public final ObjectMap getParams() {
return params;
}

public final String refreshToken() throws CatalogException {
public final String getExpiringToken() throws CatalogException {
return catalogManager.getUserManager().refreshToken(token).getToken();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,15 @@ protected void run() throws Exception {
if (StringUtils.isNotEmpty(cliParams)) {
stringBuilder.append(" ").append(cliParams);
}
stringBuilder
.append(" --opencga-token ").append(refreshToken())
.append(" -with-report ").append(outDirPath).append("/report.html\"");
stringBuilder.append(" -with-report ").append(outDirPath).append("/report.html\"");

startTraceFileMonitor();

Map<String, String> dockerParams = new HashMap<>();
// Set HOME environment variable to the temporal input directory. This is because nextflow creates a hidden folder there and,
// when nextflow runs on other dockers, we need to store those files in a path shared between the parent docker and the host
dockerParams.put("-e", "HOME=" + temporalInputDir);
dockerParams.put("-e", "OPENCGA_TOKEN=" + getExpiringToken());

// Execute docker image
StopWatch stopWatch = StopWatch.createStarted();
Expand Down

0 comments on commit 6a17eec

Please sign in to comment.