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

fix small issues with flags and logger to support dbt-rpc #6990

Merged
merged 4 commits into from
Feb 17, 2023

Conversation

ChenyuLInx
Copy link
Contributor

@ChenyuLInx ChenyuLInx commented Feb 16, 2023

resolves #6979 dbt-labs/dbt-rpc#122

The helper functions are not in ideal situation but I think we can revisit them in the revisit of Flags module that's happening soon

@ChenyuLInx ChenyuLInx requested a review from a team February 16, 2023 01:48
@ChenyuLInx ChenyuLInx requested review from a team as code owners February 16, 2023 01:48
@ChenyuLInx ChenyuLInx requested review from stu-k and emmyoop February 16, 2023 01:48
@cla-bot cla-bot bot added the cla:yes label Feb 16, 2023
@ChenyuLInx ChenyuLInx added the Skip Changelog Skips GHA to check for changelog file label Feb 16, 2023
@github-actions
Copy link
Contributor

Thank you for your pull request! We could not find a changelog entry for this change. For details on how to document a change, see the contributing guide.

@@ -133,7 +140,7 @@ def cleanup_event_logger():
EVENT_MANAGER.add_logger(
_get_logbook_log_config(debug=False) # type: ignore
if ENABLE_LEGACY_LOGGER
else _get_stdout_config(log_format="text", debug=False, use_colors=True) # type: ignore
else _get_stdout_config(log_format="text", debug=False, use_colors=True, log_cache_events=True, quiet=False) # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'll want log_cache_events=False by default

FYI @peterallenwebb since you're:

To be honest, I don't know if it's possible, and it might be motivation for us to really finally uncouple UserConfig from profiles.yml (#6207), so that we can have a configured logger before we need to parse the profile (and encounter any warnings)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, what exactly does it do?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Super verbose logging every time a relation is added, removed, updated from the cache. Adds a ton of noise in the general case, but very useful to turn on when debugging issues that might be due to cache misses/inconsistencies

@ChenyuLInx ChenyuLInx force-pushed the cl/fix_logbook_rebased branch from 6945d8a to 3f4c6f9 Compare February 16, 2023 19:40
@ChenyuLInx ChenyuLInx requested review from racheldaniel and removed request for emmyoop February 16, 2023 19:40
@@ -49,13 +49,33 @@ def convert_config(config_name, config_value):
# This function should take care of converting the values from config and original
# set_from_args to the correct type
ret = config_value
if config_name.lower() == "warn_error_options":
if config_name.lower() == "warn_error_options" and type(config_value) == dict:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this change necessary? Shouldn't warn_error_options always be a dictionary?

Docs: https://docs.getdbt.com/reference/global-configs#warnings-as-errors

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are other places that passes in something that's not a dict. I can do another round of verify it is a dict and update input from other places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remember why, it is because the default value for warn_error_options in UserConfig is None, so if you pass in a UserConfig object the original logic would fail

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 gotcha. config_value is not None would be more precise here then

ret = WarnErrorOptions(
include=config_value.get("include", []), exclude=config_value.get("exclude", [])
)
return ret


def args_to_context(args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missing typing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@@ -89,14 +88,18 @@ def get_dbt_config(project_dir, args=None, single_threaded=False):
target=getattr(args, "target", None),
)

# set global flags from arguments
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The functions in this file are still by large untested, gonna revisit to replace this file and test the interfaces we have to replace it.

sub_command_name, sub_command, args = cli.resolve_command(cli_ctx, args)

# handle source and docs group
if type(sub_command) == Group:
Copy link
Contributor

@MichelleArk MichelleArk Feb 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we only have one level of Group nesting at the moment (sources and docs, as you mentioned in the comment), but we could make this a while instead so that it works for multiple levels of Groups too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Planning on revisit all of this and add more things to it as we rethink the flags object.

ret = WarnErrorOptions(
include=config_value.get("include", []), exclude=config_value.get("exclude", [])
)
return ret


def args_to_context(args):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the intended usage of this method? Is it just to create a click context that can be used to construct a Flags instance, or would we also want callers invoking the click command on the built context? If it's just the first use case, perhaps we could add this as a class method on Flags instead, and get eventually use it to get rid of set_from_args?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it is, and that's what I mean by Flag object is leaky.
The only place that uses this right now is in dbt-rpc, and we are gonna deprecate it in 1.6. So I am thinking of merging this change for now to make the 1.5 beta release, and do a revisit of the whole flags object before final cut of 1.5

@ChenyuLInx ChenyuLInx closed this Feb 17, 2023
@ChenyuLInx ChenyuLInx reopened this Feb 17, 2023
@ChenyuLInx ChenyuLInx merged commit c952d44 into main Feb 17, 2023
@ChenyuLInx ChenyuLInx deleted the cl/fix_logbook_rebased branch February 17, 2023 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla:yes Skip Changelog Skips GHA to check for changelog file
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[CT-2123] [Bug] Flags are referenced incorrectly (and sometimes at the wrong time) in functions.py
5 participants