generated from dbt-labs/dbt-oss-template
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix unset_contextvars to correctly unset the context vars (#83)
* Fix unset_contextvars to actually unset the right vars * Changie * Add test
- Loading branch information
Showing
3 changed files
with
36 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
kind: Fixes | ||
body: Fix the unset_contextvars function in events/contextvars.py | ||
time: 2024-02-21T20:02:04.341681-05:00 | ||
custom: | ||
Author: gshank | ||
Issue: "82" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from dbt_common.events.contextvars import log_contextvars, get_node_info, set_log_contextvars | ||
|
||
|
||
def test_contextvars(): | ||
node_info = { | ||
"unique_id": "model.test.my_model", | ||
"started_at": None, | ||
"finished_at": None, | ||
} | ||
with log_contextvars(node_info=node_info): | ||
assert node_info == get_node_info() | ||
new_node_info = { | ||
"unique_id": "model.test.my_model", | ||
"started_at": "01-01-2024", | ||
"finished_at": None, | ||
} | ||
set_log_contextvars(node_info=new_node_info) | ||
assert get_node_info() == new_node_info | ||
|
||
# Ensure that after the context manager ends, the node_info is gone | ||
assert get_node_info() == {} |