Skip to content

Commit 46a3c04

Browse files
committed
fix import logic, fix remaining tests
Signed-off-by: Lance-Drane <Lance-Drane@users.noreply.github.com>
1 parent 8fa4eb4 commit 46a3c04

7 files changed

Lines changed: 257 additions & 163 deletions

File tree

pyproject.toml

Lines changed: 104 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -2,36 +2,36 @@
22
name = "intersect-sdk"
33
description = "Python SDK to interact with INTERSECT"
44
authors = [
5-
{ name = "Lance Drane", email = "dranelt@ornl.gov" },
6-
{ name = "Marshall McDonnell", email = "mcdonnellmt@ornl.gov" },
7-
{ name = "Seth Hitefield", email = "hitefieldsd@ornl.gov" },
8-
{ name = "Andrew Ayres", email = "ayresaf@ornl.gov" },
9-
{ name = "Gregory Cage", email = "cagege@ornl.gov" },
10-
{ name = "Jesse McGaha", email = "mcgahajr@ornl.gov" },
11-
{ name = "Robert Smith", email = "smithrw@ornl.gov" },
12-
{ name = "Gavin Wiggins", email = "wigginsg@ornl.gov" },
13-
{ name = "Michael Brim", email = "brimmj@ornl.gov" },
14-
{ name = "Rick Archibald", email = "archibaldrk@ornl.gov" },
15-
{ name = "Addi Malviya Thakur", email = "malviyaa@ornl.gov" },
5+
{ name = "Lance Drane", email = "dranelt@ornl.gov" },
6+
{ name = "Marshall McDonnell", email = "mcdonnellmt@ornl.gov" },
7+
{ name = "Seth Hitefield", email = "hitefieldsd@ornl.gov" },
8+
{ name = "Andrew Ayres", email = "ayresaf@ornl.gov" },
9+
{ name = "Gregory Cage", email = "cagege@ornl.gov" },
10+
{ name = "Jesse McGaha", email = "mcgahajr@ornl.gov" },
11+
{ name = "Robert Smith", email = "smithrw@ornl.gov" },
12+
{ name = "Gavin Wiggins", email = "wigginsg@ornl.gov" },
13+
{ name = "Michael Brim", email = "brimmj@ornl.gov" },
14+
{ name = "Rick Archibald", email = "archibaldrk@ornl.gov" },
15+
{ name = "Addi Malviya Thakur", email = "malviyaa@ornl.gov" },
1616
]
1717
version = "0.9.0"
1818
readme = "README.md"
1919
license = { text = "BSD-3-Clause" }
2020
requires-python = ">=3.10,<4.0"
2121
keywords = ["intersect"]
2222
classifiers = [
23-
"Programming Language :: Python :: 3",
24-
"Programming Language :: Python :: 3.10",
25-
"Programming Language :: Python :: 3.11",
26-
"Programming Language :: Python :: 3.12",
27-
"Programming Language :: Python :: 3.13",
23+
"Programming Language :: Python :: 3",
24+
"Programming Language :: Python :: 3.10",
25+
"Programming Language :: Python :: 3.11",
26+
"Programming Language :: Python :: 3.12",
27+
"Programming Language :: Python :: 3.13",
2828
]
2929
dependencies = [
30-
"pydantic>=2.7.0",
31-
"intersect-sdk-common>=0.9.4,<0.10.0",
32-
"jsonschema[format-nongpl]>=4.21.1", # extras necessary for enforcing formats
33-
#"brotli>=1.1.0", # TODO - add this dependency when we add compression
34-
"psutil>=7.0.0",
30+
"pydantic>=2.7.0",
31+
"intersect-sdk-common>=0.9.5,<0.10.0",
32+
"jsonschema[format-nongpl]>=4.21.1", # extras necessary for enforcing formats
33+
#"brotli>=1.1.0", # TODO - add this dependency when we add compression
34+
"psutil>=7.0.0",
3535
]
3636

