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: Add support for empty mounts in provisioning script #12961

Merged
merged 3 commits into from
Jun 23, 2023
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Gonna give, "not writing bad code" a shot
  • Loading branch information
DerekMaggio committed Jun 23, 2023
commit 262d21e41748787d14a2b013f6c4d5401c7a6267
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
- Profit
"""

from dataclasses import dataclass
import os
import json
from typing import Optional
Expand All @@ -18,45 +19,38 @@
LEFT_PIPETTE_ENV_VAR_NAME = "LEFT_OT3_PIPETTE_DEFINITION"
RIGHT_PIPETTE_ENV_VAR_NAME = "RIGHT_OT3_PIPETTE_DEFINITION"

NO_PIPETTE_NAME = "EMPTY"
NO_PIPETTE_MODEL = -1
NO_PIPETTE_SERIAL_CODE = ""


@dataclass
class OT3PipetteEnvVar:
Copy link
Contributor

Choose a reason for hiding this comment

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

Couldn't you just keep this a data class with defaults?

Copy link
Contributor

Choose a reason for hiding this comment

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

or keep it a dataclass and use a build classmethod

Copy link
Member Author

Choose a reason for hiding this comment

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

Stop making so much sense. I have no idea why I did it that way. I will go back and fix it.

If I remember the reason I did it that way, and the reason makes sense, I will drop a comment.

Copy link
Member Author

Choose a reason for hiding this comment

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

I remembered my reasoning for doing it that way.
My reasoning was not good.

Here is the fix
262d21e

"""OT3 Pipette Environment Variable."""

NO_PIPETTE_NAME = "EMPTY"
NO_PIPETTE_MODEL = -1
NO_PIPETTE_SERIAL_CODE = ""

def __init__(
self,
pipette_name: str,
pipette_model: int,
pipette_serial_code: str,
eeprom_file_path: str,
) -> None:
"""Initialize."""
self.pipette_name = pipette_name
self.pipette_model = pipette_model
self.pipette_serial_code = pipette_serial_code
self.eeprom_file_path = eeprom_file_path
pipette_name: str
pipette_model: int
pipette_serial_code: str
eeprom_file_path: str

def is_no_pipette(self) -> bool:
"""Check if pipette is no pipette."""
no_pipette = (
self.pipette_name == self.NO_PIPETTE_NAME,
self.pipette_model == self.NO_PIPETTE_MODEL,
self.pipette_serial_code == self.NO_PIPETTE_SERIAL_CODE,
self.pipette_name == NO_PIPETTE_NAME,
self.pipette_model == NO_PIPETTE_MODEL,
self.pipette_serial_code == NO_PIPETTE_SERIAL_CODE,
)
any_no_pipette_fields_have_been_set = any(no_pipette)
all_no_pipette_fields_are_not_set = not all(no_pipette)

if any_no_pipette_fields_have_been_set and all_no_pipette_fields_are_not_set:
raise ValueError(

Check warning on line 47 in hardware/opentrons_hardware/scripts/emulation_pipette_provision.py

View check run for this annotation

Codecov / codecov/patch

hardware/opentrons_hardware/scripts/emulation_pipette_provision.py#L47

Added line #L47 was not covered by tests
"\n".join(
(
"Invalid empty pipette definition. Expecting the following:",
f"pipette_name: {self.NO_PIPETTE_NAME}",
f"pipette_model: {self.NO_PIPETTE_MODEL}",
f"pipette_serial_code: {self.NO_PIPETTE_SERIAL_CODE}",
f"pipette_name: {NO_PIPETTE_NAME}",
f"pipette_model: {NO_PIPETTE_MODEL}",
f"pipette_serial_code: {NO_PIPETTE_SERIAL_CODE}",
"",
"You passed the following:",
f"pipette_name: {self.pipette_name}",
Expand Down
Loading