abseil / abseil-py

Abseil Common Libraries (Python)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Easily logging the value of a flag

agamrafaeli opened this issue · comments

Any time the values of flags will be managed by an external tool to abseil-py there will constantly be a sync-tension in regards to what the actual value of the flag is on one run of the program. Currently my way of dealing with this is to log (or print?) the value of the flag.

Are there best practices regarding this?

If I open a PR with an option of logging the value of a flag when accessed (or defined?), are you open to this? Perhaps a change in __getattr__ of FlagValues? Happy to hear your thoughts and contribute a little.

Do you have a more concrete example? What does an external tool mean here? Is this a third_party library aside from your own code?

You said you already log (or print?) the value of the flag, does that work for you?

This probably doesn't apply here, but one of the best practices is actually to NOT change flag values after parsing from the command line. i.e. flags shouldn't be treated as mutable global variables.

And I don't think we'll log anything that isn't a warning/error in the flags library.

The way we currently set up is indeed not changing the flag after parsing from the command line. We have an elaborate system allowing setting different flag configurations for different environments in which the flags are deployed.

What I was imagining was an easy way to start printing the flag value after it was parsed, without changing the code. Printing it requires changing the code. Maybe the right way to go about this is to write an internal util wrapper for abseil

Sounds like internal util wrapper works for you. Closing.