-
Notifications
You must be signed in to change notification settings - Fork 18
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
SWE002 No mirroring (IVS-304) #333
base: development
Are you sure you want to change the base?
Conversation
Thanks for doing the dirty work to get to a resolution. I am trending in the same direction of adding to this step implementation to handle comparison on results of a calculation with my current WIP for linear placement in LIP002. I like the change to Also thanks for pointing out the dissonance on ALS004. I agree that the step should involve a check of entity type and not of attribute value. I've captured that as a to-do for the backlog. In terms of the larger clean up - yes, I can certainly agree that this implementation is a prime candidate for refactoring and housekeeping. I agree that @Ghesselink is the best candidate to lead but I will be happy to help if and where I can. @aothms do you think this PR is ready for review as-is or is there the possibility that resolution of the failing tests (looks like IFC102 and SPS007) will affect your work here on SWE002? |
Well as you said, Not sure if you were already on board at that time @civilx64 but Geert and I have long discussed whether we should make the separation between parameters and control language more clear in the scenarios. Something like:
Or some other permutation of brackets/parens/quotes/backticks/tildes to consistently indicate whether something is:
I don't know how far we would go there, maybe distinguishing between datatypes is a bit overkill, but anyway.
Maybe also something to formalize and think about as a new year resolution. Edit: OK tests do seem to be passing now (I don't have IFC4X3 schema locally, so not all tests run...) So I guess this is somewhat ready for review. Edit2: By all means would be happy if you're involved in any refactoring, just thought your plate is a bit full with alignment rules still. New rules I guess is always a priority :) |
I spent some time looking through the code, but I wasn’t sure where to start—it’s quite a mess. This is probably a good moment to invest some effort in cleaning it up, as I feel the current solution, I tried to find some logical structure within the step implementations themselves, but perhaps we should reverse the process: start with a blank page and develop a coherent parsing strategy, rewrite the Gherkin steps using clearer language in the scenarios, and adjust the step implementations accordingly. Another con we noted back then was that the feature becomes less human-readable. We have now learned that not many people look at this feature file, and the souls that are brave enough to read them are probably also capable enough to read through brackets/quotes etc. To add even more complication; we are not even consistent with the way we quote some values. E.g.
and
When we mix these (using single instead of double), the behave parser doesn't pick it up ..
I think this was the first step of 'cornering' ourselves; we stepped back from writing two separate steps for this because of inheritance. Instead of
Because with he latter we still have access to The good news is that the its type is X implementation is equivalent to the Given statement. This means we could perform a simple check and return an Outcome: If the condition is true, yield an Outcome with PASSED severity.
Again, sometimes yes and sometimes not ..
In these cases, the simplification works. Issues start arising when we say the attribute must be
Perhaps a good plan would then be to
For the latter, let's start with the mentioned categories; prose used for matching ; opening and closing square brackets []
|
7cf3e39
to
6854cb0
Compare
Some WIP progress trying it out :) |
I like the readability of what you're proposing here. But only glanced through it quickly.
Anyway, just some additional ideas... Let's discuss |
I think so, yes. We're now categorizing implemenations into a
Furthermore, many Then steps can be reformulated to fit into this category.
So the pattern we use would probably be something like
So instead of the previous example, we'd have then simply one statement
I'm afraid the boat 'easy for new comers' sailed away a while ago.
Can be re-written to
|
@E00050 | ||
Feature: SWE002 - Mirroring within IfcDerivedProfileDef shall not be used | ||
|
||
The rule verifies that IfcDerivedProfileDef is |
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.
truncated description?
I don't remember it but it does make sense.
+1
I would vote against heading this direction and sticking with something more transparent like Geert's example @step_impl('.{schema_construct}. is "{literal_string}"') -> for Given
@step_impl('.{schema_construct}. must be "{literal_string}"') -> for Then
def step_impl(context, inst, schema_construct, literal_string):
if not check:
return ERROR
else:
return PASSED So how do we move forward? The WIP branch appears to be a solid step in a great direction but unfortunately is blocking any further rule development ATM. I would like to finalize LIP002 but there are considerable moving parts on both the geometric calculation and comparison side:
as well as on the feature file itself:
|
Don't let it block you :-) If it's merged before the WIP, I'll address the conflicts (some help would probably be nice).
I'm not sure if it answers the question, but I think this
I'd think just
And then behave will match |
@civilx64 @Ghesselink I had a bit of a nasty regression here that took me some time to figure out, see ee42006 (tests still failing though...)
I added a 'shortcut' to "The value of attribute {attribute} must be ... " because I wanted to reuse the operators we have defined there. However I don't want to apply it to an attribute value, but to the result of some calculation (matrix determinant) so I had to alias out the "of attribute {attribute}".
ifc-gherkin-rules/features/steps/thens/attributes.py
Lines 64 to 90 in ee42006
In doing so the step became ambiguous with the following:
ifc-gherkin-rules/features/steps/thens/values.py
Lines 109 to 117 in ee42006
However, Behave never warned me about the ambiguous step (maybe because we have more complex custom parse types??) so all of a sudden a large amount of tests started failing and it took me a long time to figure out that this was because the steps got directed to another implementation.
What didn't help was that I felt there was a bit of a gap in the feature file I first looked at, because we directly compare the value of an entity instance to the expected type, I would have expected something with "its entity type".
ifc-gherkin-rules/features/ALS004_Alignment-segment-shape-representation.feature
Lines 31 to 32 in ee42006
So we kind of saw this coming, we have the same functionality in a bunch of permutations:
This was expected because we keep adding adhoc things and because we can only match full sentences.
Another problem I have is with the cognitive load of the attributes.py impl I referenced first here. It's not very consistent, with all the branches: there is the expression, the empty / not empty handling and now my regex with binary operands. All have different behaviour, functionality and assumptions.
I think this would be a good candidate to clean up a bit. For example by uplifting the inline binary operators to a new implementation function with those binary ops as a full blown parse type. As a guideline (not strict rule) I think we should aim for no top-level branches in the implementation functions with different functionality. I know this can be tricky with making unique sentences.
@Ghesselink as the most familiar person with all the rules and the most eager cleaner upper, is this something you'd like to tackle in the new year?