opentrons 8.3.0a1__py2.py3-none-any.whl → 8.3.0a2__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,7 +4,7 @@ import logging
4
4
  import json
5
5
  import os
6
6
  from pathlib import Path
7
- from typing import Any, AnyStr, Dict, Optional, Union, List
7
+ from typing import Any, AnyStr, Dict, Optional, Union, List, Sequence, Literal
8
8
 
9
9
  import jsonschema # type: ignore
10
10
 
@@ -17,10 +17,30 @@ from opentrons.protocols.api_support.constants import (
17
17
  USER_DEFS_PATH,
18
18
  )
19
19
  from opentrons_shared_data.labware.types import LabwareDefinition
20
+ from opentrons_shared_data.errors.exceptions import InvalidProtocolData
20
21
 
21
22
 
22
23
  MODULE_LOG = logging.getLogger(__name__)
23
24
 
25
+ LabwareProblem = Literal[
26
+ "no-schema-id", "bad-schema-id", "schema-mismatch", "invalid-json"
27
+ ]
28
+
29
+
30
+ class NotALabwareError(InvalidProtocolData):
31
+ def __init__(
32
+ self, problem: LabwareProblem, wrapping: Sequence[BaseException]
33
+ ) -> None:
34
+ messages: dict[LabwareProblem, str] = {
35
+ "no-schema-id": "No schema ID present in file",
36
+ "bad-schema-id": "Bad schema ID in file",
37
+ "invalid-json": "File does not contain valid JSON",
38
+ "schema-mismatch": "File does not match labware schema",
39
+ }
40
+ super().__init__(
41
+ message=messages[problem], detail={"kind": problem}, wrapping=wrapping
42
+ )
43
+
24
44
 
