Notebooks
albert.collections.notebooks.NotebookCollection
Bases: BaseCollection
NotebookCollection manages Notebook entities in the Albert platform.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Attributes:
| Name | Type | Description |
|---|---|---|
base_path |
str
|
The base URL for notebook API requests. |
Methods:
| Name | Description |
|---|---|
get_by_id |
Retrieves a notebook by its ID. |
list_by_parent_id |
Lists notebooks for a given parent (task or project). |
create |
Creates or returns a notebook. |
delete |
Deletes a notebook by its ID. |
update |
Updates a notebook's name. |
update_block_content |
Updates the block content of a notebook. |
append_blocks |
Appends blocks to a notebook, preserving existing blocks. |
get_block_by_id |
Retrieves a notebook block by its ID. |
copy |
Copies a notebook into a specified parent. |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
AlbertSession
|
The Albert session instance. |
required |
Source code in src/albert/collections/notebooks.py
get_by_id
get_by_id(*, id: NotebookId) -> Notebook
Retrieve a Notebook by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the Notebook to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The Notebook object. |
Source code in src/albert/collections/notebooks.py
list_by_parent_id
Retrieve a Notebook by parent ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parent_id
|
str
|
The ID of the parent ID, e.g. task or project. |
required |
Returns:
| Type | Description |
|---|---|
list[Notebook]
|
list of notebook references. |
Source code in src/albert/collections/notebooks.py
create
Create or return notebook for the provided notebook. This endpoint automatically tries to find an existing notebook with the same parameter setpoints, and will either return the existing notebook or create a new one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook
|
Notebook
|
A list of Notebook entities to find or create. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
A list of created or found Notebook entities. |
Source code in src/albert/collections/notebooks.py
delete
delete(*, id: NotebookId) -> None
Deletes a notebook by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the notebook to delete. |
required |
Returns:
| Type | Description |
|---|---|
None
|
|
Source code in src/albert/collections/notebooks.py
update
Update a notebook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook
|
Notebook
|
The updated notebook object. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The updated notebook object as returned by the server. |
Notes
The following fields can be updated: name.
Source code in src/albert/collections/notebooks.py
update_block_content
Updates the block content of a Notebook. This does not update the notebook name (use .update for that). If a block in the Notebook does not already exist on Albert, it will be created. Note: The order of the Blocks in your Notebook matter and will be used in the updated Notebook!
Warning
Updating existing Ketcher blocks is not supported. To change a Ketcher block, delete it and create a new one instead.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook
|
Notebook
|
The updated notebook object. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The updated notebook object as returned by the server. |
Examples:
Add a Ketcher block from SMILES
Source code in src/albert/collections/notebooks.py
append_blocks
append_blocks(
*, id: NotebookId, blocks: list[NotebookBlock]
) -> Notebook
Append blocks to the end of a Notebook, preserving existing blocks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The ID of the Notebook to append to. |
required |
blocks
|
list[NotebookBlock]
|
The blocks to append to the end of the Notebook. |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The updated Notebook. |
Examples:
Append a paragraph block
Source code in src/albert/collections/notebooks.py
get_block_by_id
get_block_by_id(
*, notebook_id: NotebookId, block_id: str
) -> NotebookBlock
Retrieve a Notebook Block by its ID.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook_id
|
str
|
The ID of the Notebook to which the Block belongs. |
required |
block_id
|
str
|
The ID of the Notebook Block to retrieve. |
required |
Returns:
| Type | Description |
|---|---|
NotebookBlock
|
The NotebookBlock object. |
Source code in src/albert/collections/notebooks.py
copy
copy(
*,
notebook_copy_info: NotebookCopyInfo,
type: NotebookCopyType,
) -> Notebook
Create a copy of a Notebook into a specified parent
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
notebook_copy_info
|
NotebookCopyInfo
|
The copy information for the Notebook copy |
required |
type
|
NotebookCopyType
|
Differentiate whether copy is for templates, task, project or restoreTemplate |
required |
Returns:
| Type | Description |
|---|---|
Notebook
|
The result of the copied Notebook. |