Skip to content

Commit

Permalink
Allowed external="STREAM:" keys to not be represented in data in Comp…
Browse files Browse the repository at this point in the history
…oseEvent and ComposeEventPage
  • Loading branch information
evalott100 committed Jul 4, 2023
1 parent 19e6744 commit c565a96
Showing 1 changed file with 24 additions and 4 deletions.
28 changes: 24 additions & 4 deletions event_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2249,11 +2249,21 @@ def __call__(
)
if validate:
schema_validators[DocumentNames.event_page].validate(doc)

def keys_without_stream_keys(dictionary):
return [
key for key in dictionary.keys() if (
"external" in self.descriptor["data_keys"][key] and
self.descriptor["data_keys"][key]["external"] == "STREAM:"
)
]
if not (
self.descriptor["data_keys"].keys() == data.keys() == timestamps.keys()
keys_without_stream_keys(self.descriptor["data_keys"]) ==
keys_without_stream_keys(data) ==
keys_without_stream_keys(timestamps)
):
raise EventModelValidationError(
"These sets of keys must match:\n"
"These sets of keys must match (other than \"STREAM:\" keys):\n"
"event['data'].keys(): {}\n"
"event['timestamps'].keys(): {}\n"
"descriptor['data_keys'].keys(): {}\n".format(
Expand Down Expand Up @@ -2331,11 +2341,21 @@ def __call__(
)
if validate:
schema_validators[DocumentNames.event].validate(doc)

def keys_without_stream_keys(dictionary):
return [
key for key in dictionary.keys() if (
"external" not in self.descriptor["data_keys"][key] or
self.descriptor["data_keys"][key]["external"] == "STREAM:"
)
]
if not (
self.descriptor["data_keys"].keys() == data.keys() == timestamps.keys()
keys_without_stream_keys(self.descriptor["data_keys"]) ==
keys_without_stream_keys(data) ==
keys_without_stream_keys(timestamps)
):
raise EventModelValidationError(
"These sets of keys must match:\n"
"These sets of keys must match (other than \"STREAM:\" keys):\n"
"event['data'].keys(): {}\n"
"event['timestamps'].keys(): {}\n"
"descriptor['data_keys'].keys(): {}\n".format(
Expand Down

0 comments on commit c565a96

Please sign in to comment.