Skip to content
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

TASK-6445 - Implement OpenCGA Workflows with NextFlow #2530

Open
wants to merge 121 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
c19f6a9
core: first nextflow implementation, #TASK-6445
pfurio Jul 16, 2024
621bef2
catalog: implement workflow manager and dbadaptor, #TASK-6445
pfurio Jul 18, 2024
74f11d6
analysis: add test to run nextflow docker, #TASK-6445
pfurio Aug 5, 2024
c97f75e
app: add nextflow to opencga-base, #TASK-6445
pfurio Aug 5, 2024
d776092
catalog: add new update operation, #TASK-6445
pfurio Aug 7, 2024
c53c794
Merge branch 'develop' into TASK-6445
pfurio Aug 7, 2024
3031cc6
catalog: implement workflows under studies, #TASK-6445
pfurio Aug 8, 2024
bc99139
Merge branch 'develop' into TASK-6445
pfurio Sep 2, 2024
0bb262d
server: add new workflow web services, #TASK-6445
pfurio Sep 2, 2024
42edc20
catalog: support files in workflows, #TASK-6445
pfurio Sep 3, 2024
c152132
pom: change cellbase dependency, #TASK-6445
pfurio Sep 3, 2024
0732dd3
cicd: remove init docker from being built, #TASK-6445
pfurio Sep 3, 2024
5d3156e
catalog: fix workflow indexes, #TASK-6445
pfurio Sep 4, 2024
aa3edc0
analysis: change nextflow executor id, #TASK-6445
pfurio Sep 13, 2024
1b1f4be
catalog: add basic tests for workflows, #TASK-6445
pfurio Sep 13, 2024
234db9c
Merge branch 'develop' into TASK-6445
pfurio Sep 13, 2024
1a2ef45
catalog: implement delete workflow, #TASK-6445
pfurio Sep 16, 2024
f9578e0
Implement a python script to build Docker images for user's custom tools
imedina Sep 17, 2024
812d9eb
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
imedina Sep 17, 2024
1253359
Add missing Workflow indexes
imedina Sep 17, 2024
0f2e4f3
core: add new binary executor, #TASK-6445
pfurio Sep 17, 2024
17f93e7
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
pfurio Sep 17, 2024
2fca115
app: support Git repository when building new custom tools
imedina Sep 18, 2024
126fbb1
core: add new fields to Workflow data model, #TASK-6445
pfurio Sep 18, 2024
deaa047
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
pfurio Sep 18, 2024
7354188
server: add new WS to set acls to workflows, #TASK-6445
pfurio Sep 18, 2024
7c2f6db
analysis: add tags/attributes to Job, #TASK-6445
pfurio Sep 18, 2024
c91061a
Update clients
imedina Sep 19, 2024
311a312
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
imedina Sep 19, 2024
93ec0b6
Merge branch 'develop' into TASK-6445
pfurio Sep 19, 2024
da72511
core: improve nextflow executor, #TASK-6445
pfurio Sep 19, 2024
6c1456b
analysis: write tags and attributes in Job, #TASK-6445
pfurio Sep 19, 2024
2da90f8
analysis: avoid tag duplicates, #TASK-6445
pfurio Sep 19, 2024
49ec23e
catalog: allow updating the workflow system, #TASK-6445
pfurio Sep 19, 2024
d1d2551
analysis: execute any workflow version, #TASK-6445
pfurio Sep 19, 2024
37ce484
core: set job status to ERROR if any step fails, #TASK-6445
pfurio Sep 19, 2024
8874a65
analysis: improve nextflow parameter inputs, #TASK-6445
pfurio Sep 19, 2024
266c98c
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
imedina Sep 19, 2024
97768ac
catalog: add profile exception, #TASK-6445
pfurio Sep 20, 2024
cdb2e89
analysis: improve executor to accept fields with -, #TASK-6445
pfurio Sep 20, 2024
857b41d
core: add minimumRequirements to Workflow, #TASK-6445
pfurio Sep 20, 2024
c6df368
core: add new tool externalExecutor object to Job, #TASK-6445
pfurio Sep 20, 2024
3f22551
analysis: mount docker socket, #TASK-6445
pfurio Sep 20, 2024
612c60b
analysis: add missing trailing quote, #TASK-6445
pfurio Sep 20, 2024
c248a37
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
imedina Sep 22, 2024
f625346
core@ review workflow and job data models and their indexes
imedina Sep 22, 2024
0c6bbf9
docker: add 'make' command to custom-tool docker builder
imedina Sep 22, 2024
88ac8ba
rest: rename 'job/run' web service
imedina Sep 22, 2024
661241a
Add new REST web service to build tools for customer, new path for to…
imedina Sep 22, 2024
f089a67
rest: move 'job/run' to /job/tool/run'
imedina Sep 22, 2024
8cb935a
analysis: add new tool to build custom docker images
imedina Sep 22, 2024
9f6472e
analysis: some renaming and minor improvements
imedina Sep 22, 2024
74057f1
analysis: fix path in CustomToolBuilder
imedina Sep 22, 2024
a489e3d
app: add execution permission to new custom-tool-docker-builder.py
imedina Sep 22, 2024
5520cc9
app: execute new custom-tool-docker-builder.py with command 'python3'
imedina Sep 22, 2024
02cf40a
app: fix custom-tool-docker-builder.py
imedina Sep 23, 2024
1a60124
app: fix custom-tool-docker-builder.py
imedina Sep 23, 2024
2197de5
analysis: remove docker sock, #TASK-6445
pfurio Sep 23, 2024
927b859
catalog: allow querying by manager.id in workflows, #TASK-6445
pfurio Sep 23, 2024
881b437
catalog: add new fields to query by job, #TASK-6445
pfurio Sep 23, 2024
b89b9d7
app: add docker dependency to custom-tool-docker-builder.py
imedina Sep 23, 2024
2397d01
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
imedina Sep 23, 2024
a814182
analysis: try docker.sock and docker host, #TASK-6445
pfurio Sep 23, 2024
dc678d0
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
pfurio Sep 23, 2024
b0acafa
analysis: fix docker cli generation, #TASK-6445
pfurio Sep 23, 2024
509b9e3
analysis: add network host to container, #TASK-6445
pfurio Sep 23, 2024
5540f4d
app: add Docker to custom tool docker build script
imedina Sep 23, 2024
b90b3d6
app: add docker in docker to custom tool docker build script
imedina Sep 24, 2024
35efede
analysis: adapt executor to accept dynamic docker params, #TASK-6445
pfurio Sep 24, 2024
73983b6
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
pfurio Sep 24, 2024
21510e7
analysis: remove some params from cli, #TASK-6445
pfurio Sep 24, 2024
3328c25
analysis: new nextflow docker, #TASK-6445
pfurio Sep 25, 2024
84782cb
analysis: add docker-host env, #TASK-6445
pfurio Sep 25, 2024
ac5ec7b
analysis: add dynamic output parameters, #TASK-6445
pfurio Sep 26, 2024
416ee51
app: add new nextflow dockerfile, #TASK-6445
pfurio Sep 26, 2024
78c74eb
app: minor style improvements in opencga-base Dockerfile
imedina Sep 26, 2024
8739c18
app: add new opencga-workflow docker
imedina Sep 27, 2024
9559215
app: fixes in opencga-worklow docker
imedina Sep 27, 2024
f9fd34d
app: fix Dockerfile, #TASK-6445
pfurio Sep 27, 2024
9f408d5
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
pfurio Sep 27, 2024
fa96ec4
app: minor improvements
imedina Sep 27, 2024
16f35e7
catalog: explore file content to find file:// prefixes, #TASK-6445
pfurio Sep 27, 2024
cb9828d
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
pfurio Sep 27, 2024
d9c153c
app: remove Nextflow from opencga-base Dockerfile
imedina Sep 28, 2024
95eee7c
cdcd: add opencga-workflow docker to the different GH Actions workflows
imedina Sep 28, 2024
31ed1c0
Adding a new variant tool to liftover VCF files
imedina Sep 30, 2024
246dfab
core: add new WorkflowVariable, #TASK-6445
pfurio Sep 30, 2024
89cc3d6
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
pfurio Sep 30, 2024
97c0206
analysis: use new opencb workflow repository, #TASK-6445
pfurio Sep 30, 2024
c15799b
analysis: uncomment job update, #TASK-6445
pfurio Sep 30, 2024
d74a555
analysis: improve nextflow executor, #TASK-6445
pfurio Sep 30, 2024
14e6b6b
analysis: change workflow docker, #TASK-6445
pfurio Sep 30, 2024
d6d45c0
analysis: fix param processing in executor, #TASK-6445
pfurio Sep 30, 2024
2e91ab4
analysis: remove temporal files generated by nextflow, #TASK-6445
pfurio Sep 30, 2024
ab8086a
analysis: improve last execution steps, #TASK-6445
pfurio Sep 30, 2024
be54d85
analysis: improve cleaning resources step, #TASK-6445
pfurio Sep 30, 2024
861a87a
analysis: support $JOB_OUTPUT variable, #TASK-6445
pfurio Oct 1, 2024
bc2cc11
analysis: add new OpenCgaDockerTool, #TASK-6445
pfurio Oct 1, 2024
ccbba00
app: docker improvements
imedina Oct 3, 2024
31811c1
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
imedina Oct 3, 2024
5a89bd2
Merge branch 'develop' into TASK-6445
imedina Oct 5, 2024
d3c23a1
Merge branch 'TASK-6780' into TASK-6445
pfurio Oct 8, 2024
1ea05e2
Merge branch 'develop' into TASK-6445
imedina Oct 16, 2024
7530def
catalog: fix workflow permission check, #TASK-6445
pfurio Oct 17, 2024
71472c0
core: fix Workflow variable types
imedina Oct 18, 2024
916179f
Merge branch 'TASK-6445' of github.com:opencb/opencga into TASK-6445
imedina Oct 18, 2024
fcd8f97
catalog: add new changes for workflows, #TASK-6445
pfurio Oct 22, 2024
52a0de7
server: add import web service, #TASK-6445
pfurio Oct 22, 2024
6cc846b
client: add workflow clients and CLI
imedina Oct 22, 2024
9f93531
master: fix daemon to use correct tool id, #TASK-6445
pfurio Oct 23, 2024
f63d3e9
master: ensure only necessary ToolInfo fields are updated, #TASK-6445
pfurio Oct 23, 2024
0f51878
catalog: ensure all jobs can be accessed by the owner, #TASK-6445
pfurio Oct 25, 2024
fec2270
core: add new type field to Job, #TASK-6445
pfurio Nov 7, 2024
3e2964e
analysis: add cellbase dependency, #TASK-6445
pfurio Nov 8, 2024
fc9d19b
analysis: add opencga-token to external executions, #TASK-6445
pfurio Nov 12, 2024
6a17eec
analysis: send token as an environment variable, #TASK-6445
pfurio Nov 12, 2024
d0d8346
app: create migration scripts, #TASK-6445
pfurio Nov 13, 2024
18bb5fe
analysis: fix ToolRunner to get proper toolId, #TASK-6445
pfurio Nov 13, 2024
3f37761
Merge branch 'develop' into TASK-6445
pfurio Nov 13, 2024
93c141b
app: fix possible migration issues, #TASK-6445
pfurio Nov 13, 2024
7a5b7cd
master: Submit k8s job reading minRequirements #TASK-6445
j-coll Nov 14, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ jobs:
uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop
needs: build
with:
cli: python3 ./build/cloud/docker/docker-build.py push --images base,init
cli: python3 ./build/cloud/docker/docker-build.py push --images base,workflow,init
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/manual-deploy-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ jobs:
uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop
needs: build
with:
cli: python3 ./build/cloud/docker/docker-build.py push --images base,init --tag ${{ inputs.tag }}
cli: python3 ./build/cloud/docker/docker-build.py push --images base,workflow,init --tag ${{ inputs.tag }}
secrets: inherit
2 changes: 1 addition & 1 deletion .github/workflows/pull-request-merged.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ jobs:
uses: opencb/java-common-libs/.github/workflows/delete-docker-hub-workflow.yml@develop
needs: build
with:
cli: python3 ./build/cloud/docker/docker-build.py delete --images base --tag ${{ github.head_ref }}
cli: python3 ./build/cloud/docker/docker-build.py delete --images base,workflow --tag ${{ github.head_ref }}
secrets: inherit

