Skip to content

Commit

Permalink
Specifying pydantic<2 in pyproject.toml, also changed stream_resource…
Browse files Browse the repository at this point in the history
… to only have one compose_datum in the ComposeStreamResourceBundle
  • Loading branch information
evalott100 committed Jul 3, 2023
1 parent e5ec76c commit 65cc064
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 29 deletions.
25 changes: 6 additions & 19 deletions event_model/tests/test_em.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import json
import pickle
from distutils.version import LooseVersion
from itertools import count

import jsonschema
import numpy
Expand Down Expand Up @@ -115,19 +114,11 @@ def test_compose_stream_resource(tmp_path):
root=str(tmp_path),
resource_path="test_streams",
resource_kwargs={},
counters=[count(1), count(1)],
)
resource_doc, compose_stream_data = bundle
resource_doc, compose_stream_datum = bundle
assert bundle.stream_resource_doc is resource_doc
assert bundle.compose_stream_data is compose_stream_data
assert compose_stream_data[0] is not compose_stream_data[1]
datum_doc_0, datum_doc_1 = (
compose_stream_datum([], {}, {}) for compose_stream_datum in compose_stream_data
)
# Ensure independent counters
assert datum_doc_0["block_idx"] == datum_doc_1["block_idx"]
datum_doc_1a = compose_stream_data[1]([], {}, {})
assert datum_doc_1a["block_idx"] != datum_doc_1["block_idx"]
assert bundle.compose_stream_data is compose_stream_datum
compose_stream_datum([], {}, {})


def test_round_trip_pagination():
Expand Down Expand Up @@ -398,19 +389,15 @@ def test_document_router_streams_smoke_test(tmp_path):
compose_stream_resource = run_bundle.compose_stream_resource
start = run_bundle.start_doc
dr("start", start)
stream_resource_doc, compose_stream_data = compose_stream_resource(
stream_resource_doc, compose_stream_datum = compose_stream_resource(
spec="TIFF_STREAM",
root=str(tmp_path),
counters=[count(1), count(6)],
resource_path="test_streams",
resource_kwargs={},
)
dr("stream_resource", stream_resource_doc)
datum_doc_0, datum_doc_1 = (
compose_stream_datum([], {}, {}) for compose_stream_datum in compose_stream_data
)
dr("stream_datum", datum_doc_0)
dr("stream_datum", datum_doc_1)
datum_doc = compose_stream_datum([], {}, {})
dr("stream_datum", datum_doc)
dr("stop", run_bundle.compose_stop())


Expand Down
13 changes: 4 additions & 9 deletions event_model/tests/test_run_router.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from collections import defaultdict
from itertools import count

import numpy
import pytest
Expand Down Expand Up @@ -216,19 +215,15 @@ def test_run_router_streams(tmp_path):
bundle.compose_stop(),
)
docs.append(("start", start_doc))
stream_resource_doc, compose_stream_data = compose_stream_resource(
stream_resource_doc, compose_stream_datum = compose_stream_resource(
spec="TIFF_STREAM",
root=str(tmp_path),
resource_path="test_streams",
resource_kwargs={},
counters=[count(3), count(2)],
)
docs.append(("stream_resource", stream_resource_doc))
datum_doc_0, datum_doc_1 = (
compose_stream_datum([], {}, {}) for compose_stream_datum in compose_stream_data
)
docs.append(("stream_datum", datum_doc_0))
docs.append(("stream_datum", datum_doc_1))
datum_doc = compose_stream_datum([], {}, {})
docs.append(("stream_datum", datum_doc))
docs.append(("stop", stop_doc))

# Empty list of factories. Just make sure nothing blows up.
Expand All @@ -253,7 +248,7 @@ def all_factory(name, doc):
for name, doc in docs:
rr(name, doc)
assert len(resource_list) == 1
assert len(data_list) == 2
assert len(data_list) == 1


def test_subfactory():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ dev = [
"numpydoc",

# For schema generation.
"pydantic",
"pydantic<2.0",
]

[project.scripts]
Expand Down

0 comments on commit 65cc064

Please sign in to comment.