-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
[CT-3137] [Bug] dbt retry: Path
-type flags passed to retry
should override params from previous invocation
#8682
Comments
I am afraid that this will be especially tricky. We have access to the resolved If we just use the
Update: I'm not going to pretend that I like any part of this, but it does appear to kinda sorta get the job done here: self.previous_args = self.previous_state.results.args
# massive hack: allow 'dbt retry --explicit --cli-flags' to override previous flags
# I do not know if/how this could also support **kwargs passed into dbtRunner.invoke
new_cli_args = {
k: v
for k, v in self.args.__dict__.items()
if f"--{k.replace('_','-')}" in self.args.invocation_command.split(" ")
}
for key, value in new_cli_args.items():
self.previous_args[key] = value
self.previous_command_name = self.previous_args.get("which")
|
@peter-bertuglia made a great point. In the event that we're retrying an invocation which had previously enabled deferral, the subsequent invocation will want:
As above, plus: # massive hack: override previous args with new CLI args
...
# also allow overriding DEFER_STATE via env var (but only this)
# however: would this cause issues if the command being retried *doesn't* support --defer-state?
# right now that is only true of 'run-operation'
if self.args.defer_state:
self.previous_args["defer_state"] = defer_state |
After discussing further with @peterallenwebb: These "overrides" are really just needed for "path" configs specific to the file system, because the subsequent So rather than the hackery I had above ("only override configs that are present in the |
Path
-type flags passed to retry
should override params from previous invocation
Is this a new bug in dbt-core?
Current Behavior
Previous invocation's flags (loaded from
args
inrun_results.json
) are always used, even if CLI flags are explicitly passed into theretry
command:dbt-core/core/dbt/task/retry.py
Line 68 in 34ab4cf
dbt-core/core/dbt/task/retry.py
Lines 83 to 95 in 34ab4cf
Expected Behavior
CLI flags passed explicitly into the
dbt retry
command should override flags read in from the previous invocation.I could see this getting hairy when we think about the config hierarchy of flags > env vars > user configs (in profiles.yml). I think the precedence order should be:
--state
which may also be passed via env var (!)This assumes that the env vars (save
--state
) + user configs ought to be the same across both invocations. That is an assumption, but it feels like a reasonable one. What feels bad about this is that we're breaking the 1:1 mapping between CLI flags (--project-dir
) and env vars (DBT_PROJECT_DIR
), just forretry
.Steps To Reproduce
proj_location_1/
with a failing model:proj_location_1
→proj_location_2
dbt retry
pointing toproj_location_2
, butdbt retry
still usesproj_location_1
Relevant log output
No response
Environment
Which database adapter are you using with dbt?
postgres
Additional Context
No response
The text was updated successfully, but these errors were encountered: