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, output_metadata_tracker=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:
  • file_access (FileAccessProvider)

  • level (int)

  • flyte_client (Optional['friendly_client.SynchronousFlyteClient'])

  • compilation_state (Optional[CompilationState])

  • execution_state (Optional[ExecutionState])

  • serialization_settings (Optional[SerializationSettings])

  • in_a_condition (bool)

  • origin_stackframe (Optional[traceback.FrameSummary])

  • output_metadata_tracker (Optional[OutputMetadataTracker])

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:

FlyteContext

enter_conditional_section()[source]
Return type:

Builder

get_deck()[source]

Returns the deck that was created as part of the last execution.

The return value depends on the execution environment. In a notebook, the return value is compatible with IPython.display and should be rendered in the notebook.

with flytekit.new_context() as ctx:
    my_task(...)
ctx.get_deck()

OR if you wish to explicitly display

from IPython import display
display(ctx.get_deck())
Return type:

Union[str, ‘IPython.core.display.HTML’]

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:

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 (PathLike | None)

Return type:

ExecutionState

set_stackframe(s)[source]
Parameters:

s (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_output_metadata_tracker(t)[source]
Parameters:

t (OutputMetadataTracker)

Return type:

Builder

with_serialization_settings(ss)[source]
Parameters:

ss (SerializationSettings)

Return type:

Builder

Attributes

compilation_state: CompilationState | None = None
execution_state: ExecutionState | None = None
flyte_client: 'friendly_client.SynchronousFlyteClient' | None = None
in_a_condition: bool = False
level: int = 0
origin_stackframe: traceback.FrameSummary | None = None
output_metadata_tracker: OutputMetadataTracker | None = None
serialization_settings: SerializationSettings | None = None
user_space_params
file_access: FileAccessProvider