Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
35d5a90
partway through conversion
ecormany Aug 14, 2025
e9d1ae8
full conversion of article pages
ecormany Aug 14, 2025
0bc7f11
renamed files
ecormany Aug 14, 2025
8965869
mkdocs nav
ecormany Aug 15, 2025
a01a8e5
some fixups
ecormany Aug 15, 2025
60783eb
fix up Labware page
ecormany Aug 18, 2025
0a30a7d
some Labware changes
ecormany Aug 18, 2025
f8bfeb9
fix up through Modules landing page + find/replace link formatting
ecormany Aug 21, 2025
c237fcf
fixes through H-S
ecormany Aug 21, 2025
8ee7c27
more module page fixes
ecormany Aug 21, 2025
105e3a0
thermocycler changes
ecormany Aug 28, 2025
c4f2122
add mkdocstrings to docs dependencies
ecormany Aug 28, 2025
760cb90
moam and some of deck slots
ecormany Aug 29, 2025
410f223
rest of deck slots
ecormany Sep 2, 2025
86d4210
edits to loading pipettes; move files to building-block-commands dire…
ecormany Sep 2, 2025
8d9bb0d
fix up pipette characteristics page
ecormany Sep 2, 2025
ed3078d
update partial tip pickup
ecormany Sep 2, 2025
c9771fc
update volume modes
ecormany Sep 2, 2025
6d016a5
update liquid classes
ecormany Sep 2, 2025
bf755a2
liquid class tables, oh my
ecormany Sep 11, 2025
abd1997
building block up through touch tip
ecormany Sep 11, 2025
5d74409
finish building block liquid commands
ecormany Sep 12, 2025
3e7ec08
through complex commands
ecormany Sep 12, 2025
56e8c60
edit through robot position
ecormany Sep 12, 2025
b81199d
reorg RTP files
ecormany Sep 29, 2025
edf1db7
edits to RTP pages
ecormany Sep 29, 2025
9c93d5f
edit advanced control page
ecormany Sep 30, 2025
981aef4
update examples page
ecormany Sep 30, 2025
b3ee3d1
edit adapting page
ecormany Sep 30, 2025
4092be0
load editable opentrons package for ref
ecormany Sep 30, 2025
4da93e6
convert ProtocolContext docstrings to google style
ecormany Oct 1, 2025
d999f55
fix up doc headers and style
ecormany Oct 2, 2025
76d2b7f
api ref css improvements
ecormany Oct 2, 2025
2f52256
config: watch for changes in PAPI docstrings
ecormany Oct 2, 2025
2718f00
convert InstrumentContext docstrings through transfer()
ecormany Oct 2, 2025
a38093d
convert remaining InstrumentContext docstrings
ecormany Nov 3, 2025
9844eed
convert Labware docstrings up to load_liquid
ecormany Nov 3, 2025
72eae19
convert remaining Labware docstrings + WasteChute and TrashBin
ecormany Nov 4, 2025
9c1ced6
convert plate reader and general ModuleContext dostrings
ecormany Nov 4, 2025
fe4f92c
convert Stacker docstrings
ecormany Nov 4, 2025
4836578
convert H-S docstrings
ecormany Nov 4, 2025
84eb756
convert remaining module docstrings
ecormany Nov 5, 2025
86393a7
convert type docstrings
ecormany Nov 5, 2025
ad5e776
convert well and liquid docstrings
ecormany Nov 5, 2025
8572422
update execute and simulate docstrings; that's all of them!
ecormany Nov 5, 2025
c4fe61d
add title metadata and remove H1s
ecormany Nov 5, 2025
64766ee
first attempt at griffe extension for version numbers; functions only
ecormany Nov 7, 2025
0299153
griffe labels working for properties too (thx Seth)
ecormany Nov 7, 2025
6dfc6ac
remove print debugging in griffe script
ecormany Nov 10, 2025
221bcc9
convert RobotContext docstrings; hide docstrings throughout ref
ecormany Nov 10, 2025
bc6b5e9
fix links in API ref
ecormany Nov 10, 2025
8a20da1
split module ref entries into separate pages
ecormany Nov 10, 2025
7c6ebbf
fix up doc links
ecormany Nov 10, 2025
637b63c
fix ALL the warnings!
ecormany Nov 12, 2025
fc9f7a6
remove unused html and rst reference files
ecormany Nov 12, 2025
18eed6b
Merge branch 'edge' into what-if-no-sphinx-for-real
ecormany Nov 12, 2025
c34ee9f
convert docstrings affected by merging in current edge
ecormany Nov 12, 2025
c6b5788
fix a couple links; update makefile to work around mkdocs serve bug
ecormany Nov 13, 2025
9dfa04c
remove future dynamix mix link
ecormany Nov 13, 2025
ac7ecf7
content fixups for welcome, versioning, tutorial, labware
ecormany Nov 13, 2025
b936071
fix up moving labware
ecormany Nov 13, 2025
a484295
fix up modules through Absorbance Plate Reader; add Stacker page
ecormany Nov 13, 2025
61ca458
content fix ups through all modules
ecormany Nov 13, 2025
6918a3d
content fixups through pipette characteristics
ecormany Nov 13, 2025
4249805
fix up through all pipette pages
ecormany Nov 14, 2025
1244a23
content fix ups through building blocks
ecormany Nov 14, 2025
76ddce9
content fix ups for complex commands
ecormany Nov 14, 2025
1f69f8c
content fixups for order of operations
ecormany Nov 14, 2025
293d8da
content fix ups for complex command params
ecormany Nov 17, 2025
38ea9f6
content fix ups for robot position; delete Axis Speed Limits § as nev…
ecormany Nov 17, 2025
24f5576
content fix ups for runtime parameters
ecormany Nov 17, 2025
8a739a8
new content and refactor of advanced control into multiple pages
ecormany Nov 17, 2025
0bc3bdc
fix up examples through loops §
ecormany Nov 17, 2025
3d24c2d
content fix ups through all pages
ecormany Nov 18, 2025
0166300
sentence case headers
ecormany Nov 18, 2025
a59ec4b
add macros plugin for apiLevel replacement
ecormany Nov 18, 2025
0908114
Merge branch 'edge' into what-if-no-sphinx-for-real
ecormany Nov 18, 2025
56d83c1
fix bad previous conflict resolution; blacken
ecormany Nov 18, 2025
620f890
zap some double backticks
ecormany Nov 18, 2025
38eac04
now where did those come from?
ecormany Nov 18, 2025
4d75fbe
add black to format signatures; touch up ProtocolContext docstrings
ecormany Nov 19, 2025
03928df
fix up InstrumentContext docstrings
ecormany Nov 20, 2025
b958354
fix up RobotContext docstrings
ecormany Nov 20, 2025
0eba14a
fix up Labware docstrings
ecormany Nov 20, 2025
88a99ef
fix up Well and LiquidClass docstrings
ecormany Nov 20, 2025
d7c13c0
fix up all remaining docstrings
ecormany Nov 20, 2025
e28b0f0
the big one: move v2 -> python-api
ecormany Nov 20, 2025
fc3fdef
incoming cross-references; move api-reference -> reference for cleane…
ecormany Nov 20, 2025
4421397
opentrons dependency wasn't necessary
ecormany Nov 21, 2025
15f893d
or maybe it was, who can say
ecormany Nov 21, 2025
c2aa325
let's try the makefile instead
ecormany Nov 21, 2025
5d002df
none more black
ecormany Nov 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 107 additions & 94 deletions api/src/opentrons/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This module has functions that can be imported to provide protocol
contexts for running protocols during interactive sessions like Jupyter or just
regular python shells. It also provides a console entrypoint for running a
regular Python shells. It also provides a console entrypoint for running a
protocol from the command line.
"""
import asyncio
Expand Down Expand Up @@ -128,40 +128,43 @@ def get_protocol_api(
# *
) -> protocol_api.ProtocolContext:
"""
Build and return a ``protocol_api.ProtocolContext``
Build and return a `protocol_api.ProtocolContext`
connected to the robot.

