Skip to content

Commit 9ee337e

Browse files
committed
enable auto-teardown of instances with lab-sdk
1 parent 2ea008a commit 9ee337e

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

src/renderer/components/Experiment/Tasks/EditTaskModal.tsx

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ import Button from '@mui/joy/Button';
77
import FormControl from '@mui/joy/FormControl';
88
import FormLabel from '@mui/joy/FormLabel';
99
import Input from '@mui/joy/Input';
10-
import Textarea from '@mui/joy/Textarea';
1110
import {
1211
FormHelperText,
1312
ModalClose,
1413
ModalDialog,
1514
Sheet,
1615
Stack,
1716
Typography,
17+
Checkbox,
18+
Alert,
1819
} from '@mui/joy';
1920
import { FolderIcon } from 'lucide-react';
2021
import { Editor } from '@monaco-editor/react';
@@ -57,6 +58,7 @@ export default function EditTaskModal({
5758
const [accelerators, setAccelerators] = React.useState('');
5859
const [numNodes, setNumNodes] = React.useState('');
5960
const [setup, setSetup] = React.useState('');
61+
const [shutdownAfterCompletion, setShutdownAfterCompletion] = React.useState(false);
6062
const [saving, setSaving] = React.useState(false);
6163

6264
const setupEditorRef = useRef<any>(null);
@@ -74,6 +76,7 @@ export default function EditTaskModal({
7476
setAccelerators(cfg.accelerators != null ? String(cfg.accelerators) : '');
7577
setNumNodes(cfg.num_nodes != null ? String(cfg.num_nodes) : '');
7678
setSetup(cfg.setup != null ? String(cfg.setup) : '');
79+
setShutdownAfterCompletion(cfg.shutdown_after_completion || false);
7780
}, [task]);
7881

7982
// Keep Monaco editors in sync if the state changes after mount
@@ -156,6 +159,7 @@ export default function EditTaskModal({
156159
accelerators: accelerators || undefined,
157160
num_nodes: numNodes ? parseInt(numNodes, 10) : undefined,
158161
setup: setupValue || undefined,
162+
shutdown_after_completion: shutdownAfterCompletion,
159163
} as any;
160164

161165
const body = {
@@ -363,6 +367,26 @@ export default function EditTaskModal({
363367
</FormHelperText>
364368
</FormControl>
365369

370+
<FormControl sx={{ mt: 2 }}>
371+
<Checkbox
372+
checked={shutdownAfterCompletion}
373+
onChange={(e) => setShutdownAfterCompletion(e.target.checked)}
374+
label="Shutdown machine after execution"
375+
/>
376+
<FormHelperText>
377+
When enabled, the remote instance will be automatically shut
378+
down after the task completes.
379+
</FormHelperText>
380+
</FormControl>
381+
382+
{shutdownAfterCompletion && (
383+
<Alert color="warning" sx={{ mt: 1 }}>
384+
<strong>Warning:</strong> This will destroy all data on the
385+
remote machine that is not logged or saved elsewhere. Make sure
386+
to save any important results before the task completes.
387+
</Alert>
388+
)}
389+
366390
{/* Show uploaded directory indicator if present */}
367391
{task &&
368392
(() => {

src/renderer/components/Experiment/Tasks/Tasks.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,10 @@ export default function Tasks() {
270270
if (cfg.uploaded_dir_path)
271271
formData.append('uploaded_dir_path', String(cfg.uploaded_dir_path));
272272
if (cfg.shutdown_after_completion !== undefined)
273-
formData.append('shutdown_after_completion', String(cfg.shutdown_after_completion));
273+
formData.append(
274+
'shutdown_after_completion',
275+
String(cfg.shutdown_after_completion),
276+
);
274277

275278
return formData;
276279
};

0 commit comments

Comments
 (0)