|
|
@@ -21,65 +21,133 @@ function wbParseWorkflowInputs(workflowDefinition, userInputs, errors) { |
|
|
|
return inputs;
|
|
|
|
}
|
|
|
|
|
|
|
|
function ensureSubProject(arvHost, arvToken, projectUuid) {
|
|
|
|
const filters = [
|
|
|
|
[ 'type', '=', 'project' ],
|
|
|
|
[ 'owner_uuid', '=', projectUuid ],
|
|
|
|
[ 'properties.type', '=', 'daily_process_subproject_container' ]
|
|
|
|
];
|
|
|
|
|
|
|
|
let prom = makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/groups?filters=' + encodeURIComponent(JSON.stringify(filters)));
|
|
|
|
|
|
|
|
prom = prom.then(xhr => {
|
|
|
|
if (xhr.response.items.length === 0) {
|
|
|
|
let prom_1 = new Promise(accept => accept());
|
|
|
|
prom_1 = prom_1.then(() => makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/groups', { method: 'POST',
|
|
|
|
data: { owner_uuid: projectUuid,
|
|
|
|
name: 'Container for daily sub-projects for processes',
|
|
|
|
properties: { type: 'daily_process_subproject_container' } } }));
|
|
|
|
prom_1 = prom_1.then(xhr_1 => xhr_1.response.uuid);
|
|
|
|
return prom_1;
|
|
|
|
}
|
|
|
|
return xhr.items[0].uuid;
|
|
|
|
});
|
|
|
|
|
|
|
|
let date = new Date();
|
|
|
|
date = (date.getYear() + 1900) + '-' +
|
|
|
|
('00' + (date.getMonth() + 1)).slice(-2) + '-' +
|
|
|
|
('00' + date.getDate()).slice(-2);
|
|
|
|
|
|
|
|
prom = prom.then(containerUuid => {
|
|
|
|
const filters_1 = [
|
|
|
|
[ 'type', '=', 'project'],
|
|
|
|
[ 'owner_uuid', '=', containerUuid ],
|
|
|
|
[ 'properties.type', '=', 'daily_process_subproject' ],
|
|
|
|
[ 'properties.date', '=', date ]
|
|
|
|
];
|
|
|
|
return makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/groups?filters=' + encodeURIComponent(JSON.stringify(filters_1)));
|
|
|
|
});
|
|
|
|
|
|
|
|
prom = prom.then(xhr => {
|
|
|
|
if (xhr.reponse.items.length === 0) {
|
|
|
|
let prom_1 = new Promise(accept => accept());
|
|
|
|
prom_1 = prom_1.then(() => makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/groups', { method: 'POST',
|
|
|
|
data: { owner_uuid: containerUuid,
|
|
|
|
name: 'Daily processes sub-project for ' + date,
|
|
|
|
properties: { type: 'daily_process_subproject', date } } }));
|
|
|
|
prom_1 = prom_1.then(xhr => xhr.response.uuid);
|
|
|
|
return prom_1;
|
|
|
|
}
|
|
|
|
return xhr.items[0].uuid;
|
|
|
|
});
|
|
|
|
return prom;
|
|
|
|
}
|
|
|
|
|
|
|
|
// params:
|
|
|
|
// arvHost, arvToken, inputs,
|
|
|
|
// projectUuid, workflowDefinition, workflowUuid
|
|
|
|
// processName, processDescription
|
|
|
|
// processName, processDescription, placeInSubProject
|
|
|
|
function wbSubmitContainerRequest(params) {
|
|
|
|
|
|
|
|
const { workflowDefinition, workflowUuid,
|
|
|
|
processName, processDescription, inputs,
|
|
|
|
arvHost, arvToken, projectUuid } = params;
|
|
|
|
|
|
|
|
// prepare a request
|
|
|
|
const req = {
|
|
|
|
name: processName,
|
|
|
|
description: processDescription,
|
|
|
|
owner_uuid: projectUuid,
|
|
|
|
container_image: 'arvados/jobs',
|
|
|
|
properties: {
|
|
|
|
template_uuid: workflowUuid
|
|
|
|
},
|
|
|
|
runtime_constraints: {
|
|
|
|
API: true,
|
|
|
|
vcpus: 1,
|
|
|
|
ram: 1073741824
|
|
|
|
},
|
|
|
|
cwd: '/var/spool/cwl',
|
|
|
|
command: [
|
|
|
|
'arvados-cwl-runner',
|
|
|
|
'--local',
|
|
|
|
'--api=containers',
|
|
|
|
'--project-uuid=' + projectUuid,
|
|
|
|
'--collection-cache-size=256',
|
|
|
|
'/var/lib/cwl/workflow.json#main',
|
|
|
|
'/var/lib/cwl/cwl.input.json'],
|
|
|
|
output_path: '/var/spool/cwl',
|
|
|
|
priority: 1,
|
|
|
|
state: 'Committed',
|
|
|
|
mounts: {
|
|
|
|
'stdout': {
|
|
|
|
kind: 'file',
|
|
|
|
path: '/var/spool/cwl/cwl.output.json'
|
|
|
|
},
|
|
|
|
'/var/spool/cwl': {
|
|
|
|
kind: 'collection',
|
|
|
|
writable: true
|
|
|
|
arvHost, arvToken,
|
|
|
|
placeInSubProject } = params;
|
|
|
|
|
|
|
|
let { projectUuid } = params;
|
|
|
|
|
|
|
|
let prom = new Promise(accept => accept());
|
|
|
|
|
|
|
|
if (placeInSubProject) {
|
|
|
|
prom = prom.then(() => ensureSubProject(arvHost, arvToken, projectUuid));
|
|
|
|
prom = prom.then(subProjUuid => (projectUuid = subProjUuid));
|
|
|
|
}
|
|
|
|
|
|
|
|
prom = prom.then(() => {
|
|
|
|
// prepare a request
|
|
|
|
const req = {
|
|
|
|
name: processName,
|
|
|
|
description: processDescription,
|
|
|
|
owner_uuid: projectUuid,
|
|
|
|
container_image: 'arvados/jobs',
|
|
|
|
properties: {
|
|
|
|
template_uuid: workflowUuid
|
|
|
|
},
|
|
|
|
'/var/lib/cwl/workflow.json': {
|
|
|
|
kind: 'json',
|
|
|
|
content: workflowDefinition
|
|
|
|
runtime_constraints: {
|
|
|
|
API: true,
|
|
|
|
vcpus: 1,
|
|
|
|
ram: 1073741824
|
|
|
|
},
|
|
|
|
'/var/lib/cwl/cwl.input.json': {
|
|
|
|
kind: 'json',
|
|
|
|
content: inputs
|
|
|
|
cwd: '/var/spool/cwl',
|
|
|
|
command: [
|
|
|
|
'arvados-cwl-runner',
|
|
|
|
'--local',
|
|
|
|
'--api=containers',
|
|
|
|
'--project-uuid=' + projectUuid,
|
|
|
|
'--collection-cache-size=256',
|
|
|
|
'/var/lib/cwl/workflow.json#main',
|
|
|
|
'/var/lib/cwl/cwl.input.json'],
|
|
|
|
output_path: '/var/spool/cwl',
|
|
|
|
priority: 1,
|
|
|
|
state: 'Committed',
|
|
|
|
mounts: {
|
|
|
|
'stdout': {
|
|
|
|
kind: 'file',
|
|
|
|
path: '/var/spool/cwl/cwl.output.json'
|
|
|
|
},
|
|
|
|
'/var/spool/cwl': {
|
|
|
|
kind: 'collection',
|
|
|
|
writable: true
|
|
|
|
},
|
|
|
|
'/var/lib/cwl/workflow.json': {
|
|
|
|
kind: 'json',
|
|
|
|
content: workflowDefinition
|
|
|
|
},
|
|
|
|
'/var/lib/cwl/cwl.input.json': {
|
|
|
|
kind: 'json',
|
|
|
|
content: inputs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const prom = makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/container_requests',
|
|
|
|
{ method: 'POST', data: JSON.stringify(req) });
|
|
|
|
return makeArvadosRequest(arvHost, arvToken,
|
|
|
|
'/arvados/v1/container_requests',
|
|
|
|
{ method: 'POST', data: JSON.stringify(req) });
|
|
|
|
});
|
|
|
|
|
|
|
|
return prom;
|
|
|
|
}
|
|
|
|