This can be used to run protocols from interactive Python sessions
such as Jupyter or an interpreter on the command line:

.. code-block:: python

>>> from opentrons.execute import get_protocol_api
>>> protocol = get_protocol_api('2.0')
>>> instr = protocol.load_instrument('p300_single', 'right')
>>> instr.home()
```python
from opentrons.execute import get_protocol_api
protocol = get_protocol_api('2.0')
instr = protocol.load_instrument('p300_single', 'right')
instr.home()
```

When this function is called, modules and instruments will be recached.

:param version: The API version to use. This must be lower than
``opentrons.protocol_api.MAX_SUPPORTED_VERSION``.
It may be specified either as a string (``'2.0'``) or
as a ``protocols.types.APIVersion``
(``APIVersion(2, 0)``).
:param bundled_labware: If specified, a mapping from labware names to
labware definitions for labware to consider in the
protocol. Note that if you specify this, *only*
labware in this argument will be allowed in the
protocol. This is preparation for a beta feature
and is best not used.
:param bundled_data: If specified, a mapping from filenames to contents
for data to be available in the protocol from
:py:obj:`opentrons.protocol_api.ProtocolContext.bundled_data`.
:param extra_labware: A mapping from labware load names to custom labware definitions.
If this is ``None`` (the default), and this function is called on a robot,
it will look for labware in the ``labware`` subdirectory of the Jupyter
data directory.
:return: The protocol context.
Args:
version: The API version to use. This must be lower than
`opentrons.protocol_api.MAX_SUPPORTED_VERSION`.
It may be specified either as a string (`'2.0'`) or
as a [`APIVersion`][opentrons.protocols.api_support.types.APIVersion]
(`APIVersion(2, 0)`).
bundled_labware: If specified, a mapping from labware names to
labware definitions for labware to consider in the
protocol. Note that if you specify this, *only*
labware in this argument will be allowed in the
protocol. This is preparation for a beta feature
and is best not used.
bundled_data: If specified, a mapping from filenames to contents
for data to be available in the protocol from
[`bundled_data`][opentrons.protocol_api.ProtocolContext.bundled_data].
extra_labware: A mapping from labware load names to custom labware definitions.
If this is `None` (the default), and this function is called on a robot,
it will look for labware in the `labware` subdirectory of the Jupyter
data directory.

