-
Notifications
You must be signed in to change notification settings - Fork 189
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
feat(core): require
conditional action
#866
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to use try-except, just check the value and throw. Also no need return value. Also, is lhs
and rhs
too rigid? How do we handle container emptiness checks? Would we have to do:
lhs: FN.length(<container>)
rhs: 0
condition: ==
Since people might try using this, let's keep returning |
Container checks will be a separate action https://www.tines.com/docs/actions/types/trigger/ Tines throws a bunch of stuff all in a single action with a dropdown for options. That's not very user friendly imo. |
Also on closer look maybe not too rigid, all of Tines trigger rules are LHS, RHS, or regex Can you think of any other cases other than is empty which operates on a single value? |
Aren't |
Any kind of |
Following our private discussion, I'll drop lhs and rhs and instead use a |
138f403
to
884da94
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, i think would be great if you could add an actual action template run to test your main usecase (throwing from template). See test_registry
for examples on running template actions
@pytest.mark.parametrize( | ||
"exprs", | ||
[ | ||
True, | ||
[True, True], | ||
[True, True, True], | ||
], | ||
) | ||
def test_require_all(exprs): | ||
assert require(exprs) is True | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"exprs", | ||
[ | ||
False, | ||
[True, False], | ||
[False, True], | ||
], | ||
) | ||
def test_require_all_fail(exprs): | ||
with pytest.raises(AssertionError): | ||
require(exprs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
check empty list behavior as well?
What changed
require
action that takes one or moreexprs
exprs
is not entirely accurate, sincerequire
functions likereshape
(a more accurate argument might be bool, but from the UI perspective might be misleading since what the user sees is the template expression not bool). I went forexprs
for user clarity over functional accuracy.require
becauseassert
is a key variable in python.require
is used in Kotlin and Soliditycore.require
is semantic closest what to what I want it to do in templates (e.g. require URLScan POST result to have a successful status otherwise fail).Bigger changes
is not
andnot in
are at the front to avoidis
andin
being evaluated firstOPERATORS
infunctions.py
QA
registry/test_core_require.py
which just checks bools as inputs (i.e.as post evaluated templates)test_expression_binary_ops
with a case for each operator tounit/test_expressions.py
Future considerations
match_any
?require
in a workflow, but I'm just relying on induction: sincerequire
is logically equivalent tocore.transform.reshape
except it supports lists of exprs, which we do test.Prior art