flytekit.FlyteContext

class flytekit.FlyteContext(file_access, level=0, flyte_client=None, compilation_state=None, execution_state=None, serialization_settings=None, in_a_condition=False, origin_stackframe=None)[source]

This is an internal-facing context object, that most users will not have to deal with. It’s essentially a globally available grab bag of settings and objects that allows flytekit to do things like convert complex types, run and compile workflows, serialize Flyte entities, etc.

Even though this object as a current_context function on it, it should not be called directly. Please use the flytekit.FlyteContextManager object instead.

Please do not confuse this object with the flytekit.ExecutionParameters object.

Methods

Parameters
Return type

None

static current_context()[source]

This method exists only to maintain backwards compatibility. Please use FlyteContextManager.current_context() instead.

Users of flytekit should be wary not to confuse the object returned from this function with flytekit.current_context()

Return type

Optional[flytekit.core.context_manager.FlyteContext]

enter_conditional_section()[source]
Return type

Builder

get_origin_stackframe_repr()[source]
Return type

str

new_builder()[source]
Return type

Builder

new_compilation_state(prefix='')[source]

Creates and returns a default compilation state. For most of the code this should be the entrypoint of compilation, otherwise the code should always uses - with_compilation_state

Parameters

prefix (str) –

Return type

flytekit.core.context_manager.CompilationState

new_execution_state(working_dir=None)[source]

Creates and returns a new default execution state. This should be used at the entrypoint of execution, in all other cases it is preferable to use with_execution_state

Parameters

working_dir (Optional[os.PathLike]) –

Return type

flytekit.core.context_manager.ExecutionState

set_stackframe(s)[source]
Parameters

s (traceback.FrameSummary) –

with_compilation_state(c)[source]
Parameters

c (CompilationState) –

Return type

Builder

with_execution_state(es)[source]
Parameters

es (ExecutionState) –

Return type

Builder

with_file_access(fa)[source]
Parameters

fa (FileAccessProvider) –

Return type

Builder

with_new_compilation_state()[source]
Return type

Builder

with_serialization_settings(ss)[source]
Parameters

ss (SerializationSettings) –

Return type

Builder

Attributes

compilation_state: Optional[flytekit.core.context_manager.CompilationState] = None
execution_state: Optional[flytekit.core.context_manager.ExecutionState] = None
flyte_client: Optional[flytekit.clients.friendly.SynchronousFlyteClient] = None
in_a_condition: bool = False
level: int = 0
origin_stackframe: Optional[traceback.FrameSummary] = None
serialization_settings: Optional[flytekit.core.context_manager.SerializationSettings] = None
user_space_params
file_access: flytekit.core.data_persistence.FileAccessProvider