22
22
CreateNotebookSessionDetails ,
23
23
NotebookSession ,
24
24
NotebookSessionConfigurationDetails ,
25
+ NotebookSessionConfigDetails ,
26
+ NotebookSessionShapeConfigDetails ,
25
27
)
26
28
from oci .exceptions import ServiceError
27
29
from types import MethodType
@@ -295,6 +297,8 @@ def create_notebook_session(
295
297
shape = None ,
296
298
block_storage_size_in_gbs = None ,
297
299
subnet_id = None ,
300
+ ocpus = None ,
301
+ memory_in_gbs = None ,
298
302
** kwargs ,
299
303
):
300
304
"""
@@ -310,11 +314,15 @@ def create_notebook_session(
310
314
The value to assign to the shape property of this NotebookSessionConfigurationDetails.
311
315
Allowed values for this property are: "VM.Standard.E2.2", "VM.Standard.E2.4",
312
316
"VM.Standard.E2.8", "VM.Standard2.1", "VM.Standard2.2", "VM.Standard2.4", "VM.Standard2.8",
313
- "VM.Standard2.16","VM.Standard2.24".
317
+ "VM.Standard2.16","VM.Standard2.24". Flexible shapes also supported but require addition of ocpus and memory_in_gbs parameters
314
318
block_storage_size_in_gbs: int, required
315
319
Size of the block storage drive. Limited to values between 50 (GB) and 1024 (1024GB = 1TB)
316
- subnet_id: str, required
317
- The OCID of the subnet resource where the notebook is to be created.
320
+ subnet_id: str, optional
321
+ The OCID of the subnet resource where the notebook is to be created. If no subnet_id is specified the session will use managed egress
322
+ ocpus: int, optional
323
+ OCPUs assigned to flexible shapes, such as VM.Standard.E4.Flex
324
+ memory_in_gbs: int, optional
325
+ memory (in GBs) assigned to flexible shapes, such as VM.Standard.E4.Flex
318
326
kwargs: dict, optional
319
327
Additional kwargs passed to `DataScienceClient.create_notebook_session()`
320
328
@@ -326,18 +334,66 @@ def create_notebook_session(
326
334
------
327
335
KeyError: If the resource was not found or do not have authorization to access that resource.
328
336
"""
329
- notebook_session_configuration_details = NotebookSessionConfigurationDetails (
330
- shape = shape ,
331
- block_storage_size_in_gbs = block_storage_size_in_gbs ,
332
- subnet_id = subnet_id ,
333
- )
337
+
334
338
project_id = PROJECT_OCID if project_id is None else project_id
335
- create_notebook_details = CreateNotebookSessionDetails (
336
- display_name = display_name ,
337
- project_id = project_id ,
338
- compartment_id = self .compartment_id ,
339
- notebook_session_configuration_details = notebook_session_configuration_details ,
340
- )
339
+
340
+ if ocpus and memory_in_gbs :
341
+ if subnet_id :
342
+ notebook_session_configuration_details = NotebookSessionConfigurationDetails (
343
+ shape = shape ,
344
+ block_storage_size_in_gbs = block_storage_size_in_gbs ,
345
+ subnet_id = subnet_id ,
346
+ notebook_session_shape_config_details = oci .data_science .models .NotebookSessionShapeConfigDetails (
347
+ ocpus = ocpus ,
348
+ memory_in_gbs = memory_in_gbs )
349
+ )
350
+ create_notebook_details = CreateNotebookSessionDetails (
351
+ display_name = display_name ,
352
+ project_id = project_id ,
353
+ compartment_id = self .compartment_id ,
354
+ notebook_session_configuration_details = notebook_session_configuration_details ,)
355
+
356
+ else :
357
+ notebook_session_configuration_details = NotebookSessionConfigDetails (
358
+ shape = shape ,
359
+ block_storage_size_in_gbs = block_storage_size_in_gbs ,
360
+ notebook_session_shape_config_details = oci .data_science .models .NotebookSessionShapeConfigDetails (
361
+ ocpus = ocpus ,
362
+ memory_in_gbs = memory_in_gbs )
363
+ )
364
+ create_notebook_details = CreateNotebookSessionDetails (
365
+ display_name = display_name ,
366
+ project_id = project_id ,
367
+ compartment_id = self .compartment_id ,
368
+ notebook_session_config_details = notebook_session_configuration_details ,
369
+ )
370
+
371
+
372
+ else :
373
+
374
+ if subnet_id :
375
+ notebook_session_configuration_details = NotebookSessionConfigurationDetails (
376
+ shape = shape ,
377
+ block_storage_size_in_gbs = block_storage_size_in_gbs ,
378
+ subnet_id = subnet_id ,
379
+ )
380
+ create_notebook_details = CreateNotebookSessionDetails (
381
+ display_name = display_name ,
382
+ project_id = project_id ,
383
+ compartment_id = self .compartment_id ,
384
+ notebook_session_configuration_details = notebook_session_configuration_details ,)
385
+ else :
386
+ notebook_session_configuration_details = NotebookSessionConfigDetails (
387
+ shape = shape ,
388
+ block_storage_size_in_gbs = block_storage_size_in_gbs ,
389
+ )
390
+ create_notebook_details = CreateNotebookSessionDetails (
391
+ display_name = display_name ,
392
+ project_id = project_id ,
393
+ compartment_id = self .compartment_id ,
394
+ notebook_session_config_details = notebook_session_configuration_details ,
395
+ )
396
+
341
397
try :
342
398
create_notebook_response = self .ds_client .create_notebook_session (
343
399
create_notebook_details , ** kwargs
0 commit comments