Skip to content

Commit

Permalink
Record linearization in database
Browse files Browse the repository at this point in the history
  • Loading branch information
arjclark committed Mar 22, 2017
1 parent 7620af8 commit 4d20dff
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
3 changes: 0 additions & 3 deletions lib/cylc/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -954,9 +954,6 @@ def compute_family_tree(self):
if name not in self.runtime['first-parent descendants'][p]:
self.runtime['first-parent descendants'][p].append(name)

# for name in self.cfg['runtime']:
# print name, self.runtime['linearized ancestors'][name]

def compute_inheritance(self, use_simple_method=True):
if cylc.flags.verbose:
OUT.info("Parsing the runtime namespace hierarchy")
Expand Down
5 changes: 5 additions & 0 deletions lib/cylc/rundb.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ class CylcSuiteDAO(object):
TABLE_BROADCAST_EVENTS = "broadcast_events"
TABLE_BROADCAST_STATES = "broadcast_states"
TABLE_BROADCAST_STATES_CHECKPOINTS = "broadcast_states_checkpoints"
TABLE_LINEARIZATION = "linearization"
TABLE_SUITE_PARAMS = "suite_params"
TABLE_SUITE_PARAMS_CHECKPOINTS = "suite_params_checkpoints"
TABLE_SUITE_TEMPLATE_VARS = "suite_template_vars"
Expand Down Expand Up @@ -211,6 +212,10 @@ class CylcSuiteDAO(object):
["time"],
["event"],
],
TABLE_LINEARIZATION: [
["namespace", {"is_primary_key": True}],
["linearization"],
],
TABLE_SUITE_PARAMS: [
["key", {"is_primary_key": True}],
["value"],
Expand Down
8 changes: 8 additions & 0 deletions lib/cylc/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -1190,6 +1190,14 @@ def configure_suite(self, reconfigure=False):
self.suite_state = StateSummaryServer.get_inst(self.run_mode)
self.comms_daemon.connect(self.suite_state, COMMS_STATE_OBJ_NAME)

for namespace in self.config.cfg['runtime']:
ancestors = (' ').join(
self.config.runtime['linearized ancestors'][namespace])
self.pri_dao.add_insert_item(CylcSuiteDAO.TABLE_LINEARIZATION,
[namespace, ancestors])
self.pub_dao.add_insert_item(CylcSuiteDAO.TABLE_LINEARIZATION,
[namespace, ancestors])

def configure_suite_environment(self):
"""Configure suite environment."""
# Pass static cylc and suite variables to job script generation code
Expand Down
7 changes: 6 additions & 1 deletion tests/database/00-simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#-------------------------------------------------------------------------------
# Suite database content, a basic non-cycling suite of 3 tasks
. "$(dirname "$0")/test_header"
set_test_number 8
set_test_number 9
install_suite "${TEST_NAME_BASE}" "${TEST_NAME_BASE}"

run_ok "${TEST_NAME_BASE}-validate" cylc validate "${SUITE_NAME}"
Expand Down Expand Up @@ -60,5 +60,10 @@ sqlite3 "${DB_FILE}" 'SELECT name, cycle, status FROM task_states ORDER BY name'
>"${NAME}"
cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/${NAME}" "${NAME}"

NAME='select-linearization.out'
sqlite3 "${DB_FILE}" 'SELECT namespace, linearization FROM linearization ORDER BY namespace' \
>"${NAME}"
cmp_ok "${TEST_SOURCE_DIR}/${TEST_NAME_BASE}/${NAME}" "${NAME}"

purge_suite "${SUITE_NAME}"
exit
1 change: 1 addition & 0 deletions tests/database/00-simple/schema.out
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ CREATE TABLE broadcast_events(time TEXT, change TEXT, point TEXT, namespace TEXT
CREATE TABLE broadcast_states(point TEXT, namespace TEXT, key TEXT, value TEXT, PRIMARY KEY(point, namespace, key));
CREATE TABLE broadcast_states_checkpoints(id INTEGER, point TEXT, namespace TEXT, key TEXT, value TEXT, PRIMARY KEY(id, point, namespace, key));
CREATE TABLE checkpoint_id(id INTEGER, time TEXT, event TEXT, PRIMARY KEY(id));
CREATE TABLE linearization(namespace TEXT, linearization TEXT, PRIMARY KEY(namespace));
CREATE TABLE suite_params(key TEXT, value TEXT, PRIMARY KEY(key));
CREATE TABLE suite_params_checkpoints(id INTEGER, key TEXT, value TEXT, PRIMARY KEY(id, key));
CREATE TABLE suite_template_vars(key TEXT, value TEXT, PRIMARY KEY(key));
Expand Down
4 changes: 4 additions & 0 deletions tests/database/00-simple/select-linearization.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bar|bar root
baz|baz root
foo|foo root
root|root

0 comments on commit 4d20dff

Please sign in to comment.