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

Record linearization in database #2213

Merged
merged 2 commits into from
Mar 27, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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_INHERITANCE = "inheritance"
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_INHERITANCE: [
["namespace", {"is_primary_key": True}],
["inheritance"],
],
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 @@ -1189,6 +1189,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_INHERITANCE,
[namespace, ancestors])
self.pub_dao.add_insert_item(CylcSuiteDAO.TABLE_INHERITANCE,
[namespace, ancestors])

def configure_suite_environment(self):
"""Configure suite environment."""
# Pass static cylc and suite variables to job script generation code
Expand Down
9 changes: 7 additions & 2 deletions tests/database/00-simple.t
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
#-------------------------------------------------------------------------------
# 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}"
suite_run_ok "${TEST_NAME_BASE}-run" cylc run --debug "${SUITE_NAME}"

if ! which sqlite3 > /dev/null; then
skip 6 "sqlite3 not installed?"
skip 7 "sqlite3 not installed?"
purge_suite "${SUITE_NAME}"
exit 0
fi
Expand Down Expand Up @@ -66,5 +66,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-inheritance.out'
sqlite3 "${DB_FILE}" 'SELECT namespace, inheritance FROM inheritance 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 inheritance(namespace TEXT, inheritance 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-inheritance.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