Returns:
The protocol context.
"""
if isinstance(version, str):
checked_version = parse.version_from_string(version)
Expand Down Expand Up @@ -212,13 +215,17 @@ def get_protocol_api(


def get_arguments(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
"""Get the argument parser for this module
"""
Get the argument parser for this module.

Useful if you want to use this module as a component of another CLI program
and want to add its arguments.

:param parser: A parser to add arguments to.
:returns argparse.ArgumentParser: The parser with arguments added.
Args:
parser: A parser to add arguments to.

Returns:
argparse.ArgumentParser: The parser with arguments added.
"""
parser.add_argument(
"-l",
Expand Down Expand Up @@ -302,70 +309,72 @@ def execute(
"""
Run the protocol itself.

This is a one-stop function to run a protocol, whether python or json,
no matter the api version, from external (i.e. not bound up in other
This is a one-stop function to run a protocol, whether Python or JSON,
no matter the API version, from external (i.e. not bound up in other
internal server infrastructure) sources.

To run an opentrons protocol from other places, pass in a file like
object as protocol_file; this function either returns (if the run has no
object as `protocol_file`; this function either returns (if the run has no
problems) or raises an exception.

To call from the command line use either the autogenerated entrypoint
``opentrons_execute`` or ``python -m opentrons.execute``.

:param protocol_file: The protocol file to execute
:param protocol_name: The name of the protocol file. This is required
internally, but it may not be a thing we can get
from the ``protocol_file`` argument.
:param propagate_logs: Whether this function should allow logs from the
Opentrons stack to propagate up to the root handler.
This can be useful if you're integrating this
function in a larger application, but most logs that
occur during protocol simulation are best associated
with the actions in the protocol that cause them.
Default: ``False``
:param log_level: The level of logs to emit on the command line:
``"debug"``, ``"info"``, ``"warning"``, or ``"error"``.
Defaults to ``"warning"``.
:param emit_runlog: A callback for printing the run log. If specified, this
will be called whenever a command adds an entry to the
run log, which can be used for display and progress
estimation. If specified, the callback should take a
single argument (the name doesn't matter) which will
be a dictionary:

.. code-block:: python

{
'name': command_name,
'payload': {
'text': string_command_text,
# The rest of this struct is
# command-dependent; see
# opentrons.legacy_commands.commands.
}
}

.. note::
In older software versions, ``payload["text"]`` was a
`format string <https://docs.python.org/3/library/string.html#formatstrings>`_.
To get human-readable text, you had to do ``payload["text"].format(**payload)``.
Don't do that anymore. If ``payload["text"]`` happens to contain any
``{`` or ``}`` characters, it can confuse ``.format()`` and cause it to raise a
``KeyError``.

:param custom_labware_paths: A list of directories to search for custom labware.
Loads valid labware from these paths and makes them available
to the protocol context. If this is ``None`` (the default), and
this function is called on a robot, it will look in the ``labware``
subdirectory of the Jupyter data directory.
:param custom_data_paths: A list of directories or files to load custom
data files from. Ignored if the apiv2 feature
flag if not set. Entries may be either files or
directories. Specified files and the
non-recursive contents of specified directories
are presented by the protocol context in
``ProtocolContext.bundled_data``.
`opentrons_execute` or `python -m opentrons.execute`.

Args:
protocol_file: The protocol file to execute.
protocol_name: The name of the protocol file. This is required
internally, but it may not be a thing we can get
from the `protocol_file` argument.
propagate_logs: Whether this function should allow logs from the
Opentrons stack to propagate up to the root handler.
This can be useful if you're integrating this
function in a larger application, but most logs that
occur during protocol simulation are best associated
with the actions in the protocol that cause them.
Default: `False`.
log_level: The level of logs to emit on the command line:
`"debug"`, `"info"`, `"warning"`, or `"error"`.
Defaults to `"warning"`.
emit_runlog: A callback for printing the run log. If specified, this
will be called whenever a command adds an entry to the
run log, which can be used for display and progress
estimation. If specified, the callback should take a
single argument (the name doesn't matter) which will
be a dictionary:

```python
{
'name': command_name,
'payload': {
'text': string_command_text,
# The rest of this struct is
# command-dependent; see
# opentrons.legacy_commands.commands.
}
}
```

!!! note
In older software versions, `payload["text"]` was a
[format string](https://docs.python.org/3/library/string.html#formatstrings).
To get human-readable text, you had to do
`payload["text"].format(**payload)`. Don't do that anymore.
If `payload["text"]` happens to contain any `{` or `}`
characters, it can confuse `.format()` and cause it to raise
a `KeyError`.

custom_labware_paths: A list of directories to search for custom labware.
Loads valid labware from these paths and makes them available
to the protocol context. If this is `None` (the default), and
this function is called on a robot, it will look in the `labware`
subdirectory of the Jupyter data directory.
custom_data_paths: A list of directories or files to load custom
data files from. Ignored if the apiv2 feature
flag is not set. Entries may be either files or
directories. Specified files and the
non-recursive contents of specified directories
are presented by the protocol context in
`ProtocolContext.bundled_data`.
"""
stack_logger = logging.getLogger("opentrons")
stack_logger.propagate = propagate_logs
Expand Down Expand Up @@ -456,13 +465,17 @@ def _print_runlog(command: command_types.CommandMessage) -> None:


def main() -> int:
"""Handler for command line invocation to run a protocol.
"""
Handler for command line invocation to run a protocol.

The arguments the program was invoked with are usually
[`sys.argv`](https://docs.python.org/3/library/sys.html#sys.argv)
but if you want to override that you can.

:param argv: The arguments the program was invoked with; this is usually
:py:obj:`sys.argv` but if you want to override that you can.
:returns int: A success or failure value suitable for use as a shell
return code passed to :py:obj:`sys.exit` (0 means success,
anything else is a kind of failure).
Returns:
int: A success or failure value suitable for use as a shell return code
passed to [`sys.exit`](https://docs.python.org/3/library/sys.html#sys.exit)
(0 means success, anything else is a kind of failure).
"""
parser = argparse.ArgumentParser(
prog="opentrons_execute", description="Run an OT-2 protocol"
Expand Down
2 changes: 1 addition & 1 deletion api/src/opentrons/protocol_api/_liquid.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Liquid:
description: An optional description.
display_color: An optional display color for the liquid.
.. versionadded:: 2.14
*New in version 2.14*
"""

_id: str
Expand Down
14 changes: 5 additions & 9 deletions api/src/opentrons/protocol_api/_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@

# Implemented with an enum to support type narrowing via `== OFF_DECK`.
class OffDeckType(enum.Enum):
"""The type of the :py:obj:`OFF_DECK` constant.
"""The type of the [`OFF_DECK`][opentrons.protocol_api.OFF_DECK] constant.

Do not use directly, except in type annotations and ``isinstance`` calls.
Do not use directly, except in type annotations and `isinstance` calls.
"""

OFF_DECK = "off-deck"
WASTE_CHUTE = "waste-chute"


OFF_DECK: Final = OffDeckType.OFF_DECK
WASTE_CHUTE: Final = OffDeckType.WASTE_CHUTE

# Set __doc__ manually as a workaround. When this docstring is written the normal way, right after
# the constant definition, Sphinx has trouble picking it up.
OFF_DECK.__doc__ = """\
A special location value, indicating that a labware is not currently on the robot's deck.
"""A special location value, indicating that a labware is not currently on the robot's deck.

See :ref:`off-deck-location` for details on using ``OFF_DECK`` with :py:obj:`ProtocolContext.move_labware()`.
See [The Off-Deck Location][the-off-deck-location] for details on using `OFF_DECK` with [`ProtocolContext.move_labware()`][opentrons.protocol_api.ProtocolContext.move_labware].
"""
WASTE_CHUTE: Final = OffDeckType.WASTE_CHUTE


class PlungerPositionTypes(enum.Enum):
Expand Down
14 changes: 7 additions & 7 deletions api/src/opentrons/protocol_api/disposal_locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def height(self) -> float:
class TrashBin(_DisposalLocation):
"""Represents a Flex or OT-2 trash bin.

See :py:meth:`.ProtocolContext.load_trash_bin`.
See [`load_trash_bin()`][opentrons.protocol_api.ProtocolContext.load_trash_bin].
"""

def __init__(
Expand All @@ -103,11 +103,11 @@ def __init__(
def top(self, x: float = 0, y: float = 0, z: float = 0) -> TrashBin:
"""Add a location offset to a trash bin.

The default location (``x``, ``y``, and ``z`` all set to ``0``) is the center of
The default location (`x`, `y`, and `z` all set to `0`) is the center of
the bin on the x- and y-axes, and slightly below its physical top on the z-axis.

Offsets can be positive or negative and are measured in mm.
See :ref:`protocol-api-deck-coords`.
See [Position Relative to the Deck][position-relative-to-the-deck].
"""
return TrashBin(
location=self._location,
Expand Down Expand Up @@ -163,7 +163,7 @@ def height(self) -> float:
class WasteChute(_DisposalLocation):
"""Represents a Flex waste chute.

See :py:meth:`.ProtocolContext.load_waste_chute`.
See [`load_waste_chute()`][opentrons.protocol_api.ProtocolContext.load_waste_chute].
"""

def __init__(
Expand All @@ -180,13 +180,13 @@ def __init__(
def top(self, x: float = 0, y: float = 0, z: float = 0) -> WasteChute:
"""Add a location offset to a waste chute.

The default location (``x``, ``y``, and ``z`` all set to ``0``) is the center of
The default location (`x`, `y`, and `z` all set to `0`) is the center of
the chute's opening on the x- and y-axes, and slightly below its physical top
on the z-axis. See :ref:`configure-waste-chute` for more information on possible
on the z-axis. See [Waste Chute][waste-chute-api] for more information on possible
configurations of the chute.

Offsets can be positive or negative and are measured in mm.
See :ref:`protocol-api-deck-coords`.
See [Position Relative to the Deck][position-relative-to-the-deck].
"""
return WasteChute(
engine_client=self._engine_client,
Expand Down
Loading
Loading