Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
Signed-off-by: Katrina Rogan <[email protected]>
  • Loading branch information
katrogan committed Mar 29, 2021
1 parent a37bab1 commit 258a54c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion flytekit/core/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ def new_execution_context(
if additional_context is None:
additional_context = self.execution_state.additional_context if self.execution_state is not None else None
elif self.execution_state is not None and self.execution_state.additional_context is not None:
additional_context = {**additional_context, **self.execution_state.additional_context}
additional_context = {**self.execution_state.additional_context, **additional_context}
exec_state = ExecutionState(
mode=mode, working_dir=working_dir, engine_dir=engine_dir, additional_context=additional_context
)
Expand Down
13 changes: 12 additions & 1 deletion tests/flytekit/unit/core/test_context_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from flytekit.core.context_manager import CompilationState, FlyteContext, look_up_image_info
from flytekit.core.context_manager import CompilationState, ExecutionState, FlyteContext, look_up_image_info


class SampleTestClass(object):
Expand Down Expand Up @@ -42,3 +42,14 @@ def test_look_up_image_info():
assert img.name == "x"
assert img.tag == "latest"
assert img.fqn == "localhost:5000/xyz"


def test_additional_context():
with FlyteContext.current_context() as ctx:
with ctx.new_execution_context(
mode=ExecutionState.Mode.TASK_EXECUTION, additional_context={1: "outer", 2: "foo"}
) as exec_ctx_outer:
with exec_ctx_outer.new_execution_context(
mode=ExecutionState.Mode.TASK_EXECUTION, additional_context={1: "inner", 3: "baz"}
) as exec_ctx_inner:
assert exec_ctx_inner.execution_state.additional_context == {1: "inner", 2: "foo", 3: "baz"}

0 comments on commit 258a54c

Please sign in to comment.