benchling.benchling
class
Benchling
Benchling object to interact with Benchling API through read and write type methods.
Attributes
ganymede_context : GanymedeContext
Ganymede context to get run attributes
benchling_context : BenchlingContext
Benchling context variable, which stores Benchling connection information
conn : benchling_sdk.benchling.Benchling
The benchling connection object
run_tag : str
Tag associated with flow run
custom_entity_service : CustomEntityService
Benchling custom entity service to create or update custom entities
molecule_service : MoleculeService _ defaults to None, initialized when first used
Benchling molecule service to create or update molecules
function
Benchling.init
Set up the Benchling object
Parameters
ganymede_context : GanymedeContext
Ganymede context to get run attributes
benchling_context : BenchlingContext | None
Benchling context variable, which stores Benchling connection information
function
Benchling.list_schemas
Lists schemas, filtered by type if provided
Parameters
type : str | None
Schema type - potential values are "custom_entity", "assay_result", "molecule", "plate",
"aa_sequence", "box", "container", "entry", "location", "mixture", "workflow_task", etc.
Returns
list[dict]
list of schemas
function
Benchling.get_schema_id_by_name
Get schema by name
Parameters
schema_name : str
Schema name
type : str | None
Subset search by schema type - potential values are "custom_entity", "assay_result", etc.
Returns
str
Schema ID for specified schema
function
Benchling.is_http_429_error
Check if the exception is a Benchling HTTP 429 (rate limit) error.
function
Benchling.create_or_update_custom_entity
Creates custom entity in Benchling. If the entity does not exist, first create it.
Parameters
entity_name : str
Name of new entity to be created
folder_id : str | Unset
Folder ID containing Benchling entity to be created. This should be a string starting
with "lib_". If updating a custom entity, specifying the folder ID is optional (if specified,
moves the custom entity to the specified folder).
schema_id : str | Unset
Input schema ID Tag. schema associated with Benchling entity to be created. This should
be a string starting with "ts_"
registry_id : str | Unset
Project associated with custom entity. This identifies the registry that your run
entity will be registered to. This can be found by clicking on Avatar - Feature
Settings - Registry Settings, and you will be able to find it in the URL. This should
be a string starting with "src_"
naming_strategy : NamingStrategy
Naming strategy to use when creating new entities. See NamingStrategy for more details.
custom_entity_fields : dict | Unset
Dictionary of field names and values to associate with custom entity
author_id : str | Unset
Author ID to associate with custom entity. Should be a string starting with "ent_"
if_exists : str
Either "fail" or "update". If "fail", will raise an error if the entity already exists.
Returns
dict[str, str]
Dictionary with custom entity name as key and custom entity ID as value
function
Benchling.create_or_update_custom_entities_bulk
Bulk creates custom entities in Benchling. If the entity does not exist, first create it.
Parameters
custom_entities_dataframe : pd.DataFrame
Dataframe containing custom entities to be created
Columns should include name_field and all fields in schema
name_field : str
Name of column in custom_entities_dataframe containing entity names
folder_id : str | None
Folder ID containing Benchling entity to be created. This should be a string starting
with "lib_". If updating a custom entity, specifying the folder ID is optional (if specified,
moves the custom entity to the specified folder).
schema_id : str
Input schema ID Tag. schema associated with Benchling entity to be created. This should
be a string starting with "ts_"
registry_id : str
Project associated with custom entity. This identifies the registry that your run
entity will be registered to.
naming_strategy : NamingStrategy
Naming strategy to use when creating new entities. See NamingStrategy for more details.
check_for_existing : bool
Whether or not to check for the existence of the entities in name_field
. This is useful to turn off when you know you'll be creating new entities (for example with many naming strategies) and want to avoid many api calls for checking existence of custom entities,
wait : bool
Whether to wait for the task to complete before returning
error_on_fail : bool
Whether to raise an error if the task fails
page_size_limit : int
Maximum number of entities Benchling will return in a single page. Default is 100
Returns
dict[str, list[str]]
Dictionary with keys "created" and "updated" and values of lists of custom entity IDs
function
Benchling.create_or_update_molecule
Creates molecule in Benchling. If the entity does not exist, first create it.