Skip to content

Commit 807fab5

Browse files
committed
add option to Include Output
1 parent edea10e commit 807fab5

File tree

5 files changed

+51
-9
lines changed

5 files changed

+51
-9
lines changed

jupyter_scheduler/models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Notification(BaseModel):
2424

2525
send_to: List[str]
2626
events: List[NotificationEvent]
27-
include_preview: bool = False
27+
include_output: bool
2828

2929

3030
class RuntimeEnvironment(BaseModel):

src/components/notification-picker.tsx

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React, { useState, useCallback } from 'react';
22

33
import { Cluster } from './cluster';
44
import {
5+
Checkbox,
56
Chip,
67
FormControl,
78
FormControlLabel,
@@ -38,6 +39,9 @@ export function NotificationPicker({
3839
const [sendToInput, setSendToInput] = useState<string>(
3940
model.notification?.sendTo?.join(', ') || ''
4041
);
42+
const [includeOutput, setIncludeOutput] = useState<boolean>(
43+
model.notification?.includeOutput || false
44+
);
4145

4246
const enableNotificationChange = (e: React.ChangeEvent<HTMLInputElement>) => {
4347
const updatedEnableNotification = e.target.checked;
@@ -73,7 +77,7 @@ export function NotificationPicker({
7377
setSendToInput(e.target.value);
7478
}, []);
7579

76-
const handleBlur = useCallback(() => {
80+
const blur = useCallback(() => {
7781
const emailArray = sendToInput
7882
.split(',')
7983
.map(email => email.trim())
@@ -82,16 +86,28 @@ export function NotificationPicker({
8286
modelChange({ ...model, notification: updatedNotification });
8387
}, [sendToInput, model, modelChange]);
8488

85-
const handleKeyDown = useCallback(
89+
const keyDown = useCallback(
8690
(e: React.KeyboardEvent) => {
8791
if (e.key === 'Enter') {
8892
e.preventDefault();
89-
handleBlur();
93+
blur();
9094
}
9195
},
92-
[handleBlur]
96+
[blur]
9397
);
9498

99+
const includeOutputChange = (event: React.ChangeEvent<HTMLInputElement>) => {
100+
const updatedValue = event.target.checked;
101+
setIncludeOutput(updatedValue);
102+
modelChange({
103+
...model,
104+
notification: {
105+
...model.notification,
106+
includeOutput: updatedValue
107+
}
108+
});
109+
};
110+
95111
const deleteSelectedEvent = useCallback(
96112
(eventToDelete: string) => () => {
97113
const updatedEvents = selectedEvents.filter(
@@ -122,15 +138,14 @@ export function NotificationPicker({
122138
}
123139
label={trans.__('Enable Notifications')}
124140
/>
125-
126141
<TextField
127142
label={trans.__('Send To')}
128143
value={sendToInput}
129144
name="sendTo"
130145
variant="outlined"
131146
onChange={sendToChange}
132-
onBlur={handleBlur}
133-
onKeyDown={handleKeyDown}
147+
onBlur={blur}
148+
onKeyDown={keyDown}
134149
disabled={!enableNotification}
135150
/>
136151
<NotificationEventsSelect
@@ -146,6 +161,16 @@ export function NotificationPicker({
146161
deleteSelectedEvent={deleteSelectedEvent}
147162
disabled={!enableNotification}
148163
/>
164+
<FormControlLabel
165+
control={
166+
<Checkbox
167+
checked={includeOutput}
168+
onChange={includeOutputChange}
169+
disabled={!enableNotification}
170+
/>
171+
}
172+
label={trans.__('Include Output')}
173+
/>
149174
</Stack>
150175
);
151176
}

src/handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ export namespace Scheduler {
404404
export interface INotification {
405405
send_to: string[];
406406
events: string[];
407-
include_preview: boolean;
407+
include_output: boolean;
408408
}
409409

410410
export interface ICreateJob {

src/mainviews/create-job.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ export function CreateJob(props: ICreateJobProps): JSX.Element {
327327
jobOptions.parameters = serializeParameters(props.model.parameters);
328328
}
329329

330+
if (props.model.notification?.enableNotification) {
331+
jobOptions.notification = {
332+
send_to: props.model.notification.sendTo ?? [],
333+
events: props.model.notification.selectedEvents ?? [],
334+
include_output: props.model.notification.includeOutput ?? false
335+
};
336+
}
337+
330338
props.handleModelChange({
331339
...props.model,
332340
createError: undefined,
@@ -374,6 +382,14 @@ export function CreateJob(props: ICreateJobProps): JSX.Element {
374382
);
375383
}
376384

385+
if (props.model.notification?.enableNotification) {
386+
jobDefinitionOptions.notification = {
387+
send_to: props.model.notification.sendTo ?? [],
388+
events: props.model.notification.selectedEvents ?? [],
389+
include_output: props.model.notification.includeOutput ?? false
390+
};
391+
}
392+
377393
props.handleModelChange({
378394
...props.model,
379395
createError: undefined,

src/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ export type ModelWithScheduleFields = {
7676

7777
export type Notification = {
7878
sendTo?: string[];
79+
includeOutput?: boolean;
7980
enableNotification?: boolean;
8081
availableEvents?: string[];
8182
selectedEvents?: string[];

0 commit comments

Comments
 (0)