-
Notifications
You must be signed in to change notification settings - Fork 37
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
requires/types: introduce expression type (expr.py) #913
Conversation
IDK why the "Test / test (3.8, ubuntu-20.04) (pull_request)" job is failing, all tests are green in my env. I'll re-run them in a py3.8 environment and get to the bottom of it. |
79b363d
to
a993c18
Compare
@dosaboy fixed CI issues, ready for review. please feel free to ping me should you need to ask anything. |
This feature is intended to be used in conjunction with the aliasing feature: #929 |
a993c18
to
6516845
Compare
6516845
to
2eb6c70
Compare
2eb6c70
to
86d2594
Compare
Expression | ||
---------- | ||
|
||
Expressions allows the user to express a requirement in a human-readable domain specific language. It's purpose |
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.
Expressions allows the user to express a requirement in a human-readable domain specific language. It's purpose | |
Expressions allow the user to express a requirement in a human-readable domain specific language. Its purpose |
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.
Done
---------- | ||
|
||
Expressions allows the user to express a requirement in a human-readable domain specific language. It's purpose | ||
is to provide a simplified, clear an concise expression grammar to all requirement types, and eliminate redundancies. |
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.
is to provide a simplified, clear an concise expression grammar to all requirement types, and eliminate redundancies. | |
is to provide a simplified, clear and concise expression grammar for all requirement types and to eliminate redundancies. |
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.
Done
@@ -106,11 +106,13 @@ def huge_pages_enabled(self): | |||
|
|||
@property | |||
def hugetlb_to_mem_total_percentage(self): | |||
return round((self.Hugetlb * 100) / self.MemTotal) | |||
return (self.MemTotal and round( |
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.
Why add or 0
?
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.
Yeah, it's redundant since (int and int) would yield an int in either case.
PS for future travelers: The code is written this way to avoid division by zero.
86d2594
to
3d41ed8
Compare
c5efc64
to
06a1664
Compare
`expression` is a new requirement type that allows user to express a requirement in human-readable, SQL-like syntax. It has a proper grammar to allow user to write checks as easily digestable manner, which will improve the QOL for scenario writers and code reviewers. The grammar is constructed using `pyparsing` library. The current grammar supports the following constructs: - Keywords (True, False, None) - Constants (Integer, Float, String literal) - Runtime variables (Python properties) - Functions(len, not, file, systemd, read_ini, read_cert) - Arithmetic operators(sign, mul, div, add, sub, exp) - Comparison operators(<, <=, >, >=, ==, !=, in) - Logical operators(and, or, not) - Comments('#', '//', '/*...*/') Also, the following changes have been made: - Updated requirement_types.rst to document the new Expression requirement type. - Moved property resolver logic from YPropertyBase to PythonEntityResolver class. - Added `pyparsing` as a dependency. - Added unit tests for the new code, the coverage rate is 100 pct for the expr.py This patch rewrites some of the scenario checks in the new expression syntax to demonstrate the difference and provide examples. Signed-off-by: Mustafa Kemal Gilor <[email protected]>
06a1664
to
a4b7750
Compare
@dosaboy what's your opinion on this? Let me know should you decide to land this and I'll make the all required changes, should be there any. |
expression
is a new requirement type that allows users to express a requirement in human-readable, SQL-like syntax. It has proper grammar to allow users to write checks in as easily digestible manner, which will improve the QOL for scenario writers and code reviewers. The grammar is constructed using thepyparsing
library.Example:
With the alias patch, it'll look much prettier:
The current grammar supports the following constructs:
Also, the following changes have been made:
pyparsing
as a dependency.This patch rewrites some of the scenario checks in the new expression syntax to demonstrate the difference and provide examples.