Skip to main content

Notebook Engine profiles

Notebook Engine profiles extend the common profile fields with storage constraints and Git repository sync settings. For background on how profiles work, see Engine profiles.

Profile fields

The following table lists the fields specific to Notebook Engine profiles. For shared fields (CPU, GPU, memory, timeouts, and OIDC roles), see the shared profile fields table.

FieldRequiredTypeDescription
storage_bytes_constraintRequiredNumeric constraintAllowed range for persistent storage allocated to the notebook engine
sync_git_repository_enabledOptionalBooleanWhether to sync a Git repository when the engine starts
git_repositoryOptionalStringThe Git repository URL to clone
git_refOptionalStringThe branch, tag, or commit hash to check out. Defaults to HEAD
git_directory_nameOptionalStringThe directory name in the user's home directory where the repository is synced. Defaults to Example

Git repository sync

Administrators can configure automatic Git repository synchronization through Notebook Engine profiles. When sync_git_repository_enabled is turned on, new notebook engines clone the specified repository into the user's home directory. This is useful for distributing shared notebooks, example code, or starter templates.

info

The Git repository must be accessible from within the Kubernetes cluster. If the repository requires authentication, make sure the cluster is configured with the appropriate credentials before turning on Git sync.

Manage Notebook Engine profiles with the Python client

For installation instructions, see Python client installation.

List available profiles

To list profiles assigned to you based on your OIDC roles:

import h2o_engine_manager

aiem = h2o_engine_manager.login()
notebook_engine_profile_client = aiem.notebook_engine_profile_client

profiles = notebook_engine_profile_client.list_all_assigned_notebook_engine_profiles(
parent="workspaces/global"
)
for profile in profiles:
print(f"{profile.name}: {profile.display_name}")

Create a profile (administrator)

from h2o_engine_manager.clients.notebook_engine_profile.profile import NotebookEngineProfile
from h2o_engine_manager.clients.constraint.profile_constraint_numeric import ProfileConstraintNumeric
from h2o_engine_manager.clients.constraint.profile_constraint_duration import ProfileConstraintDuration

profile = NotebookEngineProfile(
display_name="Data Analysis Team",
priority=1,
enabled=True,
assigned_oidc_roles_enabled=True,
assigned_oidc_roles=["data-analysis"],
max_running_engines=5,
cpu_constraint=ProfileConstraintNumeric(minimum="1", default="2", maximum="8"),
gpu_constraint=ProfileConstraintNumeric(minimum="0", default="0", maximum="1"),
memory_bytes_constraint=ProfileConstraintNumeric(
minimum="2Gi", default="4Gi", maximum="32Gi"
),
storage_bytes_constraint=ProfileConstraintNumeric(
minimum="5Gi", default="10Gi", maximum="100Gi"
),
max_idle_duration_constraint=ProfileConstraintDuration(
minimum="30m", default="2h", maximum="12h"
),
max_running_duration_constraint=ProfileConstraintDuration(
minimum="1h", default="8h", maximum="1d"
),
)

created = notebook_engine_profile_client.create_notebook_engine_profile(
parent="workspaces/global",
notebook_engine_profile=profile,
notebook_engine_profile_id="data-analysis",
)
print(f"Created profile: {created.name}")

Update a profile (administrator)

To update specific fields of an existing profile, retrieve it first, modify the fields, and pass an update_mask specifying which fields to update:

profile = notebook_engine_profile_client.get_notebook_engine_profile(
name="workspaces/global/notebookEngineProfiles/data-analysis"
)
profile.max_running_engines = 10

updated = notebook_engine_profile_client.update_notebook_engine_profile(
notebook_engine_profile=profile,
update_mask="max_running_engines",
)
print(f"Updated profile: {updated.name}")

Pass update_mask="*" to update all fields at once.

Delete a profile (administrator)

notebook_engine_profile_client.delete_notebook_engine_profile(
name="workspaces/global/notebookEngineProfiles/data-analysis"
)

Create an engine with a profile

Unlike the DAI and H2O clients, the Notebook Engine client requires a NotebookEngine object instead of individual keyword arguments.

from h2o_engine_manager.clients.notebook_engine.engine import NotebookEngine

profiles = notebook_engine_profile_client.list_all_assigned_notebook_engine_profiles(
parent="workspaces/global"
)
selected_profile = profiles[0]

engine = aiem.notebook_engine_client.create_notebook_engine(
parent="workspaces/default",
notebook_engine=NotebookEngine(
profile=selected_profile.name,
notebook_image="workspaces/global/notebookEngineImages/default",
display_name="My Notebook",
cpu=4,
gpu=0,
memory_bytes="8Gi",
storage_bytes="20Gi",
max_idle_duration="2h",
max_running_duration="8h",
),
notebook_engine_id="my-notebook",
)

Feedback