3737
[project.urls]
@@ -41,20 +41,17 @@ Documentation = "https://intersect-python-sdk.readthedocs.io/en/latest/"
4141
Issues = "https://github.com/INTERSECT-SDK/python-sdk/issues"
4242

4343
[project.optional-dependencies]
44-
docs = [
45-
"sphinx>=5.3.0",
46-
"furo>=2023.3.27",
47-
]
44+
docs = ["sphinx>=5.3.0", "furo>=2023.3.27"]
4845

4946
[dependency-groups]
5047
dev = [
51-
"pre-commit>=3.3.1",
52-
"ruff==0.12.7",
53-
"mypy>=1.10.0",
54-
"codespell>=2.3.0",
55-
"pytest>=7.3.2",
56-
"pytest-cov>=4.1.0",
57-
"httpretty>=1.1.4"
48+
"pre-commit>=3.3.1",
49+
"ruff==0.12.7",
50+
"mypy>=1.10.0",
51+
"codespell>=2.3.0",
52+
"pytest>=7.3.2",
53+
"pytest-cov>=4.1.0",
54+
"httpretty>=1.1.4",
5855
]
5956

6057
[build-system]
@@ -73,88 +70,94 @@ mccabe = { max-complexity = 20 }
7370
pylint = { max-args = 10, max-branches = 20, max-returns = 15, max-statements = 75 }
7471
# pyflakes and the relevant pycodestyle rules are already configured
7572
extend-select = [
76-
'C90', # mccabe complexity
77-
'I', # isort
78-
'N', # pep8-naming
79-
'D', # pydocstyle
80-
'UP', # pyupgrade
81-
'YTT', # flake8-2020
82-
'ANN', # flake8-annotations
83-
'ASYNC', # flake8-async
84-
'S', # flake8-bandit
85-
'BLE', # flake8-blind-except
86-
'B', # flake8-bugbear
87-
'A', # flake8-builtins
88-
'COM', # flake8-commas
89-
'C4', # flake8-comprehensions
90-
'DTZ', # flake8-datetimez
91-
'T10', # flake8-debugger
92-
'EM', # flake8-error-message
93-
'FA', # flake8-future-annotations
94-
'ISC', # flake8-implicit-string-concat
95-
'ICN', # flake8-import-conventions
96-
'G', # flake8-logging-format
97-
'INP', # flake8-no-pep420
98-
'PIE', # flake8-PIE
99-
'T20', # flake8-T20
100-
'PYI', # flake8-pyi
101-
'PT', # flake8-pytest-style
102-
'Q', # flake8-quotes
103-
'RSE', # flake8-raise
104-
'RET', # flake8-return
105-
'SLF', # flake8-self
106-
'SLOT', # flake8-slots
107-
'SIM', # flake8-simplify
108-
'TC', # flake8-type-checking
109-
'ARG', # flake8-unused-arguments
110-
'PTH', # flake8-use-pathlib
111-
'PGH', # pygrep-hooks
112-
'PL', # pylint
113-
'TRY', # tryceratops
114-
'FLY', # flynt
115-
'RUF', # RUFF additional rules
116-
'INT', # flake8-gettext
73+
'C90', # mccabe complexity
74+
'I', # isort
75+
'N', # pep8-naming
76+
'D', # pydocstyle
77+
'UP', # pyupgrade
78+
'YTT', # flake8-2020
79+
'ANN', # flake8-annotations
80+
'ASYNC', # flake8-async
81+
'S', # flake8-bandit
82+
'BLE', # flake8-blind-except
83+
'B', # flake8-bugbear
84+
'A', # flake8-builtins
85+
'COM', # flake8-commas
86+
'C4', # flake8-comprehensions
87+
'DTZ', # flake8-datetimez
88+
'T10', # flake8-debugger
89+
'EM', # flake8-error-message
90+
'FA', # flake8-future-annotations
91+
'ISC', # flake8-implicit-string-concat
92+
'ICN', # flake8-import-conventions
93+
'G', # flake8-logging-format
94+
'INP', # flake8-no-pep420
95+
'PIE', # flake8-PIE
96+
'T20', # flake8-T20
97+
'PYI', # flake8-pyi
98+
'PT', # flake8-pytest-style
99+
'Q', # flake8-quotes
100+
'RSE', # flake8-raise
101+
'RET', # flake8-return
102+
'SLF', # flake8-self
103+
'SLOT', # flake8-slots
104+
'SIM', # flake8-simplify
105+
'TC', # flake8-type-checking
106+
'ARG', # flake8-unused-arguments
107+
'PTH', # flake8-use-pathlib
108+
'PGH', # pygrep-hooks
109+
'PL', # pylint
110+
'TRY', # tryceratops
111+
'FLY', # flynt
112+
'RUF', # RUFF additional rules
113+
'INT', # flake8-gettext
117114
]
118115
# If you're seeking to disable a rule, first consider whether the rule is overbearing, or if it should only be turned off for your usecase.
119116
ignore = [
120-
'COM812', # formatter, handled by Ruff format
121-
'ISC001', # formatter, handled by Ruff format
122-
'SIM105', # "with contextlib.suppress():" is slower than try-except-pass
123-
'ANN401', # allow explicit "Any" typing, use with care
124-
'PLR2004', # allow "magic numbers"
117+
'COM812', # formatter, handled by Ruff format
118+
'ISC001', # formatter, handled by Ruff format
119+
'SIM105', # "with contextlib.suppress():" is slower than try-except-pass
120+
'ANN401', # allow explicit "Any" typing, use with care
121+
'PLR2004', # allow "magic numbers"
125122
]
126123

