Skip to content
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

suite_state: don't return null db results #2440

Merged
merged 2 commits into from
Oct 19, 2017

Conversation

hjoliver
Copy link
Member

@hjoliver hjoliver commented Oct 9, 2017

cylc suite-state fails if querying a task output message from a task proxy that exists (or existed before suite shutdown) but which has not generated its message output yet. E.g.:

[cylc]
    cycle point format = %Y
[scheduling]
    initial cycle point = 2010
    final cycle point = 2012
    [[dependencies]]
        [[[P1Y]]]
          graph = "foo:x => bar"
[runtime]
    [[foo]]
        script = cylc message "the quick brown fox"
        [[[outputs]]]
            x = "the quick brown fox"
    [[bar]]
        script = true

Run this suite to completion. It shuts down with waiting task proxies recorded in the final+1 cycle (2013):

$ cylc suite-state baz
foo, 2010, succeeded
bar, 2010, succeeded
foo, 2011, succeeded
foo, 2012, succeeded
bar, 2011, succeeded
foo, 2013, waiting  # <---
bar, 2012, succeeded
bar, 2013, waiting  # <---

Querying foo's output message is fine for succeeded instances, and non-existent instances:

$ cylc suite-state -t foo -p 2012 -m 'the quick brown fox' --max-polls=1 baz
checking for 'output: the quick brown fox': satisfied

$ cylc suite-state -t foo -p 2014 -m 'the quick brown fox' --max-polls=1 baz
checking for 'output: the quick brown fox'
ERROR: condition not satisfied

But not for the instance that exists but has not recorded an output yet:

cylc suite-state -t foo -p 2013 -m 'the quick brown fox' --max-polls=1 baz
checking for 'output: the quick brown fox''NoneType' object has no attribute 'splitlines'

This seems to be because the DB task_outputs table has a column for the messages of all existing task proxies that register outputs, unpopulated until the message is received, until which time a query returns (None, ) rather than None.

This change fixes it.

@@ -107,7 +107,8 @@ def suite_state_query(

res = []
for row in self.conn.execute(stmt, stmt_args):
res.append(list(row))
if not all(v is None for v in row):
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(there might be a better way to do this?)

@hjoliver
Copy link
Member Author

hjoliver commented Oct 9, 2017

(I'll make a test out of the example...) test added

@matthewrmshin matthewrmshin added this to the next release milestone Oct 9, 2017
Copy link
Contributor

@matthewrmshin matthewrmshin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issue. The approach is good.

@oliver-sanders oliver-sanders merged commit 3bcff64 into cylc:master Oct 19, 2017
@hjoliver hjoliver deleted the suite-state-pre-msg branch October 19, 2017 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants