Skip to content

Commit

Permalink
Miroslavsimek/be 438 fix bug in continuous tests (#213)
Browse files Browse the repository at this point in the history
* When generating model, we are adding global search automatically, so must appear in links

* Fixed enum serialization in python 3.12

* Version bump
  • Loading branch information
mesemus authored Sep 9, 2024
1 parent 0a1c87c commit d1206a6
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 68 deletions.
2 changes: 1 addition & 1 deletion oarepo_runtime/datastreams/asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def run_datastream_processor(batch: Dict, *, processor: JSONObject, identity, ca
{
"batch": deserialized_batch.json,
"identity": serialize_identity(identity),
"callback": f"{processor_signature.kind}_error",
"callback": f"{processor_signature.kind.value}_error",
"exception": err.json,
},
)
Expand Down
17 changes: 13 additions & 4 deletions oarepo_runtime/datastreams/datastreams.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@ def process(self, batch: StreamBatch, callback: Union[DataStreamCallback, Any]):
def finish(self, callback: Union[DataStreamCallback, Any]):
pass

try:
from enum import StrEnum

class SignatureKind(str, Enum):
READER = "reader"
TRANSFORMER = "transformer"
WRITER = "writer"
class SignatureKind(StrEnum):
READER = "reader"
TRANSFORMER = "transformer"
WRITER = "writer"

except ImportError:

class SignatureKind(str, Enum):
READER = "reader"
TRANSFORMER = "transformer"
WRITER = "writer"


@dataclasses.dataclass
Expand Down
2 changes: 1 addition & 1 deletion oarepo_runtime/datastreams/semi_asynchronous.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def run_semi_asynchronous_datastream_processor(
{
"batch": batch.json,
"identity": serialize_identity(identity),
"callback": f"{signature.kind}_error",
"callback": f"{signature.kind.value}_error",
"exception": err.json,
},
)
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = oarepo-runtime
version = 1.5.58
version = 1.5.59
description = A set of runtime extensions of Invenio repository
authors = Alzbeta Pokorna
readme = README.md
Expand Down
60 changes: 0 additions & 60 deletions tests/test_async_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,63 +112,3 @@ def callback(
ds.process()

assert writer_error_occured, "Writer error should occur but was not detected"


#
# def test_async_fixtures_out_of_process(db, app, identity, search_clear, location):
# celery = app.extensions["flask-celeryext"].celery
# print(celery)
#
# writer = Signature(
# kind=SignatureKind.WRITER, name="service", kwargs={"service": "records2"}
# )
# reader = Signature(
# SignatureKind.READER,
# name="yaml",
# kwargs={
# "source": str(Path(__file__).parent / "pkg_data" / f"async_records.yaml")
# },
# )
#
# transformer = Signature(SignatureKind.TRANSFORMER, name="status", kwargs={})
#
# @shared_task
# def callback(
# *,
# batch: JSONObject = None,
# identity: JSONObject = None,
# callback: str = None,
# exception: JSONObject = None,
# **kwargs,
# ):
# print("Callback called", callback)
# batch = StreamBatch.from_json(batch)
# identity = deserialize_identity(identity)
# exception = StreamEntryError.from_json(exception) if exception else None
#
# if exception:
# print(callback, batch, identity, exception)
# sys.stdout.flush()
#
# ds = AsynchronousDataStream(
# readers=[reader],
# writers=[writer],
# transformers=[transformer],
# callback=callback.s(),
# on_background=True,
# )
# ds.process()
#
# for wait_timer in range(5):
# Records2Record.index.refresh()
# titles = set()
# for rec in current_service.scan(identity):
# titles.add(rec["metadata"]["title"])
# if len(titles) < 2:
# time.sleep(1)
# continue
#
# assert titles == {"pkg record 2", "pkg record 1"}
# return
#
# raise AssertionError("Timeout waiting for async datastream to finish")
4 changes: 3 additions & 1 deletion tests/test_info_endpoints.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ def test_info_endpoint(
'links': {
'models': 'http://localhost/.well-known/repository/models',
'requests': 'http://localhost/requests/',
'self': 'http://localhost/.well-known/repository/'
'self': 'http://localhost/.well-known/repository/',
'records': 'http://localhost/search/',
'user_records': 'http://localhost/user/search/'
},
'name': '',
'transfers': ['local-file', 'url-fetch'],
Expand Down

0 comments on commit d1206a6

Please sign in to comment.