Skip to navigation

Single Transfer: Unlimited Source

Transfer an entity into a container without drawing from a source container, using the entity itself as the source.

One of three transfer variants. This one has no source container; source_entity_id makes the entity itself the source, so nothing is decremented. See Introduction to Transfers for the concepts, and Source Container or Non-Empty Container for the variants that draw from a real container.

This example uses the V3 API through the V3 Python SDK.

container.transfer is stable, but unit.list, which this example uses to look up unit IDs, is beta. Set early_access="true" on the client, as below, or send the EARLY-ACCESS: true header on raw HTTP requests. See the V3 Stability Guidelines.

  1. Imports and config

    Import the SDK and the two input models this example needs, and read the tenant URL and API key from the environment rather than hard-coding them. Then initialize the client with early_access="true".

  2. Look up unit IDs

    V3 measurements name their unit by ID, not by a symbol like "mL". This helper looks a unit up by name with unit.list.

  3. Destination and source

    Both are fixed API IDs for demonstration. Neither needs fetching, because the source is an entity, not a container whose quantity has to be read.

  4. Perform the transfer

    The SingleTransferInput sets source_entity_id rather than source_container_id, which is what makes the source unlimited. source_concentration sets the entity’s concentration, here 25%. Because the destination is empty, it ends up holding the entity at 25%, as the V2 version of this recipe did. Leave source_concentration out and the concentration isn’t tracked. container.transfer starts an async task, and wait_for_task_response polls it until it finishes.

import os
from benchling_v3_sdk import Benchling, MeasurementInput, SingleTransferInput
TENANT_URL = os.environ.get("TENANT_URL")
API_KEY = os.environ.get("API_KEY")
benchling = Benchling(
base_url=TENANT_URL,
api_key=API_KEY,
early_access="true",
)
def unit_id(name):
return next(iter(benchling.unit.list(name_any_of=name))).id
destination = "con_TbU7UrgR"
source_entity = "prtn_tNciwmYB"
link = benchling.container.transfer(
transfers=[
SingleTransferInput(
destination_container_id=destination,
source_entity_id=source_entity,
transfer_quantity=MeasurementInput(value=5, unit_id=unit_id("milliliter")),
source_concentration=MeasurementInput(value=25, unit_id=unit_id("percent")),
)
]
)
benchling.wait_for_task_response(link)