-
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
Task state code refactor. #1775
Conversation
+1 from me for moving from strings to constants (e.g. state.WAITING_STATE over 'waiting') - pretty much for the typos reason you give above |
This would be good for performance - |
I'll get rid of
|
afc796f
to
dc9774e
Compare
@matthewrmshin - this is ready to review, test battery passes here. Description updated above. (note I backed out of a more extensive refactoring of task_proxy module, will email re this later...). (I do intend to add some more docstrings yet) |
Test battery OK (with and without
|
(I'll attempt to look at this change in detail tomorrow.) |
The handling of state, prerequisites, outputs, retries, incoming messages, events, DB writes, etc., in the task_proxy module has become increasingly detailed and unnecessarily tangled, and IMO the whole thing could use a complete redesign, to abstract out the messy detail. I actually made a start on it in this branch (because moving prereqs and outputs to task_state.py goes a little way toward that goal) but I backed out of it pretty quickly because it could be a lot of work and a difficult change to review, and for no functional purpose at this point. However, I thought I'd just flag that this should probably be done at some point in the future... |
|
||
suite = args.pop(0) | ||
|
||
prompt('Reset task(s) %s in %s' % (args, suite), options.force) |
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.
Spawn instead of Reset?
5a26daa
to
f955d79
Compare
Rebased. |
Branch needs rebase again, I am afraid. |
self.legal_task_states = TaskState.legal_for_restricted_monitoring | ||
else: | ||
self.legal_task_states = TaskState.legal | ||
self.legal_task_states = TASK_STATUSES_RESTRICTED |
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 think self.legal_task_states
needs to be set regardless. I am getting a traceback on View > Task Filtering
.
Traceback (most recent call last):
File "/home/matt/cylc.git/lib/cylc/gui/app_gcylc.py", line 3150, in popup_filter_dialog
self.create_task_filter_widgets()
File "/home/matt/cylc.git/lib/cylc/gui/app_gcylc.py", line 2911, in create_task_filter_widgets
n_states = len(self.legal_task_states)
AttributeError: 'ControlApp' object has no attribute 'legal_task_states'
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.
Good spotting, I should have tested that.
f955d79
to
38e69f7
Compare
Branch rebased, bug fixed. A minor thing I forget to mention above - this PR also makes the gcylc task right-click View menu a bit more context sensitive: for submitted, submit-failed, and submit-retrying tasks you can view job script and activity log, but not job logs. |
707f70d
to
c42c7ef
Compare
Branched rebased, tests passing. |
Sorry for conflicting this one up! |
Again! But never mind, it's worth it! |
17fe934
to
3bdb067
Compare
@hjoliver Sorry, but as usual, this branch is in conflicts again. We should aim to merge this in as soon as possible so that we can be testing with it in for most of the new release cycle. |
(I'll sort out the conflicts as soon as possible...) |
c42c7ef
to
fe47835
Compare
@matthewrmshin - branch rebased, tests pass here. It might be a good idea for @benfitzpatrick to take a quick look at this too, to check my resolution of the conflicts with his changes #1813 and #1819. |
Looks OK. Tests OK (with and without global configuration) in my environment. @benfitzpatrick please review 2. |
@@ -333,7 +337,8 @@ class restart(Scheduler): | |||
for line in task_lines: | |||
# instance variables | |||
try: | |||
(id_, state) = line.split(' : ') | |||
(id_, state_string) = line.split(' : ') | |||
# state_string e.g. 'status=running, spawned=false' |
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.
=False
Looks like it leads to a speedup! Great! |
Refactor the code associated with handling of task state/status.
[updated 13 April - original lines
crossed out]Motivation: working on another current pull request, I was bitten by a typo in a task status string comparison, which wouldn't happen if we used (constant) variables to refer to states like "waiting" etc. (which would be better for internationalization too, if it comes to that at some point...). Further, each task proxy currently holds its status in a "task_state" object that is (a) next to useless - it contains just a status string, and some minimal logic that is largely duplicated in wrapper methods in the task proxy class anyway; and (b) also holds "spawned/not spawned" status in a silly two-key dict along with "status", which doesn't make much sense. This is all dates back a long way, before I learned a few things off @cylc/core members 😬
So: this PR does the following:
gets rid of the task state objects (now just a status string held by task proxies)task_state
module now defines aTaskState
class that (for each task proxy) holds the simple status string, and prerequisites and outputs (which are intimately connected to task status), plus associated logic.STATUS_WAITING = 'waiting'
, and these are now used throughout the code.state.is_currently()
andstate.get_status()
methods with static set membership tests, for performance reasons (as pointed out by @benfitzpatrick below).@matthewrmshin - this isn't quite ready - I still need to use STATUS_WAITING etc. throughout the code instead of hard-coded strings "waiting" etc.; add a test for "cylc spawn", and address a few TODO comments left in the code (mainly for checking valid status at various points). However, as this grew a bit bigger than I was expecting, I just wanted to post the branch as-is before the weekend in case of any fundamental objections, or suggestions for improvement. Test battery passes on this branch at the moment.