Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(api): Add skeleton of new Labware class #2363

Merged
merged 1 commit into from
Sep 26, 2018
Merged
Changes from all commits
Commits
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
64 changes: 64 additions & 0 deletions api/opentrons/labware/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
from typing import List, Tuple
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 💯 🎉

from collections import OrderedDict


class Well:
"""
This class represents a well within a labware. It provides methods for
specifying a location within a well.
"""

def __init__(self) -> None:
pass

def top(self) -> Tuple[float, float, float]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dumb question(s) about typing:

  • Does this type cover if we used a named tuple for this return?
  • Will we use a named tuple for these methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty sure that namedtuple inherits from tuple, so should be fine. I don't know if we'll use a namedtuple or not, but we can always narrow the type.

pass

def bottom(self) -> Tuple[float, float, float]:
pass

def from_center(self) -> Tuple[float, float, float]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since this takes no args, should this be just def center(self)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

named for backward-compatibility

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, and you're right that it should take args. I'll make a note in the implementation ticket

pass


class Labware:
"""
This class represents a labware, such as a PCR plate, a tube rack, trough,
tip rack, etc. It defines the physical geometry of the labware, and
provides methods for accessing wells within the labware.
"""
def __init__(self, defintion: dict) -> None:
pass

def wells(self) -> List[Well]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing this gets its ordering from ordering key in the labware def jsons -- and I'm also guessing it flattens ordering 2D array so that the flat array goes first by column then by row (A1 B1 C1 ... A2 B2) unless the ordering in the def itself is in a different order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

pass

def wells_by_index(self) -> OrderedDict[str, Well]:
pass

def rows(self) -> List[List[Well]]:
pass

def rows_by_index(self) -> OrderedDict[str, List[Well]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The index is a string -- it's a letter here right? "A" "B" "C" etc? And a string number "1" ... "12" ... for columns?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct

pass

def columns(self) -> List[List[Well]]:
pass

def columns_by_index(self) -> OrderedDict[str, List[Well]]:
pass


def load(name: str) -> Labware:
"""
Load a labware definition by name. Definition must have been previously
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not directly related to this fn or over this Python PR, but important to define for the labware defs in general: in the updated schema, what is a name? The name of the file? I think we have displayName and uuid but not a lookup name but I might be wrong. And if there are deprecated versions of an old def that was revised, does it have a new name or a different name?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I'll make a note in the ticket for implementing these methods

stored locally on the robot.
"""
pass


def load_from_definition(definition: dict) -> Labware:
"""
Create a labware object from a labware definition dict
"""
return Labware(definition)