Skip to content

Commit

Permalink
Rework commit for exec and allocation
Browse files Browse the repository at this point in the history
  • Loading branch information
chandra-tacc committed Apr 17, 2024
1 parent c31bc64 commit ffaf67e
Show file tree
Hide file tree
Showing 8 changed files with 261 additions and 70 deletions.
89 changes: 49 additions & 40 deletions client/src/components/Applications/AppForm/AppForm.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ import {
getQueueValueForExecSystem,
getAppQueueValues,
matchExecSysWithAllocations,
getExecSystemsForPortalAllocation,
isAppUsingDynamicExecSystem,
} from './AppFormUtils';
import { getExecSystemFromId, getDefaultExecSystem } from 'utils/apps';

Expand Down Expand Up @@ -235,9 +237,9 @@ export const AppSchemaForm = ({ app }) => {
} = useSelector((state) => {
const matchingExecutionHostsMap = matchExecSysWithAllocations(
app,
state.allocations
state.allocations,
);
const execSystemsWithAllocation = [...matchingExecutionHostsMap.keys()];
const execSystemsWithAllocation = getExecSystemsForPortalAllocation(matchingExecutionHostsMap, state.allocations.portal_alloc);
const { defaultHost, configuration, defaultSystem } = state.systems.storage;

const keyService = state.systems.storage.configuration.find(
Expand Down Expand Up @@ -265,7 +267,7 @@ export const AppSchemaForm = ({ app }) => {
.filter((currSystem) => !currSystem.is_operational)
.map((downSys) => downSys.hostname)
: [],
execSystem: getDefaultExecSystem(app) ?? '',
execSystem: getDefaultExecSystem(app, execSystemsWithAllocation) ?? '',
defaultSystem,
keyService,
execSystemsWithAllocation,
Expand Down Expand Up @@ -294,8 +296,8 @@ export const AppSchemaForm = ({ app }) => {
const appFields = FormSchema(app);
const [currentValues, setCurrentValues] = useState({
execSys: execSystem,
allocations: execSystemAllocationsMap.get(execSystem.id) ?? [],
appQueueValues: getAppQueueValues(app, execSystem.batchLogicalQueues),
allocations: execSystemAllocationsMap.get(execSystem?.id) ?? [],
appQueueValues: getAppQueueValues(app, execSystem?.batchLogicalQueues),
});

const updateFormState = {
Expand Down Expand Up @@ -336,10 +338,9 @@ export const AppSchemaForm = ({ app }) => {

let missingAllocation = false;
if (app.definition.jobType === 'BATCH') {
initialValues.execSystemLogicalQueue = getQueueValueForExecSystem(
app,
getExecSystemFromId(app, app.definition.jobAttributes.execSystemId)
).name;
// Dynamic execution: For batch jobs, initial values comes from
// portal default allocation and stored in execSystem.
initialValues.execSystemId = execSystem?.id;
if (currentValues.allocations.includes(portalAlloc)) {
initialValues.allocation = portalAlloc;
} else {
Expand All @@ -348,6 +349,10 @@ export const AppSchemaForm = ({ app }) => {
? currentValues.allocations[0]
: '';
}
initialValues.execSystemLogicalQueue = getQueueValueForExecSystem(
app,
getExecSystemFromId(app, initialValues.execSystemId)
)?.name;
if (!hasDefaultAllocation && hasStorageSystems) {
jobSubmission.error = true;
jobSubmission.response = {
Expand All @@ -358,10 +363,12 @@ export const AppSchemaForm = ({ app }) => {
missingAllocation = true;
} else if (!currentValues.allocations.length) {
jobSubmission.error = true;
let message = 'You need access to at least one system and corressponding allocation to run this application.';
if (!isAppUsingDynamicExecSystem(app)) {
message = `You need an allocation on ${getSystemName(currentValues.execSys.host)} to run this application.`;
}
jobSubmission.response = {
message: `You need an allocation on ${getSystemName(
currentValues.execSys.host
)} to run this application.`,
message: message,
};
missingAllocation = true;
}
Expand Down Expand Up @@ -509,7 +516,7 @@ export const AppSchemaForm = ({ app }) => {
.required('Required'),
execSystemLogicalQueue: Yup.string()
.required('Required')
.oneOf(exec_sys.batchLogicalQueues.map((q) => q.name)),
.oneOf(exec_sys?.batchLogicalQueues.map((q) => q.name)??[]),
nodeCount: getNodeCountValidation(queue, app),
coresPerNode: getCoresPerNodeValidation(queue),
maxMinutes: getMaxMinutesValidation(queue).required('Required'),
Expand Down Expand Up @@ -736,28 +743,48 @@ export const AppSchemaForm = ({ app }) => {
<div className="appSchema-header">
<span>Configuration</span>
</div>
{app.execSystems &&
Object.keys(execSystemsWithAllocation).length > 1 && (
{app.definition.jobType === 'BATCH' &&
isAppUsingDynamicExecSystem(app) &&
execSystemsWithAllocation.length && (
<FormField
label="Execution System"
label="System"
name="execSystemId"
description="Select the system this job will execute on."
description="Select the system this job will execute on. The systems available to run the job is dependent on allocation."
type="select"
required
>
{execSystemsWithAllocation
.sort()
.map((exec_system_id) => (
<option key={exec_system_id} value={exec_system_id}>
{getSystemName(
getExecSystemFromId(app, exec_system_id)?.host
)}{' '}
: {exec_system_id} :{' '}
{getExecSystemFromId(app, exec_system_id)?.host}
{app.definition.notes?.dynamicExecSystems?.[
exec_system_id
] ??
getSystemName(
getExecSystemFromId(app, exec_system_id)?.host
)}
</option>
))}
</FormField>
)}
{app.definition.jobType === 'BATCH' && (
<FormField
label="Allocation"
name="allocation"
description="Select the project allocation you would like to use with this job submission. The allocations shown are dependent on the system selected above."
type="select"
required
>
<option hidden disabled>
{' '}
</option>
{currentValues.allocations.sort().map((projectId) => (
<option key={projectId} value={projectId}>
{projectId}
</option>
))}
</FormField>
)}
{app.definition.jobType === 'BATCH' && (
<FormField
label="Queue"
Expand Down Expand Up @@ -799,24 +826,6 @@ export const AppSchemaForm = ({ app }) => {
/>
</>
) : null}
{app.definition.jobType === 'BATCH' && (
<FormField
label="Allocation"
name="allocation"
description="Select the project allocation you would like to use with this job submission."
type="select"
required
>
<option hidden disabled>
{' '}
</option>
{currentValues.allocations.sort().map((projectId) => (
<option key={projectId} value={projectId}>
{projectId}
</option>
))}
</FormField>
)}
</div>
<div className="appSchema-section">
<div className="appSchema-header">
Expand Down

0 comments on commit ffaf67e

Please sign in to comment.