1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from 'react';
6 import { ExpansionPanel, ExpansionPanelDetails, ExpansionPanelSummary } from '@material-ui/core';
7 import { reduxForm, Field } from 'redux-form';
8 import { Grid } from '@material-ui/core';
9 import { TextField } from 'components/text-field/text-field';
10 import { ExpandIcon } from 'components/icon/icon';
11 import * as IntInput from './inputs/int-input';
12 import { min } from 'validators/min';
13 import { optional } from 'validators/optional';
15 export const RUN_PROCESS_ADVANCED_FORM = 'runProcessAdvancedForm';
17 export const OUTPUT_FIELD = 'output';
18 export const RUNTIME_FIELD = 'runtime';
19 export const RAM_FIELD = 'ram';
20 export const VCPUS_FIELD = 'vcpus';
21 export const KEEP_CACHE_RAM_FIELD = 'keep_cache_ram';
22 export const RUNNER_IMAGE_FIELD = 'acr_container_image';
24 export interface RunProcessAdvancedFormData {
25 [OUTPUT_FIELD]?: string;
26 [RUNTIME_FIELD]?: number;
28 [VCPUS_FIELD]: number;
29 [KEEP_CACHE_RAM_FIELD]: number;
30 [RUNNER_IMAGE_FIELD]: string;
33 export const RunProcessAdvancedForm =
34 reduxForm<RunProcessAdvancedFormData>({
35 form: RUN_PROCESS_ADVANCED_FORM,
38 <ExpansionPanel elevation={0}>
39 <ExpansionPanelSummary style={{ padding: 0 }} expandIcon={<ExpandIcon />}>
41 </ExpansionPanelSummary>
42 <ExpansionPanelDetails style={{ padding: 0 }}>
43 <Grid container spacing={4}>
44 <Grid item xs={12} md={6}>
47 component={TextField as any}
48 label="Output name" />
50 <Grid item xs={12} md={6}>
53 component={TextField as any}
54 helperText="Maximum running time (in seconds) that this container will be allowed to run before being cancelled."
56 parse={IntInput.parse}
57 format={IntInput.format}
59 validate={runtimeValidation} />
61 <Grid item xs={12} md={6}>
64 component={TextField as any}
66 helperText="Number of ram bytes to be used to run this process."
67 parse={IntInput.parse}
68 format={IntInput.format}
71 validate={ramValidation} />
73 <Grid item xs={12} md={6}>
76 component={TextField as any}
78 helperText="Number of cores to be used to run this process."
79 parse={IntInput.parse}
80 format={IntInput.format}
83 validate={vcpusValidation} />
85 <Grid item xs={12} md={6}>
87 name={KEEP_CACHE_RAM_FIELD}
88 component={TextField as any}
89 label="Keep cache RAM"
90 helperText="Number of keep cache bytes to be used to run this process."
91 parse={IntInput.parse}
92 format={IntInput.format}
94 validate={keepCacheRamValidation} />
96 <Grid item xs={12} md={6}>
98 name={RUNNER_IMAGE_FIELD}
99 component={TextField as any}
102 helperText='The container image with arvados-cwl-runner that will execute this workflow.' />
105 </ExpansionPanelDetails>
109 const ramValidation = [min(0)];
110 const vcpusValidation = [min(1)];
111 const keepCacheRamValidation = [optional(min(0))];
112 const runtimeValidation = [optional(min(1))];