Skip to content

Commit 7ee1ddb

Browse files
committed
revert some changes; optimize usage for BASE_EVENT_CLS_TO_APP_TYPE_MAPPING
1 parent 21de5cb commit 7ee1ddb

File tree

2 files changed

+26
-7
lines changed

2 files changed

+26
-7
lines changed

src/corva/__init__.py

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,22 @@
1-
from .models.scheduled.scheduled import ScheduledDataTimeEvent
1+
from .api import Api
2+
from .handlers import scheduled, stream, task, partial_rerun_merge
3+
from .logger import CORVA_LOGGER as Logger
4+
from .models.rerun import RerunDepth, RerunDepthRange, RerunTime, RerunTimeRange
5+
from .models.scheduled.scheduled import (
6+
ScheduledDataTimeEvent,
7+
ScheduledDepthEvent,
8+
ScheduledNaturalTimeEvent,
9+
)
10+
from .models.stream.stream import (
11+
StreamDepthEvent,
12+
StreamDepthRecord,
13+
StreamTimeEvent,
14+
StreamTimeRecord,
15+
)
16+
from .models.merge.merge import PartialRerunMergeEvent
17+
from .models.task import TaskEvent
18+
from .service.cache_sdk import UserRedisSdk as Cache
19+
from .shared import SECRETS as secrets
220

321

422
def __getattr__(name):

src/corva/validate_app_init.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
from corva.models.stream.raw import RawStreamEvent
1313
from corva.models.task import RawTaskEvent
1414

15+
BASE_EVENT_CLS_TO_APP_TYPE_MAPPING: Dict[str, Type[RawBaseEvent]] = {
16+
"task": RawTaskEvent,
17+
"stream": RawStreamEvent,
18+
"scheduled": RawScheduledEvent,
19+
}
20+
1521

1622
def find_leaf_subclasses(base_class):
1723
leaf_classes = []
@@ -42,19 +48,14 @@ def validate_manifested_type(manifest: Dict[str, Any], app_decorator_type: str)
4248

4349

4450
def validate_event_payload(aws_event, app_decorator_type) -> None:
45-
base_event_cls_to_app_type_mapping: Dict[str, Type[RawBaseEvent]] = {
46-
"task": RawTaskEvent,
47-
"stream": RawStreamEvent,
48-
"scheduled": RawScheduledEvent,
49-
}
5051

5152
if event_cls := guess_event_type(aws_event):
5253
if issubclass(event_cls, RawPartialRerunMergeEvent):
5354
# RawPartialRerunMergeEvent(-s) should be ignored here since
5455
# it is not new app type itself it's just a run mode for existing app types
5556
return
5657

57-
expected_base_event_cls = base_event_cls_to_app_type_mapping[app_decorator_type]
58+
expected_base_event_cls = BASE_EVENT_CLS_TO_APP_TYPE_MAPPING[app_decorator_type]
5859
if not issubclass(event_cls, expected_base_event_cls):
5960
raise RuntimeError(
6061
f'Application with type "{app_decorator_type}" '

0 commit comments

Comments
 (0)