IF YOU WOULD LIKE TO GET AN ACCOUNT, please write an email to s dot adaszewski at gmail dot com. User accounts are meant only to report issues and/or generate pull requests. This is a purpose-specific Git hosting for ADARED projects. Thank you for your understanding!
Browse Source

Started implementing running processes in automatically created sub-projects, needs testing.

pull/1/head
parent
commit
9979cb0b6f
2 changed files with 131 additions and 51 deletions
  1. +116
    -48
      frontend/src/js/arvados/process/wb-submit-container-request.js
  2. +15
    -3
      frontend/src/js/page/wb-launch-workflow-page.js

+ 116
- 48
frontend/src/js/arvados/process/wb-submit-container-request.js View File

@@ -21,65 +21,133 @@ function wbParseWorkflowInputs(workflowDefinition, userInputs, errors) {
return inputs; 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: // params:
// arvHost, arvToken, inputs, // arvHost, arvToken, inputs,
// projectUuid, workflowDefinition, workflowUuid // projectUuid, workflowDefinition, workflowUuid
// processName, processDescription
// processName, processDescription, placeInSubProject
function wbSubmitContainerRequest(params) { function wbSubmitContainerRequest(params) {
const { workflowDefinition, workflowUuid, const { workflowDefinition, workflowUuid,
processName, processDescription, inputs, 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; return prom;
} }


+ 15
- 3
frontend/src/js/page/wb-launch-workflow-page.js View File

@@ -17,6 +17,7 @@ class WBLaunchWorkflowPage extends Component {
this.browseDialogRef = createRef(); this.browseDialogRef = createRef();
this.state.inputs = {}; this.state.inputs = {};
this.state.errors = []; this.state.errors = [];
this.state.placeInSubProject = true;
} }
componentDidMount() { componentDidMount() {
@@ -46,7 +47,8 @@ class WBLaunchWorkflowPage extends Component {
const { arvHost, arvToken, currentUser } = app.state; const { arvHost, arvToken, currentUser } = app.state;
const { workflowDefinition, projectUuid, const { workflowDefinition, projectUuid,
processName, processDescription, processName, processDescription,
defaultProcessName, defaultProcessDescription } = this.state;
defaultProcessName, defaultProcessDescription,
placeInSubProject } = this.state;
const errors = []; const errors = [];
const inputs = wbParseWorkflowInputs(workflowDefinition, const inputs = wbParseWorkflowInputs(workflowDefinition,
@@ -61,7 +63,7 @@ class WBLaunchWorkflowPage extends Component {
processName: processName || defaultProcessName, processName: processName || defaultProcessName,
processDescription: processDescription || defaultProcessDescription, processDescription: processDescription || defaultProcessDescription,
projectUuid: projectUuid || currentUser.uuid, projectUuid: projectUuid || currentUser.uuid,
workflowUuid, workflowDefinition
workflowUuid, workflowDefinition, placeInSubProject
} }
wbDisableControls(); wbDisableControls();
@@ -78,7 +80,7 @@ class WBLaunchWorkflowPage extends Component {
render({ app, workflowUuid }, render({ app, workflowUuid },
{ workflow, workflowDefinition, projectUuid, processName, processDescription, { workflow, workflowDefinition, projectUuid, processName, processDescription,
defaultProcessName, defaultProcessDescription, errors }) {
defaultProcessName, defaultProcessDescription, errors, placeInSubProject }) {
return ( return (
<div> <div>
@@ -116,6 +118,16 @@ class WBLaunchWorkflowPage extends Component {
) : null } ) : null }
</div> </div>
<div class="form-check mb-3">
<input class="form-check-input" type="checkbox"
checked={ placeInSubProject ? 'checked' : null }
onchange={ e => (this.state.placeInSubProject = e.target.checked) }
id="placeInSubProject" />
<label class="form-check-label" for="placeInSubProject">
Place in a daily sub-project
</label>
</div>
<div class="form-group"> <div class="form-group">
<label for="processName">Process Name</label> <label for="processName">Process Name</label>
<input type="text" class="form-control" id="processName" <input type="text" class="form-control" id="processName"


Loading…
Cancel
Save