Skip to content

Conversation

@ChenyuLInx
Copy link
Contributor

@ChenyuLInx ChenyuLInx commented Jan 31, 2023

resolves #6701
This moves the remaining default to cli/flags.py
We still have a few being accessed by legacy logger that remains in flags module.

TODO

  • with the new dbtRunner, we would initialize the global flag object again when running the actually dbt command. This would make previously set project_dir and profiles_dir at link not carried over and cause some additional tests fail.

@cla-bot cla-bot bot added the cla:yes label Jan 31, 2023
@ChenyuLInx ChenyuLInx changed the base branch from main to feature/click-cli January 31, 2023 05:18
@ChenyuLInx ChenyuLInx added the Skip Changelog Skips GHA to check for changelog file label Jan 31, 2023
@ChenyuLInx ChenyuLInx closed this Jan 31, 2023
@ChenyuLInx ChenyuLInx reopened this Jan 31, 2023

# set the default flags
for key, value in flag_defaults.items():
object.__setattr__(self, key, value)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not directly related to this changeset, so feel free to ignore this comment.

I think this flags code would be simpler and more readable if we added _get_flag() and _set_flag() functions which handled the casing concerns and the use of the setattr/getattr functions.

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, I was chatting with @MichelleArk about similar thing also. @iknox-fa might have something around it, but we are gonna defer that to work later on instead of in this PR

Copy link
Contributor

Choose a reason for hiding this comment

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

I didn't do that the first time around because I wanted to keep things as immutable as python allows so adding even a "private" method to do that seemed like a recipe for mutated flags in the codebase in a few months.

Maybe as a compromise for readability we just make nested get and set functions in init? That way no-one uses them unless they're directly editing the flags? We can discuss it further but given how much of a tangled mess the flags are currently I think we're going to get a lot of mileage out of having reasonable assurance of immutability and I don't want to jeopardize that.

@ChenyuLInx ChenyuLInx force-pushed the cl/consolidate_flags branch from 5498310 to 2b7afc8 Compare February 1, 2023 01:32
@ChenyuLInx ChenyuLInx closed this Feb 1, 2023
@ChenyuLInx ChenyuLInx reopened this Feb 1, 2023
@ChenyuLInx ChenyuLInx marked this pull request as ready for review February 1, 2023 01:34
@ChenyuLInx ChenyuLInx requested a review from a team as a code owner February 1, 2023 01:34
@ChenyuLInx ChenyuLInx requested a review from a team February 1, 2023 01:34
@ChenyuLInx ChenyuLInx requested review from a team as code owners February 1, 2023 01:34
@ChenyuLInx ChenyuLInx requested review from gshank and nssalian February 1, 2023 01:34
f"Duplicate flag names found in click command: {param_name}"
)
else:
if param_name not in params_assigned_from_default:
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure this is working as expected. params_assigned_from_default isn't an accurate representation of which params have not been set by the user within assign_params as the assign_params method itself is what populates params_assigned_from_default recursively.

check out the breaking test: tests/functional/simple_seed/test_seed.py::TestBasicSeedTests::test_simple_seed_full_refresh_flag, which sets --full-refresh by the user but is not reflected in Flags.

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 with new logic, slightly cleaner, I would like to defer the duplicate param issue to a new issue, maybe after merge. @iknox-fa thoughts?

Copy link
Contributor

@aranke aranke left a comment

Choose a reason for hiding this comment

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

Looks fine to me.

@ChenyuLInx ChenyuLInx removed request for a team, gshank and nssalian February 1, 2023 21:56
@ChenyuLInx ChenyuLInx force-pushed the cl/consolidate_flags branch from 9095034 to 003ad78 Compare February 2, 2023 01:03
@MichelleArk MichelleArk force-pushed the cl/consolidate_flags branch 2 times, most recently from 9dcea2f to 09c1171 Compare February 4, 2023 00:21

class TestDbtRunner:
@pytest.fixture
def dbt(self) -> dbtRunner:
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels like gonna introduce some overhead of setting up the project to unittests?

@ChenyuLInx ChenyuLInx force-pushed the cl/consolidate_flags branch from abcb34c to 9b9c908 Compare February 7, 2023 15:47
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-1885] [Feature] Remove flags.py

7 participants