127124
[tool.ruff.lint.flake8-type-checking]
128-
runtime-evaluated-base-classes = ["pydantic.BaseModel", "intersect_sdk.IntersectBaseCapabilityImplementation"]
129-
runtime-evaluated-decorators = ["pydantic.dataclasses.dataclass","pydantic.validate_call"]
125+
runtime-evaluated-base-classes = [
126+
"pydantic.BaseModel",
127+
"intersect_sdk.IntersectBaseCapabilityImplementation",
128+
]
129+
runtime-evaluated-decorators = [
130+
"pydantic.dataclasses.dataclass",
131+
"pydantic.validate_call",
132+
]
130133

131134
[tool.ruff.lint.extend-per-file-ignores]
132135
'__init__.py' = [
133-
'F401', # __init__.py commonly has unused imports
134-
'TC004', # do lazy imports when importing from the base module
136+
'F401', # __init__.py commonly has unused imports
137+
'TC004', # do lazy imports when importing from the base module
135138
]
136139
'docs/*' = [
137-
'D', # the documentation folder does not need documentation
138-
'INP001', # docs are not a namespace package
140+
'D', # the documentation folder does not need documentation
141+
'INP001', # docs are not a namespace package
139142
]
140143
'examples/*' = [
141-
'N999', # module names for examples are not standard
142-
'T20', # allow print/pprint statements in examples
143-
'S106', # don't care about credentials in examples
144-
'D100', # documenting modules in examples is unhelpful
145-
'D104', # documenting packages in examples is unhelpful
146-
'TRY002', # examples can raise their own exception
144+
'N999', # module names for examples are not standard
145+
'T20', # allow print/pprint statements in examples
146+
'S106', # don't care about credentials in examples
147+
'D100', # documenting modules in examples is unhelpful
148+
'D104', # documenting packages in examples is unhelpful
149+
'TRY002', # examples can raise their own exception
147150
]
148151
'tests/*' = [
149-
'S101', # allow assert statements in tests
150-
'S106', # don't care about credentials in tests
151-
'S311', # don't care about cryptographic security in tests
152-
'SLF001', # allow private member access in tests
153-
'ANN', # tests in general don't need types, unless they are runtime types.
154-
'ARG', # allow unused parameters in tests
155-
'D', # ignore documentation in tests
156-
'RUF012', # permit "mutable" class attributes to not be annotated with typing.ClassVar (these shouldn't be mutated anyways...)
157-
]
152+
'S101', # allow assert statements in tests
153+
'S106', # don't care about credentials in tests
154+
'S311', # don't care about cryptographic security in tests
155+
'SLF001', # allow private member access in tests
156+
'ANN', # tests in general don't need types, unless they are runtime types.
157+
'ARG', # allow unused parameters in tests
158+
'D', # ignore documentation in tests
159+
'RUF012', # permit "mutable" class attributes to not be annotated with typing.ClassVar (these shouldn't be mutated anyways...)
160+
]
158161

