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

Chore/update deps ensure tempsgs testing #90

Merged
merged 5 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
7 changes: 6 additions & 1 deletion tests/btrdb_integration/test_conn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import btrdb
from btrdb.exceptions import BTrDBError
from btrdb.utils.credentials import credentials_by_profile


@pytest.mark.skipif(
Expand All @@ -20,9 +21,13 @@ def test_connection_info(self, conn):
def test_incorrect_connect(
self,
):
env_name = os.getenv("BTRDB_INTEGRATION_TEST_PROFILE")
creds = credentials_by_profile(env_name)
conn_str = creds["endpoints"]
print(f"{creds = }")
youngale-pingthings marked this conversation as resolved.
Show resolved Hide resolved
err_msg = r"""Could not connect to the database, error message: <_InactiveRpcError of RPC that terminated with:\n\tstatus = StatusCode.UNAUTHENTICATED\n\tdetails = "invalid api key"\n"""
with pytest.raises(BTrDBError, match=err_msg):
conn = btrdb.connect(conn_str="127.0.0.1:4410", apikey="BOGUS_KEY")
conn = btrdb.connect(conn_str=conn_str, apikey="BOGUS_KEY")

@pytest.mark.xfail(
reason="Should return BTrDBError, but returns GRPCError instead, FIXME"
Expand Down
36 changes: 18 additions & 18 deletions tests/btrdb_integration/test_streamset.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ def test_streamset_arrow_values(conn, tmp_collection):
s2.insert(list(zip(t2, d2)))
ss = btrdb.stream.StreamSet([s1, s2]).filter(start=100, end=121)
expected_times = [100, 101, 105, 106, 110, 114, 115, 119, 120]
expected_col1 = [0.0, np.NaN, 1.0, np.NaN, 2.0, np.NaN, 3.0, np.NaN, 4.0]
expected_col2 = [np.NaN, 5.0, np.NaN, 6.0, 7.0, 8.0, np.NaN, 9.0, np.NaN]
expected_col1 = [0.0, np.nan, 1.0, np.nan, 2.0, np.nan, 3.0, np.nan, 4.0]
expected_col2 = [np.nan, 5.0, np.nan, 6.0, 7.0, 8.0, np.nan, 9.0, np.nan]
expected_schema = pa.schema(
[
pa.field("time", pa.timestamp("ns", tz="UTC"), nullable=False),
Expand All @@ -65,8 +65,8 @@ def test_streamset_arrow_values(conn, tmp_collection):
)
values = ss.arrow_values()
times = [t.value for t in values["time"]]
col1 = [np.NaN if isnan(v.as_py()) else v.as_py() for v in values[str(s1.uuid)]]
col2 = [np.NaN if isnan(v.as_py()) else v.as_py() for v in values[str(s2.uuid)]]
col1 = [np.nan if isnan(v.as_py()) else v.as_py() for v in values[str(s1.uuid)]]
col2 = [np.nan if isnan(v.as_py()) else v.as_py() for v in values[str(s2.uuid)]]
assert times == expected_times
assert col1 == expected_col1
assert col2 == expected_col2
Expand All @@ -91,12 +91,12 @@ def test_streamset_template_schema(conn, tmp_collection):
)
ss = btrdb.stream.StreamSet([s1, s2]).filter(start=100, end=121, schema=schema)
expected_times = [100, 101, 105, 106, 110, 114, 115, 119, 120]
expected_col1 = [0.0, np.NaN, 1.0, np.NaN, 2.0, np.NaN, 3.0, np.NaN, 4.0]
expected_col2 = [np.NaN, 5.0, np.NaN, 6.0, 7.0, 8.0, np.NaN, 9.0, np.NaN]
expected_col1 = [0.0, np.nan, 1.0, np.nan, 2.0, np.nan, 3.0, np.nan, 4.0]
expected_col2 = [np.nan, 5.0, np.nan, 6.0, 7.0, 8.0, np.nan, 9.0, np.nan]
values = ss.arrow_values()
times = [t.value for t in values["t"]]
col1 = [np.NaN if isnan(v.as_py()) else v.as_py() for v in values["a"]]
col2 = [np.NaN if isnan(v.as_py()) else v.as_py() for v in values["b"]]
col1 = [np.nan if isnan(v.as_py()) else v.as_py() for v in values["a"]]
col2 = [np.nan if isnan(v.as_py()) else v.as_py() for v in values["b"]]
assert times == expected_times
assert col1 == expected_col1
assert col2 == expected_col2
Expand Down Expand Up @@ -292,8 +292,8 @@ def test_streamset_to_dataframe(conn, tmp_collection):
ss = btrdb.stream.StreamSet([s1, s2]).filter(start=100, end=121)
values = ss.to_dataframe()
expected_times = [100, 101, 105, 106, 110, 114, 115, 119, 120]
expected_col1 = [0.0, np.NaN, 1.0, np.NaN, 2.0, np.NaN, 3.0, np.NaN, 4.0]
expected_col2 = [np.NaN, 5.0, np.NaN, 6.0, 7.0, 8.0, np.NaN, 9.0, np.NaN]
expected_col1 = [0.0, np.nan, 1.0, np.nan, 2.0, np.nan, 3.0, np.nan, 4.0]
expected_col2 = [np.nan, 5.0, np.nan, 6.0, 7.0, 8.0, np.nan, 9.0, np.nan]
expected_dat = {
tmp_collection + "/s1": expected_col1,
tmp_collection + "/s2": expected_col2,
Expand All @@ -318,10 +318,10 @@ def test_arrow_streamset_to_dataframe(conn, tmp_collection):
pa.scalar(v, type=pa.timestamp("ns", tz="UTC")).as_py() for v in expected_times
]
expected_col1 = pa.array(
[0.0, np.NaN, 1.0, np.NaN, 2.0, np.NaN, 3.0, np.NaN, 4.0], mask=[False] * 9
[0.0, np.nan, 1.0, np.nan, 2.0, np.nan, 3.0, np.nan, 4.0], mask=[False] * 9
)
expected_col2 = pa.array(
[np.NaN, 5.0, np.NaN, 6.0, 7.0, 8.0, np.NaN, 9.0, np.NaN], mask=[False] * 9
[np.nan, 5.0, np.nan, 6.0, 7.0, 8.0, np.nan, 9.0, np.nan], mask=[False] * 9
)
expected_dat = {
"time": expected_times,
Expand Down Expand Up @@ -361,8 +361,8 @@ def test_arrow_streamset_to_polars(conn, tmp_collection):
expected_times = [
pa.scalar(v, type=pa.timestamp("ns", tz="UTC")).as_py() for v in expected_times
]
expected_col1 = [0.0, np.NaN, 1.0, np.NaN, 2.0, np.NaN, 3.0, np.NaN, 4.0]
expected_col2 = [np.NaN, 5.0, np.NaN, 6.0, 7.0, 8.0, np.NaN, 9.0, np.NaN]
expected_col1 = [0.0, np.nan, 1.0, np.nan, 2.0, np.nan, 3.0, np.nan, 4.0]
expected_col2 = [np.nan, 5.0, np.nan, 6.0, 7.0, 8.0, np.nan, 9.0, np.nan]
expected_dat = {
tmp_collection + "/s1": expected_col1,
tmp_collection + "/s2": expected_col2,
Expand Down Expand Up @@ -395,8 +395,8 @@ def test_streamset_arrow_polars_vs_old_to_polars(conn, tmp_collection, name_call
expected_times = [
pa.scalar(v, type=pa.timestamp("ns", tz="UTC")).as_py() for v in expected_times
]
expected_col1 = [0.0, np.NaN, 1.0, np.NaN, 2.0, np.NaN, 3.0, np.NaN, 4.0]
expected_col2 = [np.NaN, 5.0, np.NaN, 6.0, 7.0, 8.0, np.NaN, 9.0, np.NaN]
expected_col1 = [0.0, np.nan, 1.0, np.nan, 2.0, np.nan, 3.0, np.nan, 4.0]
expected_col2 = [np.nan, 5.0, np.nan, 6.0, 7.0, 8.0, np.nan, 9.0, np.nan]
expected_dat = {
tmp_collection + "/s1": expected_col1,
tmp_collection + "/s2": expected_col2,
Expand Down Expand Up @@ -509,8 +509,8 @@ def test_timesnap_backward_extends_range(conn, tmp_collection):
values = ss.arrow_values()
assert [1 * sec, 2 * sec] == [t.value for t in values["time"]]
assert [0.5, 2.0] == [v.as_py() for v in values[str(s1.uuid)]]
assert [np.NaN, 2.0] == [
np.NaN if isnan(v.as_py()) else v.as_py() for v in values[str(s2.uuid)]
assert [np.nan, 2.0] == [
np.nan if isnan(v.as_py()) else v.as_py() for v in values[str(s2.uuid)]
]
assert [1.0, 2.0] == [v.as_py() for v in values[str(s3.uuid)]]

Expand Down
Loading