From 40e593bd2016b623ce509a3db24965997422eed2 Mon Sep 17 00:00:00 2001 From: Dougal Matthews Date: Wed, 18 Oct 2017 15:51:19 +0100 Subject: [PATCH] Rename task_id to task_execution_id The previous name isn't consistent and it is confusing, tasks don't have an ID, but the execution for a task does. Related-Bug: #1718353 Change-Id: I049cf7312c58d83e9405aaa36a6961cca006cb16 --- mistral_lib/actions/context.py | 22 ++++++++++++++++--- mistral_lib/tests/actions/test_context.py | 2 +- ...to-task-execution-id-f17d671fcef0127a.yaml | 5 +++++ 3 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 releasenotes/notes/rename-task-id-to-task-execution-id-f17d671fcef0127a.yaml diff --git a/mistral_lib/actions/context.py b/mistral_lib/actions/context.py index 295a388..76bca95 100644 --- a/mistral_lib/actions/context.py +++ b/mistral_lib/actions/context.py @@ -80,11 +80,27 @@ class SecurityContext(object): class ExecutionContext(object): - def __init__(self, workflow_execution_id=None, task_id=None, + def __init__(self, workflow_execution_id=None, task_execution_id=None, action_execution_id=None, workflow_name=None, - callback_url=None): + callback_url=None, task_id=None): self.workflow_execution_id = workflow_execution_id - self.task_id = task_id + self.task_execution_id = task_execution_id self.action_execution_id = action_execution_id self.workflow_name = workflow_name self.callback_url = callback_url + + if task_id is not None: + self.task_execution_id = task_id + self._deprecate_task_id_warning() + + def _deprecate_task_id_warning(self): + warnings.warn( + "context.execution.task_id was deprecated in the Queens cycle. " + "Please use context.execution.task_execution_id. It will be " + "removed in a future release.", DeprecationWarning + ) + + @property + def task_id(self): + self._deprecate_task_id_warning() + return self.task_execution_id diff --git a/mistral_lib/tests/actions/test_context.py b/mistral_lib/tests/actions/test_context.py index b98775d..d9d58c4 100644 --- a/mistral_lib/tests/actions/test_context.py +++ b/mistral_lib/tests/actions/test_context.py @@ -30,7 +30,7 @@ def _fake_context(): execution_ctx = context.ExecutionContext( workflow_execution_id='workflow_execution_id', - task_id='task_id', + task_execution_id='task_execution_id', action_execution_id='action_execution_id', workflow_name='workflow_name', callback_url='callback_url') diff --git a/releasenotes/notes/rename-task-id-to-task-execution-id-f17d671fcef0127a.yaml b/releasenotes/notes/rename-task-id-to-task-execution-id-f17d671fcef0127a.yaml new file mode 100644 index 0000000..c787e72 --- /dev/null +++ b/releasenotes/notes/rename-task-id-to-task-execution-id-f17d671fcef0127a.yaml @@ -0,0 +1,5 @@ +--- +deprecations: + - | + The attribute `context.execution.task_id` has been renamed to + `context.execution.task_execution_id`.