25
45
  def get_labware_definition(
26
46
  load_name: str,
@@ -126,7 +146,7 @@ def save_definition(
126
146
  json.dump(labware_def, f)
127
147
 
128
148
 
129
- def verify_definition(
149
+ def verify_definition( # noqa: C901
130
150
  contents: Union[AnyStr, LabwareDefinition, Dict[str, Any]]
131
151
  ) -> LabwareDefinition:
132
152
  """Verify that an input string is a labware definition and return it.
@@ -146,15 +166,24 @@ def verify_definition(
146
166
  if isinstance(contents, dict):
147
167
  to_return = contents
148
168
  else:
149
- to_return = json.loads(contents)
169
+ try:
170
+ to_return = json.loads(contents)
171
+ except json.JSONDecodeError as e:
172
+ raise NotALabwareError("invalid-json", [e]) from e
150
173
  try:
151
174
  schema_version = to_return["schemaVersion"]
175
+ except KeyError as e:
176
+ raise NotALabwareError("no-schema-id", [e]) from e
177
+
178
+ try:
152
179
  schema = schemata_by_version[schema_version]
153
- except KeyError:
154
- raise RuntimeError(
155
- f'Invalid or unknown labware schema version {to_return.get("schemaVersion", None)}'
156
- )
157
- jsonschema.validate(to_return, schema)
180
+ except KeyError as e:
181
+ raise NotALabwareError("bad-schema-id", [e]) from e
182
+
183
+ try:
184
+ jsonschema.validate(to_return, schema)
185
+ except jsonschema.ValidationError as e:
186
+ raise NotALabwareError("schema-mismatch", [e]) from e
158
187
 
159
188
  # we can type ignore this because if it passes the jsonschema it has
160
189
  # the correct structure
@@ -6,7 +6,6 @@ import contextlib
6
6
  from dataclasses import dataclass
7
7
  import json
8
8
  import logging
9
- from json import JSONDecodeError
10
9
  import pathlib
11
10
  import subprocess
12
11
  import sys
@@ -21,8 +20,6 @@ from typing import (
21
20
  TYPE_CHECKING,
22
21
  )
23
22
 
24
- from jsonschema import ValidationError # type: ignore
25
-
26
23
  from opentrons.calibration_storage.deck_configuration import (
27
24
  deserialize_deck_configuration,
28
25
  )
@@ -32,7 +29,7 @@ from opentrons.config import (
32
29
  JUPYTER_NOTEBOOK_LABWARE_DIR,
33
30
  SystemArchitecture,
34
31
  )
35
- from opentrons.protocol_api import labware
32
+ from opentrons.protocols import labware
36
33
  from opentrons.calibration_storage import helpers
37
34
  from opentrons.protocol_engine.errors.error_occurrence import (
38
35
  ErrorOccurrence as ProtocolEngineErrorOccurrence,
@@ -79,7 +76,7 @@ def labware_from_paths(
79
76
  if child.is_file() and child.suffix.endswith("json"):
80
77
  try:
81
78
  defn = labware.verify_definition(child.read_bytes())
82
- except (ValidationError, JSONDecodeError):
79
+ except labware.NotALabwareError:
83
80
  log.info(f"{child}: invalid labware, ignoring")
84
81
  log.debug(
85
82
  f"{child}: labware invalid because of this exception.",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: opentrons
3
- Version: 8.3.0a1
3
+ Version: 8.3.0a2
4
4
  Summary: The Opentrons API is a simple framework designed to make writing automated biology lab protocols easy.
5
5
  Author: Opentrons
6
6
  Author-email: engineering@opentrons.com
@@ -21,7 +21,7 @@ Classifier: Programming Language :: Python :: 3.10
21
21
  Classifier: Topic :: Scientific/Engineering
22
22
  Requires-Python: >=3.10
23
23
  License-File: ../LICENSE
24
- Requires-Dist: opentrons-shared-data (==8.3.0a1)
24
+ Requires-Dist: opentrons-shared-data (==8.3.0a2)
25
25
  Requires-Dist: aionotify (==0.3.1)
26
26
  Requires-Dist: anyio (<4.0.0,>=3.6.1)
27
27
  Requires-Dist: jsonschema (<4.18.0,>=3.0.1)
@@ -35,9 +35,9 @@ Requires-Dist: pyusb (==1.2.1)
35
35
  Requires-Dist: packaging (>=21.0)
36
36
  Requires-Dist: importlib-metadata (>=1.0) ; python_version < "3.8"
37
37
  Provides-Extra: flex-hardware
38
- Requires-Dist: opentrons-hardware[flex] (==8.3.0a1) ; extra == 'flex-hardware'
38
+ Requires-Dist: opentrons-hardware[flex] (==8.3.0a2) ; extra == 'flex-hardware'
39
39
  Provides-Extra: ot2-hardware
40
- Requires-Dist: opentrons-hardware (==8.3.0a1) ; extra == 'ot2-hardware'
40
+ Requires-Dist: opentrons-hardware (==8.3.0a2) ; extra == 'ot2-hardware'
41
41
 
42
42
  .. _Full API Documentation: http://docs.opentrons.com
43
43
 
@@ -474,7 +474,7 @@ opentrons/protocol_runner/run_orchestrator.py,sha256=5hGKWPVWcbJkaUCVqPXovmLsZAf
474
474
  opentrons/protocol_runner/task_queue.py,sha256=YH8_lvuLBYjfzXAOJU8DYXizQcbaxGmUiAPmd7kHERw,2581
475
475
  opentrons/protocols/__init__.py,sha256=cOUxilkIvdlqGvN4nYJQYr0TGdIWnzxBaTfoz3svmw8,245
476
476
  opentrons/protocols/bundle.py,sha256=QW_2kwnxgdG_nNPl2e110A5ehOH9Ej63-9TBx-F9Yvw,3666
477
- opentrons/protocols/labware.py,sha256=e3r3fk3Vs7pl61qk-ZR90s4D3h_gu8Pv3aL_-7V082w,9759
477
+ opentrons/protocols/labware.py,sha256=UvFDDz64-WgHXqEg6xSXi1q0R6A2-HFUhcFrAS6Snn8,10809
478
478
  opentrons/protocols/parse.py,sha256=viQxA4NiERPmZeHQaujq1CheiUop2oWkoPC8p7V_XqQ,27488
479
479
  opentrons/protocols/types.py,sha256=XttBJsVGx5hd__PK7OJzMepdlcRaQmno3-yZ0hUJNME,6045
480
480
  opentrons/protocols/advanced_control/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -533,15 +533,15 @@ opentrons/util/__init__.py,sha256=0ytBXWZoU15mtAqAwq-fKLgUrc-eMWXoNd2bCVtjNHE,87
533
533
  opentrons/util/async_helpers.py,sha256=v88i4JO4HGYNrIw1EkOhgJtrkMMNPBDsoweqZct8PPw,6155
534
534
  opentrons/util/broker.py,sha256=lFtIWvp44bSWWrp7pydLHLr7nRNnl5jmLvfkXzKfa5s,2705
535
535
  opentrons/util/change_notifier.py,sha256=Rmo0cyVV3yTNz62JdUHlVpiPbIj1HC6mlRUh0SXFai8,1628
536
- opentrons/util/entrypoint_util.py,sha256=5z9HjwvTfaWzvM4PcDVnvJfzB_UkNHfhQ0Ly3AQEurQ,10889
536
+ opentrons/util/entrypoint_util.py,sha256=C0KN-09_WgNkqLbCyIB3yVm-kJoe7RGrZTb7qh9z0ec,10787
537
537
  opentrons/util/get_union_elements.py,sha256=H1KqLnG1zYvI2kanhc3MXRZT-S07E5a2vF1jEkhXpCs,1073
538
538
  opentrons/util/helpers.py,sha256=3hr801bWGbxEcOFAS7f-iOhmnUhoK5qahbB8SIvaCfY,165
539
539
  opentrons/util/linal.py,sha256=IlKAP9HkNBBgULeSf4YVwSKHdx9jnCjSr7nvDvlRALg,5753
540
540
  opentrons/util/logging_config.py,sha256=UHoY7dyD6WMYNP5GKowbMxUSG_hlXeI5TaIwksR5u-U,6887
541
541
  opentrons/util/performance_helpers.py,sha256=ew7H8XD20iS6-2TJAzbQeyzStZkkE6PzHt_Adx3wbZQ,5172
542
- opentrons-8.3.0a1.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
543
- opentrons-8.3.0a1.dist-info/METADATA,sha256=sSOSsL481AAlRXiXEbVvwQkf4iHo1mgg-DSPxO7jzKM,5084
544
- opentrons-8.3.0a1.dist-info/WHEEL,sha256=qUzzGenXXuJTzyjFah76kDVqDvnk-YDzY00svnrl84w,109
545
- opentrons-8.3.0a1.dist-info/entry_points.txt,sha256=fTa6eGCYkvOtv0ov-KVE8LLGetgb35LQLF9x85OWPVw,106
546
- opentrons-8.3.0a1.dist-info/top_level.txt,sha256=wk6whpbMZdBQpcK0Fg0YVfUGrAgVOFON7oQAhOMGMW8,10
547
- opentrons-8.3.0a1.dist-info/RECORD,,
542
+ opentrons-8.3.0a2.dist-info/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
543
+ opentrons-8.3.0a2.dist-info/METADATA,sha256=N6FK95vBL2iTWYoENZJ4mqas-qArDOGOhgq1ZLpbPFk,5084
544
+ opentrons-8.3.0a2.dist-info/WHEEL,sha256=qUzzGenXXuJTzyjFah76kDVqDvnk-YDzY00svnrl84w,109
545
+ opentrons-8.3.0a2.dist-info/entry_points.txt,sha256=fTa6eGCYkvOtv0ov-KVE8LLGetgb35LQLF9x85OWPVw,106
546
+ opentrons-8.3.0a2.dist-info/top_level.txt,sha256=wk6whpbMZdBQpcK0Fg0YVfUGrAgVOFON7oQAhOMGMW8,10
547
+ opentrons-8.3.0a2.dist-info/RECORD,,