159162
# see https://mypy.readthedocs.io/en/stable/config_file.html for a complete reference
160163
[tool.mypy]
@@ -175,8 +178,8 @@ addopts = "-ra"
175178

176179
[tool.coverage.report]
177180
omit = [
178-
'*__init__*', # __init__ files should just re-export other classes and functions
179-
'*/discovery_service.py', # currently unused
181+
'*__init__*', # __init__ files should just re-export other classes and functions
182+
'*/discovery_service.py', # currently unused
180183
]
181184
exclude_also = [
182185
'pragma: no-cover', # standard

src/intersect_sdk/__init__.py

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -87,28 +87,52 @@
8787
# [0] = package, [1] = path to module within package
8888
__lazy_imports = {
8989
# COMMON: core types
90-
'IntersectDataHandler': ('intersect_sdk_common', ''),
91-
'IntersectMimeType': ('intersect_sdk_common', ''),
90+
'IntersectDataHandler': ('intersect_sdk_common', '.'),
91+
'IntersectMimeType': ('intersect_sdk_common', '.'),
9292
# COMMON: config types
93-
'ControlPlaneConfig': ('intersect_sdk_common', ''),
94-
'ControlProvider': ('intersect_sdk_common', ''),
95-
'DataStoreConfig': ('intersect_sdk_common', ''),
96-
'DataStoreConfigMap': ('intersect_sdk_common', ''),
97-
'HierarchyConfig': ('intersect_sdk_common', ''),
93+
'ControlPlaneConfig': ('intersect_sdk_common', '.'),
94+
'ControlProvider': ('intersect_sdk_common', '.'),
95+
'DataStoreConfig': ('intersect_sdk_common', '.'),
96+
'DataStoreConfigMap': ('intersect_sdk_common', '.'),
97+
'HierarchyConfig': ('intersect_sdk_common', '.'),
9898
# imports not in common
99-
'INTERSECT_CLIENT_EVENT_CALLBACK_TYPE': (__spec__.parent, '.client_callback_definitions'),
100-
'INTERSECT_CLIENT_RESPONSE_CALLBACK_TYPE': (__spec__.parent, '.client_callback_definitions'),
99+
'INTERSECT_CLIENT_EVENT_CALLBACK_TYPE': (
100+
__spec__.parent,
101+
'.client_callback_definitions',
102+
),
103+
'INTERSECT_CLIENT_RESPONSE_CALLBACK_TYPE': (
104+
__spec__.parent,
105+
'.client_callback_definitions',
106+
),
101107
'INTERSECT_JSON_VALUE': (__spec__.parent, '.shared_callback_definitions'),
102-
'INTERSECT_RESPONSE_VALUE': (__spec__.parent, '.shared_callback_definitions'),
103-
'INTERSECT_SERVICE_RESPONSE_CALLBACK_TYPE': (__spec__.parent, '.service_callback_definitions'),
104-
'IntersectBaseCapabilityImplementation': (__spec__.parent, '.capability.base'),
108+
'INTERSECT_RESPONSE_VALUE': (
109+
__spec__.parent,
110+
'.shared_callback_definitions',
111+
),
112+
'INTERSECT_SERVICE_RESPONSE_CALLBACK_TYPE': (
113+
__spec__.parent,
114+
'.service_callback_definitions',
115+
),
116+
'IntersectBaseCapabilityImplementation': (
117+
__spec__.parent,
118+
'.capability.base',
119+
),
105120
'IntersectCapabilityError': (__spec__.parent, '.exceptions'),
106121
'IntersectClient': (__spec__.parent, '.client'),
107-
'IntersectClientCallback': (__spec__.parent, '.client_callback_definitions'),
122+
'IntersectClientCallback': (
123+
__spec__.parent,
124+
'.client_callback_definitions',
125+
),
108126
'IntersectClientConfig': (__spec__.parent, '.config.client'),
109-
'IntersectDirectMessageParams': (__spec__.parent, '.shared_callback_definitions'),
127+
'IntersectDirectMessageParams': (
128+
__spec__.parent,
129+
'.shared_callback_definitions',
130+
),
110131
'IntersectEventDefinition': (__spec__.parent, '.service_definitions'),
111-
'IntersectEventMessageParams': (__spec__.parent, '.shared_callback_definitions'),
132+
'IntersectEventMessageParams': (
133+
__spec__.parent,
134+
'.shared_callback_definitions',
135+
),
112136
'IntersectService': (__spec__.parent, '.service'),
113137
'IntersectServiceConfig': (__spec__.parent, '.config.service'),
114138
'__version__': (__spec__.parent, '.version'),

src/intersect_sdk/_internal/version_resolver.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
from ..core_definitions import IntersectDataHandler
1+
from intersect_sdk_common import IntersectDataHandler
2+
23
from ..version import version_info, version_string
34
from .logger import logger
45

@@ -38,7 +39,9 @@ def _resolve_user_version(
3839

3940

4041
def resolve_user_version(
41-
their_version: str, their_source: str, their_data_handler: IntersectDataHandler
42+
their_version: str,
43+
their_source: str,
44+
their_data_handler: IntersectDataHandler,
4245
) -> bool:
4346
"""This function handles all version compatibilities between our SDK version and an incoming message's SDK version.
4447

tests/integration/test_return_type_mismatch.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@
1010
import time
1111
from uuid import uuid4
1212

13+
from intersect_sdk_common import (
14+
ControlPlaneManager,
15+
)
16+
from intersect_sdk_common.control_plane.messages.userspace import (
17+
create_userspace_message_headers,
18+
validate_userspace_message_headers,
19+
)
20+
1321
from intersect_sdk import (
1422
ControlPlaneConfig,
1523
DataStoreConfig,
@@ -20,13 +28,6 @@
2028
IntersectServiceConfig,
2129
intersect_message,
2230
)
23-
from intersect_sdk._internal.control_plane.control_plane_manager import (
24-
ControlPlaneManager,
25-
)
26-
from intersect_sdk._internal.messages.userspace import (
27-
create_userspace_message_headers,
28-
validate_userspace_message_headers,
29-
)
3031
from tests.fixtures.example_schema import FAKE_HIERARCHY_CONFIG
3132

3233
# FIXTURE #############################
@@ -96,10 +97,17 @@ def test_call_user_function_with_invalid_payload() -> None:
9697
def userspace_msg_callback(
9798
payload: bytes, content_type: str, raw_headers: dict[str, str]
9899
) -> None:
99-
msg[0] = (payload, content_type, validate_userspace_message_headers(raw_headers))
100+
msg[0] = (
101+
payload,
102+
content_type,
103+
validate_userspace_message_headers(raw_headers),
104+
)
100105

101106
message_interceptor.add_subscription_channel(
102-
'msg/msg/msg/msg/msg/response', {userspace_msg_callback}, False
107+
'msg/msg/msg/msg/msg/response',
108+
{userspace_msg_callback},
109+
False,
110+
'my_queue_name',
103111
)
104112
message_interceptor.connect()
105113
intersect_service.startup()

0 commit comments

Comments
 (0)