From 97c4053c1f94e09bcf0f463b44aad894868a625a Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Wed, 5 Jun 2024 09:07:01 -0500 Subject: [PATCH 1/4] add diffing --- core/dbt/cli/requires.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/core/dbt/cli/requires.py b/core/dbt/cli/requires.py index 01425d8db9b..bb35e7c7859 100644 --- a/core/dbt/cli/requires.py +++ b/core/dbt/cli/requires.py @@ -45,6 +45,7 @@ Recorder, RecorderMode, get_record_mode_from_env, + get_record_types_from_dict, get_record_types_from_env, ) from dbt_common.utils import cast_dict_to_dict_of_strings @@ -111,7 +112,16 @@ def setup_record_replay(): recorder: Optional[Recorder] = None if rec_mode == RecorderMode.REPLAY: recording_path = os.environ.get("DBT_RECORDER_FILE_PATH") - recorder = Recorder(RecorderMode.REPLAY, types=rec_types, recording_path=recording_path) + recorder = Recorder( + RecorderMode.REPLAY, types=rec_types, previous_recording_path=recording_path + ) + elif rec_mode == RecorderMode.DIFF: + previous_recording_path = os.environ.get("DBT_RECORDER_FILE_PATH") + # ensure types match the previous recording + types = get_record_types_from_dict(previous_recording_path) + recorder = Recorder( + RecorderMode.DIFF, types=types, previous_recording_path=previous_recording_path + ) elif rec_mode == RecorderMode.RECORD: recorder = Recorder(RecorderMode.RECORD, types=rec_types) @@ -122,7 +132,11 @@ def tear_down_record_replay(): recorder = get_invocation_context().recorder if recorder is not None: if recorder.mode == RecorderMode.RECORD: - recorder.write("recording.json") + recorder.write() + if recorder.mode == RecorderMode.DIFF: + # write out result of recording to it was be referred to as needed + recorder.write() + recorder.write_diffs(diff_file_name="diffs.json") elif recorder.mode == RecorderMode.REPLAY: recorder.write_diffs("replay_diffs.json") From d00b84c6524f1bd76880a83638b3b4a0a0014170 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Wed, 12 Jun 2024 14:57:22 -0500 Subject: [PATCH 2/4] WIP --- core/dbt/cli/requires.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dbt/cli/requires.py b/core/dbt/cli/requires.py index bb35e7c7859..2d4377aaf10 100644 --- a/core/dbt/cli/requires.py +++ b/core/dbt/cli/requires.py @@ -111,9 +111,9 @@ def setup_record_replay(): recorder: Optional[Recorder] = None if rec_mode == RecorderMode.REPLAY: - recording_path = os.environ.get("DBT_RECORDER_FILE_PATH") + previous_recording_path = os.environ.get("DBT_RECORDER_FILE_PATH") recorder = Recorder( - RecorderMode.REPLAY, types=rec_types, previous_recording_path=recording_path + RecorderMode.REPLAY, types=rec_types, previous_recording_path=previous_recording_path ) elif rec_mode == RecorderMode.DIFF: previous_recording_path = os.environ.get("DBT_RECORDER_FILE_PATH") From d35d6d8e47b70a1607954b100e02b52e4f86f5ad Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Mon, 17 Jun 2024 14:21:52 -0500 Subject: [PATCH 3/4] change file name --- core/dbt/cli/requires.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/dbt/cli/requires.py b/core/dbt/cli/requires.py index 2d4377aaf10..e4700706b15 100644 --- a/core/dbt/cli/requires.py +++ b/core/dbt/cli/requires.py @@ -136,7 +136,7 @@ def tear_down_record_replay(): if recorder.mode == RecorderMode.DIFF: # write out result of recording to it was be referred to as needed recorder.write() - recorder.write_diffs(diff_file_name="diffs.json") + recorder.write_diffs(diff_file_name="recording_diffs.json") elif recorder.mode == RecorderMode.REPLAY: recorder.write_diffs("replay_diffs.json") From 94cee97b084ac81fae4e86094b3ed45b26525bf5 Mon Sep 17 00:00:00 2001 From: Emily Rockman Date: Mon, 17 Jun 2024 16:48:40 -0500 Subject: [PATCH 4/4] Update core/dbt/cli/requires.py --- core/dbt/cli/requires.py | 1 - 1 file changed, 1 deletion(-) diff --git a/core/dbt/cli/requires.py b/core/dbt/cli/requires.py index e4700706b15..892705d9b0c 100644 --- a/core/dbt/cli/requires.py +++ b/core/dbt/cli/requires.py @@ -134,7 +134,6 @@ def tear_down_record_replay(): if recorder.mode == RecorderMode.RECORD: recorder.write() if recorder.mode == RecorderMode.DIFF: - # write out result of recording to it was be referred to as needed recorder.write() recorder.write_diffs(diff_file_name="recording_diffs.json") elif recorder.mode == RecorderMode.REPLAY: