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!
Przeglądaj źródła

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

pull/1/head
rodzic
commit
9979cb0b6f
2 zmienionych plików z 131 dodań i 51 usunięć
  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 Wyświetl plik

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


+ 15
- 3
frontend/src/js/page/wb-launch-workflow-page.js Wyświetl plik

@@ -17,6 +17,7 @@ class WBLaunchWorkflowPage extends Component {
this.browseDialogRef = createRef();
this.state.inputs = {};
this.state.errors = [];
this.state.placeInSubProject = true;
}
componentDidMount() {
@@ -46,7 +47,8 @@ class WBLaunchWorkflowPage extends Component {
const { arvHost, arvToken, currentUser } = app.state;
const { workflowDefinition, projectUuid,
processName, processDescription,
defaultProcessName, defaultProcessDescription } = this.state;
defaultProcessName, defaultProcessDescription,
placeInSubProject } = this.state;
const errors = [];
const inputs = wbParseWorkflowInputs(workflowDefinition,
@@ -61,7 +63,7 @@ class WBLaunchWorkflowPage extends Component {
processName: processName || defaultProcessName,
processDescription: processDescription || defaultProcessDescription,
projectUuid: projectUuid || currentUser.uuid,
workflowUuid, workflowDefinition
workflowUuid, workflowDefinition, placeInSubProject
}
wbDisableControls();
@@ -78,7 +80,7 @@ class WBLaunchWorkflowPage extends Component {
render({ app, workflowUuid },
{ workflow, workflowDefinition, projectUuid, processName, processDescription,
defaultProcessName, defaultProcessDescription, errors }) {
defaultProcessName, defaultProcessDescription, errors, placeInSubProject }) {
return (
<div>
@@ -116,6 +118,16 @@ class WBLaunchWorkflowPage extends Component {
) : null }
</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">
<label for="processName">Process Name</label>
<input type="text" class="form-control" id="processName"


Ładowanie…
Anuluj
Zapisz