-
Notifications
You must be signed in to change notification settings - Fork 94
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
Advanced exclusion syntax #2258
Conversation
|
lib/cylc/time_parser.py
Outdated
if excl_off: | ||
exclusion_point += excl_off | ||
exclusion_points.append(exclusion_point) | ||
except: |
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.
- To catch any exception use the
except Exception
, instead ofexcept BaseException
or justexcept
. - Indicate the most specific exception type in
except
block.
For example:
# Bad
try:
mapping[key]
except Exception:
...
# Better
try:
mapping[key]
except KeyError:
...
|
33339df
to
16b49bf
Compare
This has been refactored now so that the individual exclusion sequences are not separate types - they are the same class as the ISO8601Sequence type, just treated as exclusions. |
if ',' in exclusions: | ||
if (not exclusions.strip().startswith('(') or not | ||
exclusions.strip().endswith(')')): | ||
raise Exception("'%s': a list of exclusions must be " |
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.
@oliver-sanders you may have spaces before and after parentheses now.
I'm afraid I've found a bug.
|
OK, it will require a few changes if you want to combine points and sequences in the same exclusion list. Will have a look next week. |
You should be able to combine exclusion types in this format now:
|
This is looking really good. One question about integer cycling. By analogy with |
I will see if I can get this implemented today - requires some changes for integer sequence exclusions to be valid. |
Integer sequence exclusions now implemented. |
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.
This is working for me! I've a few comments but otherwise it looks good.
lib/cylc/cycling/iso8601.py
Outdated
|
||
try: | ||
self.p_iso_exclusions.append( | ||
point_parse(str(exclusion_point))) |
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.
What is the purpose of this point_parse(str(point))
?
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.
yes, it is redundant - removed
lib/cylc/cycling/iso8601.py
Outdated
@@ -281,9 +281,64 @@ def _iso_interval_nonzero(interval_string): | |||
return bool(interval) | |||
|
|||
|
|||
class ISO8601Exclusions(object): |
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.
The IntegerExclusions
and ISO8601Exclusions
classes look pretty much identical now. cylc.cycling.loader
provides abstractions for points/sequences, would it be possible to use this to consolidate these two classes?
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.
refactored as much as possible in latest commit
graph = wibble | ||
|
||
# Run hourly at 15 minutes past except every 3rd hour | ||
[[[ T-15!T-15/PT3H ]]] |
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.
I would be good to test the implicit version here too (T-15!PT3H
).
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.
Added the implicit case too
# Stacked sequences | ||
[[[ T0230, PT3H!(T09,T12), T1945 ]]] | ||
graph = dibble | ||
[runtime] |
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.
It would also be a good idea to add a test here with some arbitrary white-space around parenthesis to test for the parsing problem we had earlier.
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.
Added some arbitrary whitespace to one of these suite tests. (This is tested in the unit tests already - under the integer ones - which all use the same parse method to strip the whitespace/parentheses.
graph = bar | ||
[[[ P1 !(P2,6,8) ]]] | ||
graph = qux | ||
[runtime] |
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.
Could we add a test for implicit start/end context for integer cycling as well e.g. R/1/P2!P3
.
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.
Added
(this is generally looking good to me, just waiting for Oliver's points to be addressed before a final review) |
05157aa
to
6a443b4
Compare
Added extra tests now. |
6a443b4
to
c8dba9e
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.
Looks good to me!
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.
Very nice.
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.
It would be better to use here custom type of Exception instead of general Exception itself.
if ',' in exclusions: | ||
if (not exclusions.strip().startswith('(') or not | ||
exclusions.strip().endswith(')')): | ||
raise Exception("'%s': a list of exclusions must be " |
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.
Same as mentioned above
expression3 = "T01/PT1H! PT8H, (T06, T09)" | ||
expression4 = "T01/PT1H! T03, T06, T09" | ||
|
||
self.assertRaises(Exception, parse_exclusion, expression1) |
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.
Same as mentioned above
@duboviy - fair point, in general. Would you like to raise a Pull Request, or are you just "observing from afar"? |
@hjoliver just observing from afar |
Hi @duboviy Thanks for sending us your insight from afar 🔭 . Please rest assure that we are fixing these issues - as opportunities arise. |
@matthewrmshin great, thanks! |
Implements remaining features in issue #1960.
Exclusions can already be a simple list of points (as in PR #2244), but can now also be any valid datetime sequence.
Also adds an extra test suite
advanced_exclusions
to test-battery.