Skip to content

Commit

Permalink
in dagstermill test, don't dump entire dagster event to json (#21463)
Browse files Browse the repository at this point in the history
## Summary & Motivation

In general, DagsterEvents are not always json-dumpable (e.g. they
contain enums), but this test assumes they are. This causes problems
when moving from `NamedTuple` (which are json-dumpable) to
`DagsterModel` (which are not json-dumpable) for classes within
`DagsterEvent`s.

## How I Tested These Changes
  • Loading branch information
sryza authored Apr 29, 2024
1 parent 7b103db commit 557627c
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ def __init__(self, file_path):

def emit(self, record):
with open(self.file_path, "a", encoding="utf8") as fd:
fd.write(seven.json.dumps(record.__dict__) + "\n")
fd.write(
seven.json.dumps({"the_message": record.__dict__["dagster_meta"]["orig_message"]})
+ "\n"
)


@logger(config_schema={"name": String, "log_level": String, "file_path": String})
Expand Down Expand Up @@ -123,10 +126,10 @@ def test_logging(hello_logging_job_type) -> None:
if line
]

messages = [x["dagster_meta"]["orig_message"] for x in records]
messages = [x["the_message"] for x in records]

assert "Hello, there!" in messages

critical_messages = [x["dagster_meta"]["orig_message"] for x in critical_records]
critical_messages = [x["the_message"] for x in critical_records]

assert "Hello, there!" not in critical_messages

0 comments on commit 557627c

Please sign in to comment.