Skip to content

Commit 1cf13ca

Browse files
committed
allow for missing kafka/websocket C++ adapters, enable future mmissing parquet adapter after cache cleanup
Signed-off-by: Tim Paine <[email protected]> Raise hard import errors if trying to use adapters with missing dependencies, with helpful error messages. Remove runtime requirement on pandas Signed-off-by: Tim Paine <[email protected]> Remove superfluous checks Signed-off-by: Tim Paine <[email protected]> Add oldest supported numpy as runtime dep as well Signed-off-by: Tim Paine <[email protected]> fix spacing in action, dont depend on oldest-supported-numpy Signed-off-by: Tim Paine <[email protected]> Isolate sdist build environment Signed-off-by: Tim Paine <[email protected]>
1 parent a2ddfa0 commit 1cf13ca

File tree

9 files changed

+29
-38
lines changed

9 files changed

+29
-38
lines changed

.github/actions/setup-caches/action.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ runs:
6161
/Users/runner/vcpkg_download_cache
6262
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('vcpkg.json') }}
6363
restore-keys: vcpkg-${{ runner.os }}-${{ runner.arch }}-
64-
if: ${{ runner.os == 'macOS' && inputs.vcpkg == 'true'}}
64+
if: ${{ runner.os == 'macOS' && inputs.vcpkg == 'true' }}
6565

6666
- name: Setup vcpkg cache in shell (Windows)
6767
shell: bash
@@ -70,7 +70,7 @@ runs:
7070
mkdir C:\\Users\\runneradmin\\AppData\\Local\\vcpkg_download_cache
7171
echo "VCPKG_DEFAULT_BINARY_CACHE=C:\\Users\\runneradmin\\AppData\\Local\\vcpkg_cache" >> $GITHUB_ENV
7272
echo "VCPKG_DOWNLOADS=C:\\Users\\runneradmin\\AppData\\Local\\vcpkg_download_cache" >> $GITHUB_ENV
73-
if: ${{ runner.os == 'Windows' && inputs.vcpkg == 'true'}}
73+
if: ${{ runner.os == 'Windows' && inputs.vcpkg == 'true' }}
7474

