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';
14 import { PROCESS_NAME_VALIDATION } from 'validators/validators';
16 export const RUN_PROCESS_ADVANCED_FORM = 'runProcessAdvancedForm';
18 export const DESCRIPTION_FIELD = 'description';
19 export const OUTPUT_FIELD = 'output';
20 export const RUNTIME_FIELD = 'runtime';
21 export const RAM_FIELD = 'ram';
22 export const VCPUS_FIELD = 'vcpus';
23 export const KEEP_CACHE_RAM_FIELD = 'keep_cache_ram';
24 export const RUNNER_IMAGE_FIELD = 'acr_container_image';
26 export interface RunProcessAdvancedFormData {
27 [DESCRIPTION_FIELD]?: string;
28 [OUTPUT_FIELD]?: string;
29 [RUNTIME_FIELD]?: number;
31 [VCPUS_FIELD]: number;
32 [KEEP_CACHE_RAM_FIELD]: number;
33 [RUNNER_IMAGE_FIELD]: string;
36 export const RunProcessAdvancedForm =
37 reduxForm<RunProcessAdvancedFormData>({
38 form: RUN_PROCESS_ADVANCED_FORM,
41 <ExpansionPanel elevation={0}>
42 <ExpansionPanelSummary style={{ padding: 0 }} expandIcon={<ExpandIcon />}>
44 </ExpansionPanelSummary>
45 <ExpansionPanelDetails style={{ padding: 0 }}>
46 <Grid container spacing={32}>
47 <Grid item xs={12} md={6}>
49 name={DESCRIPTION_FIELD}
50 component={TextField as any}
51 label="Optional description" />
53 <Grid item xs={12} md={6}>
56 component={TextField as any}
57 label="Output name" />
59 <Grid item xs={12} md={6}>
62 component={TextField as any}
63 helperText="Maximum running time (in seconds) that this container will be allowed to run before being cancelled."
65 parse={IntInput.parse}
66 format={IntInput.format}
68 validate={runtimeValidation} />
70 <Grid item xs={12} md={6}>
73 component={TextField as any}
75 helperText="Number of ram bytes to be used to run this process."
76 parse={IntInput.parse}
77 format={IntInput.format}
80 validate={ramValidation} />
82 <Grid item xs={12} md={6}>
85 component={TextField as any}
87 helperText="Number of cores to be used to run this process."
88 parse={IntInput.parse}
89 format={IntInput.format}
92 validate={vcpusValidation} />
94 <Grid item xs={12} md={6}>
96 name={KEEP_CACHE_RAM_FIELD}
97 component={TextField as any}
98 label="Keep cache RAM"
99 helperText="Number of keep cache bytes to be used to run this process."
100 parse={IntInput.parse}
101 format={IntInput.format}
103 validate={keepCacheRamValidation} />
105 <Grid item xs={12} md={6}>
107 name={RUNNER_IMAGE_FIELD}
108 component={TextField as any}
111 helperText='The container image with arvados-cwl-runner that will execute this workflow.' />
114 </ExpansionPanelDetails>
118 const ramValidation = [min(0)];
119 const vcpusValidation = [min(1)];
120 const keepCacheRamValidation = [optional(min(0))];
121 const runtimeValidation = [optional(min(1))];