-
Notifications
You must be signed in to change notification settings - Fork 93
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
Supply URLs to suite and task event handlers. #2276
Merged
Merged
Changes from 3 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -187,7 +187,7 @@ class TaskProxy(object): | |
"is_manual_submit", "summary", "local_job_file_path", | ||
"retries_configured", "try_timers", | ||
"event_handler_try_timers", "db_inserts_map", | ||
"db_updates_map", "suite_name", "task_host", "task_owner", | ||
"db_updates_map", "task_host", "task_owner", | ||
"job_vacated", "poll_timers", "event_hooks", | ||
"delayed_start_str", "delayed_start", "expire_time_str", | ||
"expire_time", "state"] | ||
|
@@ -231,6 +231,10 @@ class TaskProxy(object): | |
|
||
stop_sim_mode_job_submission = False | ||
|
||
# Updated during config parsing: | ||
suite_name = None | ||
suite_url = None | ||
|
||
def __init__( | ||
self, tdef, start_point, status=TASK_STATUS_WAITING, | ||
hold_swap=None, has_spawned=False, stop_point=None, | ||
|
@@ -316,9 +320,6 @@ def __init__( | |
self.TABLE_TASK_STATES: [], | ||
} | ||
|
||
# TODO - should take suite name from config! | ||
self.suite_name = os.environ['CYLC_SUITE_NAME'] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doesn't need to be an instance variable, and this was an insane way of getting the suite name. |
||
|
||
# In case task owner and host are needed by db_events_insert() | ||
# for pre-submission events, set their initial values as if | ||
# local (we can't know the correct host prior to this because | ||
|
@@ -789,17 +790,20 @@ def setup_custom_event_handlers(self, event, message, only_list=None): | |
continue | ||
cmd = handler % { | ||
"event": quote(event), | ||
"suite": quote(self.suite_name), | ||
"suite": quote(self.__class__.suite_name), | ||
"point": quote(str(self.point)), | ||
"name": quote(self.tdef.name), | ||
"submit_num": self.submit_num, | ||
"id": quote(self.identity), | ||
"task_url": quote(self.tdef.rtconfig['URL']), | ||
"suite_url": quote(self.__class__.suite_url), | ||
"message": quote(message), | ||
} | ||
if cmd == handler: | ||
# Nothing substituted, assume classic interface | ||
cmd = "%s '%s' '%s' '%s' '%s'" % ( | ||
handler, event, self.suite_name, self.identity, message) | ||
handler, event, self.__class__.suite_name, | ||
self.identity, message) | ||
self.log(DEBUG, "Queueing %s handler: %s" % (event, cmd)) | ||
self.event_handler_try_timers[(key1, self.submit_num)] = ( | ||
TaskActionTimer( | ||
|
@@ -1121,7 +1125,7 @@ def _prep_submit_impl(self, overrides=None): | |
|
||
if self.tdef.run_mode != 'simulation': | ||
RemoteJobHostManager.get_inst().init_suite_run_dir( | ||
self.suite_name, self.task_host, self.task_owner) | ||
self.__class__.suite_name, self.task_host, self.task_owner) | ||
self.db_updates_map[self.TABLE_TASK_JOBS].append({ | ||
"user_at_host": user_at_host, | ||
"batch_sys_name": self.summary['batch_sys_name'], | ||
|
@@ -1158,7 +1162,7 @@ def _prep_submit_impl(self, overrides=None): | |
'remote_suite_d': rtconfig['remote']['suite definition directory'], | ||
'shell': rtconfig['job']['shell'], | ||
'submit_num': self.submit_num, | ||
'suite_name': self.suite_name, | ||
'suite_name': self.__class__.suite_name, | ||
'task_id': self.identity, | ||
'try_num': self.try_timers[self.KEY_EXECUTE].num + 1, | ||
'work_d': rtconfig['work sub-directory'], | ||
|
@@ -1522,10 +1526,10 @@ def get_job_log_path(self, head_mode=None, submit_num=None, tail=None): | |
args.append(submit_num) | ||
if head_mode == self.HEAD_MODE_LOCAL: | ||
args.insert(0, GLOBAL_CFG.get_derived_host_item( | ||
self.suite_name, "suite job log directory")) | ||
self.__class__.suite_name, "suite job log directory")) | ||
elif head_mode == self.HEAD_MODE_REMOTE: | ||
args.insert(0, GLOBAL_CFG.get_derived_host_item( | ||
self.suite_name, 'suite job log directory', | ||
self.__class__.suite_name, 'suite job log directory', | ||
self.task_host, self.task_owner)) | ||
if tail: | ||
args.append(tail) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ OPT_SET= | |
if [[ "${TEST_NAME_BASE}" == *-globalcfg ]]; then | ||
create_test_globalrc "" " | ||
[task events] | ||
handlers=hello-event-handler '%(name)s' '%(event)s' | ||
handlers = hello-event-handler %(name)s %(event)s %(suite_url)s %(task_url)s %(message)s %(point)s %(submit_num)s %(id)s | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Might as well test all possible args. |
||
handler events=succeeded, failed | ||
handler retry delays=PT0S, 2*PT1S" | ||
OPT_SET='-s GLOBALCFG=True' | ||
|
@@ -33,15 +33,17 @@ run_ok "${TEST_NAME_BASE}-validate" cylc validate ${OPT_SET} "${SUITE_NAME}" | |
suite_run_ok "${TEST_NAME_BASE}-run" \ | ||
cylc run --reference-test --debug ${OPT_SET} "${SUITE_NAME}" | ||
|
||
SUITE_URL=http://my-suites.com/${SUITE_NAME}.html | ||
TASK_URL=http://my-suites.com/${SUITE_NAME}/t1.html | ||
LOG="${SUITE_RUN_DIR}/log/job/1/t1/NN/job-activity.log" | ||
sed "/(('event-handler-00', 'succeeded'), 1)/!d; s/^.* \[/[/" "${LOG}" \ | ||
>'edited-job-activity.log' | ||
cmp_ok 'edited-job-activity.log' <<'__LOG__' | ||
[(('event-handler-00', 'succeeded'), 1) cmd] hello-event-handler 't1' 'succeeded' | ||
cmp_ok 'edited-job-activity.log' <<__LOG__ | ||
[(('event-handler-00', 'succeeded'), 1) cmd] hello-event-handler t1 succeeded ${SUITE_URL} ${TASK_URL} 'job succeeded' 1 1 t1.1 | ||
[(('event-handler-00', 'succeeded'), 1) ret_code] 1 | ||
[(('event-handler-00', 'succeeded'), 1) cmd] hello-event-handler 't1' 'succeeded' | ||
[(('event-handler-00', 'succeeded'), 1) cmd] hello-event-handler t1 succeeded ${SUITE_URL} ${TASK_URL} 'job succeeded' 1 1 t1.1 | ||
[(('event-handler-00', 'succeeded'), 1) ret_code] 1 | ||
[(('event-handler-00', 'succeeded'), 1) cmd] hello-event-handler 't1' 'succeeded' | ||
[(('event-handler-00', 'succeeded'), 1) cmd] hello-event-handler t1 succeeded ${SUITE_URL} ${TASK_URL} 'job succeeded' 1 1 t1.1 | ||
[(('event-handler-00', 'succeeded'), 1) ret_code] 0 | ||
[(('event-handler-00', 'succeeded'), 1) out] hello | ||
__LOG__ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Should be URL (ALL CAPS), to be consistent with line 304 above.