7575
- name: Setup vcpkg cache (Windows)
7676
uses: actions/cache@v4
@@ -80,4 +80,4 @@ runs:
8080
C:\\Users\\runneradmin\\AppData\\Local\\vcpkg_download_cache
8181
key: vcpkg-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('vcpkg.json') }}
8282
restore-keys: vcpkg-${{ runner.os }}-${{ runner.arch }}-
83-
if: ${{ runner.os == 'Windows' && inputs.vcpkg == 'true'}}
83+
if: ${{ runner.os == 'Windows' && inputs.vcpkg == 'true' }}

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ major:
142142
dist-py: dist-py-sdist # Build python dist
143143
dist-py-sdist:
144144
rm -rf csp/lib/*
145-
python -m build --sdist -n
145+
python -m build --sdist
146146

147147
dist-py-wheel:
148148
python setup.py bdist_wheel $(EXTRA_ARGS)

csp/adapters/db.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,8 @@
2626
_SQLALCHEMY_2 = False
2727

2828
import sqlalchemy as db
29-
30-
_HAS_SQLALCHEMY = True
3129
except (PackageNotFoundError, ValueError, TypeError, ImportError):
32-
_HAS_SQLALCHEMY = False
33-
db = None
30+
raise ModuleNotFoundError("csp's db adapter requires `sqlalchemy`")
3431

3532

3633
class TimeAccessor(ABC):
@@ -200,8 +197,6 @@ def __init__(
200197
:param log_query: set to True to see what query was generated to access the data
201198
:param use_raw_user_query: Don't do any alteration to user query, assume it contains all the needed columns and sorting
202199
"""
203-
if not _HAS_SQLALCHEMY:
204-
raise RuntimeError("Could not find SQLAlchemy installation")
205200
self._connection = connection
206201
self._table_name = table_name
207202
self._schema_name = schema_name

csp/adapters/kafka.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,11 @@
1818
hash_mutable,
1919
)
2020
from csp.impl.wiring import ReplayMode, input_adapter_def, output_adapter_def, status_adapter_def
21-
from csp.lib import _kafkaadapterimpl
21+
22+
try:
23+
from csp.lib import _kafkaadapterimpl
24+
except ImportError:
25+
raise ImportError("csp's kafka adapter requires the C++ csp extension to be built, but it could not be imported")
2226

2327
_ = BytesMessageProtoMapper, DateTimeType, JSONTextMessageMapper, RawBytesMessageMapper, RawTextMessageMapper
2428
T = TypeVar("T")

csp/adapters/parquet.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,12 @@
1616
from csp.impl.types.typing_utils import CspTypingUtils
1717
from csp.impl.wiring import input_adapter_def, status_adapter_def
1818
from csp.impl.wiring.node import node
19-
from csp.lib import _parquetadapterimpl
19+
20+
try:
21+
from csp.lib import _parquetadapterimpl
22+
except ImportError:
23+
raise ImportError("csp's parquet adapter requires the C++ csp extension to be built, but it could not be imported")
24+
2025

2126
__all__ = [
2227
"ParquetOutputConfig",

csp/adapters/perspective.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import tornado.web
2020
import tornado.websocket
2121
except ImportError:
22-
raise ImportError("perspective adapter requires tornado package")
22+
raise ModuleNotFoundError("csp's perspective adapter requires `tornado`")
2323

2424

2525
_PERSPECTIVE_3 = is_perspective3()

csp/adapters/websocket.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,13 @@
1919
)
2020
from csp.impl.wiring import input_adapter_def, output_adapter_def, status_adapter_def
2121
from csp.impl.wiring.delayed_node import DelayedNodeWrapperDef
22-
from csp.lib import _websocketadapterimpl
22+
23+
try:
24+
from csp.lib import _websocketadapterimpl
25+
except ImportError:
26+
raise ImportError(
27+
"csp's websocket adapter requires the C++ csp extension to be built, but it could not be imported"
28+
)
2329

2430
from .websocket_types import WebsocketHeaderUpdate
2531

@@ -38,14 +44,14 @@
3844
import tornado.web
3945
import tornado.websocket
4046
except ImportError:
41-
raise ImportError("websocket adapter requires tornado package")
47+
raise ModuleNotFoundError("csp's websocket adapter requires `tornado`")
4248

4349
try:
4450
import rapidjson
4551

4652
datetime_mode = rapidjson.DM_UNIX_TIME | rapidjson.DM_NAIVE_IS_UTC
4753
except ImportError:
48-
raise ImportError("websocket adapter requires rapidjson package")
54+
raise ModuleNotFoundError("csp's websocket adapter requires `rapidjson`")
4955

5056

5157
def diff_dict(old, new):

csp/impl/perspective_common.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
_PERSPECTIVE_3 = True
1111
from perspective.widget import PerspectiveWidget
1212

13-
elif version.parse(perspective.__version__) >= version.parse("0.6.2"):
13+
elif version.parse(perspective.__version__) >= version.parse("2.0.0"):
1414
from perspective import PerspectiveManager, PerspectiveWidget # noqa F401
1515

1616
_PERSPECTIVE_3 = False
1717
else:
18-
raise ImportError("perspective adapter requires 0.6.2 or greater of the perspective-python package")
18+
raise ImportError("perspective adapter requires 2.0 or greater of the perspective-python package")
1919

2020
except ImportError:
2121
raise ImportError(

pyproject.toml

+1-20
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,11 @@ dependencies = [
2323
"deprecated",
2424
"numpy<2",
2525
"packaging",
26-
"pandas",
2726
"psutil",
2827
"pyarrow>=15,<19",
2928
"pydantic>=2",
3029
"pytz",
3130
"ruamel.yaml",
32-
"sqlalchemy",
33-
"typing-extensions",
3431
]
3532

3633
classifiers = [
@@ -80,6 +77,7 @@ develop = [
8077
"httpx>=0.20,<1", # kafka
8178
"perspective-python>=2", # perspective
8279
"ipywidgets", # perspective
80+
"pandas", # pandas extension
8381
"polars", # parquet
8482
"psutil", # test_engine/test_history
8583
"sqlalchemy", # db
@@ -91,23 +89,6 @@ showgraph = [
9189
"graphviz",
9290
"pillow",
9391
]
94-
test = [
95-
"graphviz",
96-
"pillow",
97-
"pytest",
98-
"pytest-asyncio",
99-
"pytest-cov",
100-
"pytest-sugar",
101-
"httpx>=0.20,<1",
102-
"perspective-python",
103-
"polars",
104-
"psutil",
105-
"requests",
106-
"slack-sdk>=3",
107-
"sqlalchemy",
108-
"threadpoolctl",
109-
"tornado",
110-
]
11192
symphony = [
11293
"csp-adapter-symphony",
11394
]

0 commit comments

Comments
 (0)