Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support DIFF as a recording mode #10263

Merged
merged 4 commits into from
Jun 20, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 16 additions & 3 deletions core/dbt/cli/requires.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -110,8 +111,17 @@

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)
previous_recording_path = os.environ.get("DBT_RECORDER_FILE_PATH")
recorder = Recorder(

Check warning on line 115 in core/dbt/cli/requires.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/cli/requires.py#L114-L115

Added lines #L114 - L115 were not covered by tests
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")

Check warning on line 119 in core/dbt/cli/requires.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/cli/requires.py#L119

Added line #L119 was not covered by tests
# ensure types match the previous recording
types = get_record_types_from_dict(previous_recording_path)
recorder = Recorder(

Check warning on line 122 in core/dbt/cli/requires.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/cli/requires.py#L121-L122

Added lines #L121 - L122 were not covered by tests
RecorderMode.DIFF, types=types, previous_recording_path=previous_recording_path
)
elif rec_mode == RecorderMode.RECORD:
recorder = Recorder(RecorderMode.RECORD, types=rec_types)

Expand All @@ -122,7 +132,10 @@
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:
recorder.write()
recorder.write_diffs(diff_file_name="recording_diffs.json")

Check warning on line 138 in core/dbt/cli/requires.py

View check run for this annotation

Codecov / codecov/patch

core/dbt/cli/requires.py#L135-L138

Added lines #L135 - L138 were not covered by tests
elif recorder.mode == RecorderMode.REPLAY:
recorder.write_diffs("replay_diffs.json")

Expand Down
Loading