Skip to content

Commit 6f8ff2b

Browse files
authored
Merge pull request #40 from jeffreylwang/feature/enable-public-ip-checkbox
Feature/enable public ip checkbox
2 parents 0d0bdc2 + be9385b commit 6f8ff2b

File tree

8 files changed

+4163
-4124
lines changed

8 files changed

+4163
-4124
lines changed

.yarnrc.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
1+
compressionLevel: mixed
2+
3+
enableGlobalCache: false
4+
15
nodeLinker: node-modules

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "scheduler-jupyter-plugin",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"description": "A JupyterLab extension.",
55
"keywords": [
66
"jupyter",

scheduler_jupyter_plugin/models/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class DescribeVertexJob(BaseModel):
8585
disk_type: str = None
8686
disk_size: str = None
8787
kms_key_name: Optional[str] = None
88+
enable_public_ip: Optional[bool] = True
8889

8990
@classmethod
9091
def from_dict(cls, data):
@@ -121,6 +122,7 @@ class DescribeUpdateVertexJob(BaseModel):
121122
disk_type: Optional[str] = None
122123
disk_size: Optional[str] = None
123124
kms_key_name: Optional[str] = None
125+
enable_public_ip: Optional[bool] = True
124126

125127
@classmethod
126128
def from_dict(cls, data):

scheduler_jupyter_plugin/services/vertex.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ async def create_schedule(self, job, file_path, bucket_name):
170170
]["networkSpec"]["network"] = job.network
171171
payload["createNotebookExecutionJobRequest"]["notebookExecutionJob"][
172172
"customEnvironmentSpec"
173-
]["networkSpec"]["enableInternetAccess"] = "TRUE"
173+
]["networkSpec"]["enableInternetAccess"] = "TRUE" if job.enable_public_ip else "FALSE"
174174
if job.subnetwork and job.network:
175175
payload["createNotebookExecutionJobRequest"]["notebookExecutionJob"][
176176
"customEnvironmentSpec"
@@ -524,6 +524,7 @@ async def update_schedule(self, region_id, schedule_id, input_data):
524524
custom_environment_spec["networkSpec"] = {
525525
"network": data.network,
526526
"subnetwork": data.subnetwork,
527+
"enableInternetAccess": "TRUE" if data.enable_public_ip else "FALSE",
527528
}
528529
if data.disk_size or data.disk_type:
529530
custom_environment_spec["persistentDiskSpec"] = {

src/scheduler/vertex/CreateVertexScheduler.tsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ import {
2828
FormControlLabel,
2929
Typography,
3030
Box,
31-
CircularProgress
31+
CircularProgress,
32+
Checkbox
3233
} from '@mui/material';
3334
import CalendarMonthIcon from '@mui/icons-material/CalendarMonth';
3435
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
@@ -195,6 +196,7 @@ const CreateVertexScheduler = ({
195196
network: string;
196197
subnetwork: string;
197198
} | null>(null);
199+
const [enablePublicIp, setEnablePublicIp] = useState<boolean>(true);
198200
const [maxRuns, setMaxRuns] = useState<string>('');
199201
const [scheduleField, setScheduleField] = useState<string>('');
200202
const [scheduleMode, setScheduleMode] = useState<scheduleMode>('runNow');
@@ -897,7 +899,8 @@ const CreateVertexScheduler = ({
897899
end_time: endDate,
898900
disk_type: diskTypeSelected,
899901
disk_size: diskSize,
900-
parameters: [] // Parameters for future scope
902+
parameters: [], // Parameters for future scope
903+
enable_public_ip: enablePublicIp
901904
};
902905

903906
if (acceleratorType && acceleratedCount) {
@@ -1070,6 +1073,7 @@ const CreateVertexScheduler = ({
10701073
setDiskTypeSelected(vertexSchedulerDetails.disk_type);
10711074
setDiskSize(vertexSchedulerDetails.disk_size);
10721075
setGcsPath(vertexSchedulerDetails.gcs_notebook_source ?? '');
1076+
setEnablePublicIp(vertexSchedulerDetails.enable_public_ip ?? true);
10731077

10741078
if ('kms_key_name' in vertexSchedulerDetails) {
10751079
if (vertexSchedulerDetails.kms_key_name) {
@@ -1869,6 +1873,27 @@ const CreateVertexScheduler = ({
18691873
)}
18701874
</>
18711875
)}
1876+
1877+
{/* Enable public IP checkbox - shown when custom network is configured */}
1878+
{(primaryNetworkSelected || sharedNetworkSelected) && (
1879+
<div className="create-scheduler-form-element">
1880+
<FormControlLabel
1881+
control={
1882+
<Checkbox
1883+
checked={enablePublicIp}
1884+
onChange={(e) => setEnablePublicIp(e.target.checked)}
1885+
disabled={editMode}
1886+
/>
1887+
}
1888+
label={
1889+
<Typography variant="body2">
1890+
Enable public IP (allows internet access)
1891+
</Typography>
1892+
}
1893+
/>
1894+
</div>
1895+
)}
1896+
18721897
<div className="create-scheduler-label">Schedule</div>
18731898
<div className="create-scheduler-form-element">
18741899
<FormControl>

src/scheduler/vertex/VertexInterfaces.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ export interface ICreatePayload {
5454
disk_size: string;
5555
gcs_notebook_source?: string;
5656
kms_key_name?: string;
57+
enable_public_ip?: boolean;
5758
}
5859
export interface IVertexScheduleList {
5960
displayName: string;

src/services/Vertex.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,13 @@ export class VertexServices {
680680
.diskSizeGb,
681681
gcs_notebook_source:
682682
formattedResponse.createNotebookExecutionJobRequest
683-
.notebookExecutionJob.gcsNotebookSource.uri
683+
.notebookExecutionJob.gcsNotebookSource.uri,
684+
enable_public_ip:
685+
formattedResponse.createNotebookExecutionJobRequest
686+
.notebookExecutionJob.customEnvironmentSpec?.networkSpec
687+
?.enableInternetAccess === 'TRUE'
688+
? true
689+
: false
684690
};
685691
setCreateCompleted(false);
686692
setRegion(region);

0 commit comments

Comments
 (0)