Skip to content

Conversation

HarrySnart
Copy link
Member

Enhancement to create_notebook_session. Related to FR:1276

This enhancement adds the ability for users to use a flexible shape, by specifying ocpus and memory_in_gbs and also makes subnet_id optional. If no subnet_id is specified the notebook is provisioned with default networking. This has been unit tested locally with my own tenancy with the below tests:

from ads.catalog import notebook
notebook_catalog = NotebookCatalog(compartment_id = "ocid1...")

standard shape, specified subnet

test1 = notebook_catalog.create_notebook_session(display_name='dev-1',project_id='ocid1...',shape="VM.Standard2.1",block_storage_size_in_gbs=50,subnet_id='ocid1...')

standard shape, default netorking

test2 = notebook_catalog.create_notebook_session(display_name='dev-2',project_id='ocid1...',shape="VM.Standard2.1",block_storage_size_in_gbs=50)

flexible shape, specified subnet

test3 = notebook_catalog.create_notebook_session(display_name='dev-3',project_id='ocid1...',shape="VM.Standard.E4.Flex",ocpus = 2,memory_in_gbs = 16,block_storage_size_in_gbs=50,subnet_id='ocid1...')

flexible shape, default networking

test4 = notebook_catalog.create_notebook_session(display_name='dev-4',project_id='ocid1...',shape="VM.Standard.E4.Flex",ocpus = 2,memory_in_gbs = 16,block_storage_size_in_gbs=50)

All four notebook sessions have then been created successfully in my tenancy

Copy link

Thank you for your pull request and welcome to our community! To contribute, please sign the Oracle Contributor Agreement (OCA).
The following contributors of this PR have not signed the OCA:

To sign the OCA, please create an Oracle account and sign the OCA in Oracle's Contributor Agreement Application.

When signing the OCA, please provide your GitHub username. After signing the OCA and getting an OCA approval from Oracle, this PR will be automatically updated.

If you are an Oracle employee, please make sure that you are a member of the main Oracle GitHub organization, and your membership in this organization is public.

@oracle-contributor-agreement oracle-contributor-agreement bot added the OCA Required At least one contributor does not have an approved Oracle Contributor Agreement. label Sep 23, 2025
compartment_id=self.compartment_id,
notebook_session_configuration_details=notebook_session_configuration_details,
)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @HarrySnart for the PR. I was checking the difference between NotebookSessionConfigurationDetails and NotebookSessionConfigDetails, and it looks it their implementation is exactly the same - not sure why it is replicated. We can just use 1 of them to avoid any confusion. Also, we can simplify the notebook config creation with something like this:

        ...
        ...
        # build configuration kwargs
        config_kwargs = dict(
            shape=shape,
            block_storage_size_in_gbs=block_storage_size_in_gbs,
        )
        if subnet_id:
            config_kwargs["subnet_id"] = subnet_id
        if private_endpoint_id:
            config_kwargs["private_endpoint_id"] = private_endpoint_id
         if ocpus is not None and memory_in_gbs is not None:
            config_kwargs["notebook_session_shape_config_details"] = NotebookSessionShapeConfigDetails(ocpus=ocpus, memory_in_gbs=memory_in_gbs)

        # single config object
        notebook_cfg = NotebookSessionConfigurationDetails(**config_kwargs)

        # create request details
        create_notebook_details = CreateNotebookSessionDetails(
            display_name=display_name,
            project_id=project_id,
            compartment_id=self.compartment_id,
            notebook_session_configuration_details=notebook_cfg,  
        )
        try:
            create_notebook_response = self.ds_client.create_notebook_session(...
       ...
       ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OCA Required At least one contributor does not have an approved Oracle Contributor Agreement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants