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(actors): Allow boolean-like values for SKIP_DRY #538

Merged
merged 7 commits into from
Jan 21, 2025
Merged

Conversation

LaikaN57
Copy link
Member

@LaikaN57 LaikaN57 commented Jan 18, 2025

Fixes a usability issue where regardless of the value of DRY, if SKIP_DRY was true you would get the following message:

19:47:50 WARNING
19:47:50 WARNING *** You have disabled the dry run.
19:47:50 WARNING *** Execution will begin with no expectation of success.
19:47:50 WARNING

The way the logic works after this PR is thusly...

DRY SKIP_DRY Operations
TRUE ✅ TRUE ✅ - Run Dry ☀️
TRUE ✅ FALSE ❌
(default)
- Run Dry ☀️
FALSE ❌ TRUE ✅ - Print Warning ⚠
- Run Wet 💦
FALSE ❌ FALSE ❌
(default)
- Run Dry ☀️
- Run Wet 💦

Comment on lines -353 to -374
def str2bool(self, v, strict=False):
"""Returns a Boolean from a variety of inputs.

Args:
value: String/Bool
strict: Whether or not to _only_ convert the known words into booleans, or whether to allow "any" word to be considered True other than the known False words.

Returns:
A boolean
"""
false = ("no", "false", "f", "0")
true = ("yes", "true", "t", "1")

string = str(v).lower()

if strict:
if string not in true and string not in false:
raise exceptions.InvalidOptions(
"Expected [%s, %s] but got: %s" % (true, false, string)
)

return string not in false
Copy link
Member Author

Choose a reason for hiding this comment

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

Moved to kingpin.utils for use in non-actor classes.

docs/conf.py Show resolved Hide resolved
@LaikaN57 LaikaN57 marked this pull request as draft January 18, 2025 04:02
Comment on lines +501 to +520
def str2bool(v, strict=False) -> bool:
"""Returns a Boolean from a variety of inputs.

Args:
value: String/Bool
strict: Whether or not to _only_ convert the known words into booleans, or whether to allow "any" word to be considered True other than the known False words.

Returns:
A boolean
"""
false = ("no", "false", "f", "0")
true = ("yes", "true", "t", "1")

string = str(v).lower()

if strict:
if string not in true and string not in false:
raise ValueError(f"Expected [{true}, {false}] but got: {string}")

return string not in false
Copy link
Member Author

Choose a reason for hiding this comment

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

From deleted function above.

Comment on lines +361 to +365
try:
check = utils.str2bool(self._condition)
self.log.debug("Condition %s evaluates to %s" % (self._condition, check))
except ValueError as e:
raise exceptions.InvalidOptions(e.args) from e
Copy link
Member Author

Choose a reason for hiding this comment

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

Added try-except to convert the raised error to maintain correct raise types outside function.

@LaikaN57 LaikaN57 marked this pull request as ready for review January 18, 2025 04:17
@LaikaN57 LaikaN57 changed the title fix: Allow boolean-like values for SKIP_DRY fix(actors): Allow boolean-like values for SKIP_DRY Jan 18, 2025
@LaikaN57 LaikaN57 requested a review from diranged January 18, 2025 19:39
@LaikaN57 LaikaN57 merged commit a8edf8b into main Jan 21, 2025
2 checks passed
@LaikaN57 LaikaN57 deleted the adk-fix-skip-dry branch January 21, 2025 18:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants