1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as 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 { SwitchField } from '~/components/switch-field/switch-field';
16 export const RUN_PROCESS_ADVANCED_FORM = 'runProcessAdvancedForm';
18 export const OUTPUT_FIELD = 'output';
19 export const RUNTIME_FIELD = 'runtime';
20 export const RAM_FIELD = 'ram';
21 export const VCPUS_FIELD = 'vcpus';
22 export const KEEP_CACHE_RAM_FIELD = 'keep_cache_ram';
23 export const API_FIELD = 'api';
25 export interface RunProcessAdvancedFormData {
26 [OUTPUT_FIELD]?: string;
27 [RUNTIME_FIELD]?: number;
29 [VCPUS_FIELD]: number;
30 [KEEP_CACHE_RAM_FIELD]?: number;
31 [API_FIELD]?: boolean;
34 export const RunProcessAdvancedForm =
35 reduxForm<RunProcessAdvancedFormData>({
36 form: RUN_PROCESS_ADVANCED_FORM,
39 <ExpansionPanel elevation={0}>
40 <ExpansionPanelSummary style={{ padding: 0 }} expandIcon={<ExpandIcon />}>
42 </ExpansionPanelSummary>
43 <ExpansionPanelDetails style={{ padding: 0 }}>
44 <Grid container spacing={32}>
45 <Grid item xs={12} md={6}>
49 label="Output name" />
51 <Grid item xs={12} md={6}>
55 helperText="Maximum running time (in seconds) that this container will be allowed to run before being cancelled."
57 parse={IntInput.parse}
58 format={IntInput.format}
60 validate={runtimeValidation} />
62 <Grid item xs={12} md={6}>
67 helperText="Number of ram bytes to be used to run this process."
68 parse={IntInput.parse}
69 format={IntInput.format}
72 validate={ramValidation} />
74 <Grid item xs={12} md={6}>
79 helperText="Number of cores to be used to run this process."
80 parse={IntInput.parse}
81 format={IntInput.format}
84 validate={vcpusValidation} />
86 <Grid item xs={12} md={6}>
88 name={KEEP_CACHE_RAM_FIELD}
90 label="Keep cache RAM"
91 helperText="Number of keep cache bytes to be used to run this process."
92 parse={IntInput.parse}
93 format={IntInput.format}
95 validate={keepCacheRamValidation} />
97 <Grid item xs={12} md={6}>
100 component={SwitchField}
105 helperText='When set, ARVADOS_API_HOST and ARVADOS_API_TOKEN will be set, and process will have networking enabled to access the Arvados API server.' />
108 </ExpansionPanelDetails>
112 const ramValidation = [min(0)];
113 const vcpusValidation = [min(1)];
114 const keepCacheRamValidation = [optional(min(0))];
115 const runtimeValidation = [optional(min(1))];