2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop
needs: build-hdp
with:
cli: python3 ./build/cloud/docker/docker-build.py push --images base,init --tag "${{ needs.build-hdp.outputs.version }}-hdp3.1"
cli: python3 ./build/cloud/docker/docker-build.py push --images base,workflow,init --tag "${{ needs.build-hdp.outputs.version }}-hdp3.1"
build_folder: build-folder
secrets: inherit

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ jobs:
uses: opencb/java-common-libs/.github/workflows/deploy-docker-hub-workflow.yml@develop
needs: test
with:
cli: python3 ./build/cloud/docker/docker-build.py push --images base,init --tag ${{ github.ref_name }}
cli: python3 ./build/cloud/docker/docker-build.py push --images base,workflow --tag ${{ github.ref_name }}
secrets: inherit
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import org.opencb.opencga.core.models.file.FileQualityControl;
import org.opencb.opencga.core.models.file.FileUpdateParams;
import org.opencb.opencga.core.models.job.Job;
import org.opencb.opencga.core.models.job.JobType;
import org.opencb.opencga.core.response.OpenCGAResult;
import org.opencb.opencga.core.tools.annotations.Tool;
import org.opencb.opencga.core.tools.annotations.ToolParams;
Expand Down Expand Up @@ -119,7 +120,7 @@ protected void run() throws ToolException {
.toParams(new ObjectMap(ParamConstants.STUDY_PARAM, study));

OpenCGAResult<Job> flagStatsJobResult = catalogManager.getJobManager()
.submit(study, AlignmentFlagStatsAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
.submit(study, JobType.NATIVE, AlignmentFlagStatsAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
+ getId() + " - " + getJobId(), Collections.emptyList(), Collections.emptyList(), getJobId(), null,
false, token);
flagStatsJobId = flagStatsJobResult.first().getId();
Expand All @@ -137,7 +138,7 @@ protected void run() throws ToolException {
.toParams(new ObjectMap(ParamConstants.STUDY_PARAM, study));

OpenCGAResult<Job> statsJobResult = catalogManager.getJobManager()
.submit(study, AlignmentStatsAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
.submit(study, JobType.NATIVE, AlignmentStatsAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
+ getId() + " - " + getJobId(), Collections.emptyList(), Collections.emptyList(), getJobId(), null,
false, token);
statsJobId = statsJobResult.first().getId();
Expand All @@ -154,7 +155,7 @@ protected void run() throws ToolException {
.toParams(new ObjectMap(ParamConstants.STUDY_PARAM, study));

OpenCGAResult<Job> fastQcMetricsJobResult = catalogManager.getJobManager()
.submit(study, AlignmentFastQcMetricsAnalysis.ID, Enums.Priority.MEDIUM, params, null,
.submit(study, JobType.NATIVE, AlignmentFastQcMetricsAnalysis.ID, Enums.Priority.MEDIUM, params, null,
"Job generated by " + getId() + " - " + getJobId(), Collections.emptyList(), Collections.emptyList(),
getJobId(), null, false, token);
fastQcMetricsJobId = fastQcMetricsJobResult.first().getId();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
package org.opencb.opencga.analysis.customTool;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.opencb.opencga.analysis.tools.OpenCgaToolScopeStudy;
import org.opencb.opencga.core.common.TimeUtils;
import org.opencb.opencga.core.exceptions.ToolException;
import org.opencb.opencga.core.models.common.Enums;
import org.opencb.opencga.core.models.job.JobToolBuildParams;
import org.opencb.opencga.core.tools.annotations.Tool;
import org.opencb.opencga.core.tools.annotations.ToolParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;

@Tool(id = CustomToolBuilder.ID, resource = Enums.Resource.JOB, description = CustomToolBuilder.DESCRIPTION)
public class CustomToolBuilder extends OpenCgaToolScopeStudy {

public static final String ID = "custom-tool-builder";
public static final String DESCRIPTION = "Build an external bioinformatic tool from a GitHub repository URL.";

private static final String PYTHON_SCRIPT_NAME = "custom-tool-docker-build.py";

@ToolParams
protected JobToolBuildParams toolBuildParams = new JobToolBuildParams();

private final static Logger logger = LoggerFactory.getLogger(CustomToolBuilder.class);

@Override
protected void check() throws Exception {
super.check();

// Check any condition
if (toolBuildParams == null) {
throw new ToolException("Missing toolBuildParams");
}
if (StringUtils.isEmpty(toolBuildParams.getGitRepository())) {
throw new ToolException("Missing Git repository URL");
}
if (toolBuildParams.getDocker() == null
|| StringUtils.isEmpty(toolBuildParams.getDocker().getOrganisation())
|| StringUtils.isEmpty(toolBuildParams.getDocker().getName())
|| StringUtils.isEmpty(toolBuildParams.getDocker().getTag())
|| StringUtils.isEmpty(toolBuildParams.getDocker().getUser())
|| StringUtils.isEmpty(toolBuildParams.getDocker().getPassword())
) {
throw new ToolException("Missing Docker parameters, please provide the organisation, name, tag, user and password");
}
logger.debug("Checking finished, all seems fine");
}

@Override
protected void run() throws Exception {
// Build CLI params
StringBuilder cliBuilder = new StringBuilder();

// 1. Get the path to the custom-tool-docker-builder script
Path customToolDockerBuilderPath = this.getOpencgaHome()
.resolve("cloud")
.resolve("docker")
.resolve("custom-tool-docker-builder")
.resolve(PYTHON_SCRIPT_NAME);
logger.info("Executing custom-tool-docker-builder script: {}", customToolDockerBuilderPath);

// 2. Prepare basic CLI params
cliBuilder.append("python3").append(" ")
.append(customToolDockerBuilderPath).append(" ")
.append("push").append(" ")
.append("-t").append(" ").append(toolBuildParams.getGitRepository()).append(" ")
.append("-o").append(" ").append(toolBuildParams.getDocker().getOrganisation()).append(" ")
.append("-n").append(" ").append(toolBuildParams.getDocker().getName()).append(" ")
.append("-v").append(" ").append(toolBuildParams.getDocker().getTag()).append(" ")
.append("-u").append(" ").append(toolBuildParams.getDocker().getUser()).append(" ")
.append("-p").append(" ").append(toolBuildParams.getDocker().getPassword()).append(" ");

// 3. Check if 'apt-get' is provided
if (StringUtils.isNotEmpty(toolBuildParams.getAptGet())) {
cliBuilder.append("--apt-get").append(" ").append(toolBuildParams.getAptGet()).append(" ");
}

// 4. Check if 'installR' is provided
if (toolBuildParams.getInstallR() != null && toolBuildParams.getInstallR()) {
cliBuilder.append("--install-r").append(" ");
}

// 5. Execute the script
logger.info("CLI params: {}", cliBuilder);
// 5.1 Split the CLI params into a list
List<String> cliArgs = Arrays.asList(StringUtils.split(cliBuilder.toString(), " "));

// 5.2 Statr the stop watch
StopWatch stopWatch = StopWatch.createStarted();

// 5.3 Execute Python CLI
ProcessBuilder processBuilder = new ProcessBuilder(cliArgs);

// 5.4 Set the working directory of the process
processBuilder.directory(getOutDir().toFile());

// 5.5 Start execution
logger.info("Executing: {}", cliBuilder);
Process p;
try {
p = processBuilder.start();
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream()));
String line;
while ((line = input.readLine()) != null) {
logger.info("{}", line);
}
while ((line = error.readLine()) != null) {
logger.error("{} ", line);
}
p.waitFor();
input.close();
} catch (IOException | InterruptedException e) {
throw new RuntimeException("Error executing cli: " + e.getMessage(), e);
}
logger.info("Execution time: {}", TimeUtils.durationToString(stopWatch));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package org.opencb.opencga.analysis.customTool;

import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.time.StopWatch;
import org.opencb.opencga.analysis.tools.OpenCgaDockerToolScopeStudy;
import org.opencb.opencga.core.common.TimeUtils;
import org.opencb.opencga.core.exceptions.ToolException;
import org.opencb.opencga.core.models.common.Enums;
import org.opencb.opencga.core.models.job.JobRunDockerParams;
import org.opencb.opencga.core.models.job.JobRunParams;
import org.opencb.opencga.core.models.job.ToolInfoExecutor;
import org.opencb.opencga.core.tools.annotations.Tool;
import org.opencb.opencga.core.tools.annotations.ToolParams;
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 {

public final static String ID = "custom-tool";
public static final String DESCRIPTION = "Execute an analysis from a custom binary.";

@ToolParams
protected JobRunParams runParams = new JobRunParams();

private String cliParams;
private String dockerImage;

private final static Logger logger = LoggerFactory.getLogger(CustomToolExecutor.class);

@Override
protected void check() throws Exception {
super.check();

// Check any condition
if (runParams == null) {
throw new ToolException("Missing runParams");
}
if (StringUtils.isEmpty(runParams.getCommandLine())) {
throw new ToolException("Missing commandLine");
}
if (runParams.getDocker() == null || StringUtils.isEmpty(runParams.getDocker().getId())) {
runParams.setDocker(new JobRunDockerParams("opencb/opencga-ext-tools", "3.2.1", null));
}
if (!runParams.getDocker().getId().contains("/")) {
throw new ToolException("Missing repository organization. Format for the docker image should be 'organization/image'");
}
this.dockerImage = runParams.getDocker().getId();
if (StringUtils.isNotEmpty(runParams.getDocker().getTag())) {
this.dockerImage += ":" + runParams.getDocker().getTag();
}

// Update job tags and attributes
ToolInfoExecutor toolInfoExecutor = new ToolInfoExecutor(runParams.getDocker().getId(), runParams.getDocker().getTag());
List<String> tags = new LinkedList<>();
tags.add(ID);
tags.add(this.dockerImage);
updateJobInformation(tags, toolInfoExecutor);

StringBuilder cliParamsBuilder = new StringBuilder();
processInputParams(runParams.getCommandLine(), cliParamsBuilder);
this.cliParams = cliParamsBuilder.toString();
}

@Override
protected void run() throws Exception {
StopWatch stopWatch = StopWatch.createStarted();

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));
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.opencb.opencga.core.models.common.Enums;
import org.opencb.opencga.core.models.file.*;
import org.opencb.opencga.core.models.job.Job;
import org.opencb.opencga.core.models.job.JobType;
import org.opencb.opencga.core.response.OpenCGAResult;
import org.opencb.opencga.core.tools.annotations.Tool;
import org.opencb.opencga.core.tools.annotations.ToolParams;
Expand Down Expand Up @@ -68,7 +69,7 @@ protected void run() throws Exception {
Map<String, Object> params = new PostLinkToolParams(postLinkFileIds, null)
.toParams(new ObjectMap(ParamConstants.STUDY_PARAM, study));
Job postLinkJob = catalogManager.getJobManager()
.submit(getStudy(), PostLinkSampleAssociation.ID, Enums.Priority.MEDIUM, params, null,
.submit(getStudy(), JobType.NATIVE, PostLinkSampleAssociation.ID, Enums.Priority.MEDIUM, params, null,
"Job generated by " + getId() + " - " + getJobId(), Collections.emptyList(), Collections.emptyList(),
getJobId(), null, false, getToken()).first();
logger.info("Submit post-link job : " + postLinkJob.getId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import org.opencb.opencga.core.models.common.Enums;
import org.opencb.opencga.core.models.file.File;
import org.opencb.opencga.core.models.job.Job;
import org.opencb.opencga.core.models.job.JobType;
import org.opencb.opencga.core.models.sample.Sample;
import org.opencb.opencga.core.models.sample.SampleQualityControl;
import org.opencb.opencga.core.models.sample.SampleUpdateParams;
Expand Down Expand Up @@ -224,7 +225,7 @@ protected void run() throws ToolException {
.toParams(new ObjectMap(ParamConstants.STUDY_PARAM, getStudy()));

OpenCGAResult<Job> variantStatsJobResult = catalogManager.getJobManager()
.submit(study, SampleVariantStatsAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
.submit(study, JobType.NATIVE, SampleVariantStatsAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
+ getId() + " - " + getJobId(), Collections.emptyList(), Collections.emptyList(), getJobId(), null,
false, token);
variantStatsJobId = variantStatsJobResult.first().getId();
Expand Down Expand Up @@ -267,7 +268,7 @@ protected void run() throws ToolException {
.toParams(new ObjectMap(ParamConstants.STUDY_PARAM, getStudy()));

OpenCGAResult<Job> signatureJobResult = catalogManager.getJobManager()
.submit(getStudy(), MutationalSignatureAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
.submit(getStudy(), JobType.NATIVE, MutationalSignatureAnalysis.ID, Enums.Priority.MEDIUM, params, null, "Job generated by "
+ getId() + " - " + getJobId(), Collections.emptyList(), Collections.emptyList(), getJobId(), null,
false, token);
signatureJobId = signatureJobResult.first().getId();
Expand All @@ -289,7 +290,7 @@ protected void run() throws ToolException {
.toParams(new ObjectMap(ParamConstants.STUDY_PARAM, getStudy()));

OpenCGAResult<Job> genomePlotJobResult = catalogManager.getJobManager()
.submit(getStudy(), GenomePlotAnalysis.ID, Enums.Priority.MEDIUM, params, null,
.submit(getStudy(), JobType.NATIVE, GenomePlotAnalysis.ID, Enums.Priority.MEDIUM, params, null,
"Job generated by " + getId() + " - " + getJobId(), Collections.emptyList(), Collections.emptyList(),
getJobId(), null, false, token);
genomePlotJobId = genomePlotJobResult.first().getId();
Expand Down
Loading