Skip to content

Commit

Permalink
fix(api): Fix opentrons_execute ignoring args for custom labware and …
Browse files Browse the repository at this point in the history
…data (#13074)

* Fix a bug where the `--custom-labware-path` (`-L`), `--custom-data-path` (`-D`), and `--custom-data-file`) (`-d`) arguments to `opentrons_execute` had no effect. This closes #9256.
* In the `--help` text, clarify how `--custom-labware-path` (`-L)` affects the default behavior of searching the current working directory.
* Refactor: Remove some unnecessary `getattr()` calls to read attributes that should always be present.
  • Loading branch information
SyntaxColoring authored Jul 11, 2023
1 parent 11b4775 commit b059fe3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
11 changes: 7 additions & 4 deletions api/src/opentrons/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,9 @@ def get_arguments(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
"Only directories specified directly by "
"this argument are searched, not their children. JSON files that "
"do not define labware will be ignored with a message. "
"By default, the current directory (the one in which you are "
"invoking this program) will be searched for labware.",
"The current directory (the one from which you are "
"invoking this program) will always be included implicitly, "
"in addition to any directories that you specify.",
)
parser.add_argument(
"-D",
Expand Down Expand Up @@ -410,8 +411,10 @@ def main() -> int:
log_level = "warning"
# Try to migrate containers from database to v2 format
execute(
args.protocol,
args.protocol.name,
protocol_file=args.protocol,
protocol_name=args.protocol.name,
custom_labware_paths=args.custom_labware_path,
custom_data_paths=(args.custom_data_path + args.custom_data_file),
log_level=log_level,
emit_runlog=printer,
)
Expand Down
13 changes: 7 additions & 6 deletions api/src/opentrons/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,8 +545,9 @@ def get_arguments(parser: argparse.ArgumentParser) -> argparse.ArgumentParser:
"Only directories specified directly by "
"this argument are searched, not their children. JSON files that "
"do not define labware will be ignored with a message. "
"By default, the current directory (the one from which you are "
"invoking this program) will be searched for labware.",
"The current directory (the one from which you are "
"invoking this program) will always be included implicitly, "
"in addition to any directories that you specify.",
)
parser.add_argument(
"-D",
Expand Down Expand Up @@ -665,10 +666,10 @@ def main() -> int:
duration_estimator = DurationEstimator() if args.estimate_duration else None # type: ignore[no-untyped-call]

runlog, maybe_bundle = simulate(
args.protocol,
args.protocol.name,
getattr(args, "custom_labware_path", []),
getattr(args, "custom_data_path", []) + getattr(args, "custom_data_file", []),
protocol_file=args.protocol,
file_name=args.protocol.name,
custom_labware_paths=args.custom_labware_path,
custom_data_paths=(args.custom_data_path + args.custom_data_file),
duration_estimator=duration_estimator,
hardware_simulator_file_path=getattr(args, "custom_hardware_simulator_file"),
log_level=args.log_level,
Expand Down

0 comments on commit b059fe3

Please sign in to comment.