- class flytekitplugins.awssagemaker.SagemakerCustomTrainingTask(*args, **kwargs)#
Allows a custom training algorithm to be executed on Amazon Sagemaker. For this to work, make sure your container is built according to Flyte plugin documentation (TODO point the link here)
task_config (T) – Configuration object for Task. Should be a unique type for that specific Task
task_function (Callable) – Python function that has type annotations and works for the task
ignore_input_vars (Optional[List[str]]) – When supplied, these input variables will be removed from the interface. This can be used to inject some client side variables only. Prefer using ExecutionParams
execution_mode (Optional[ExecutionBehavior]) – Defines how the execution should behave, for example executing normally or specially handling a dynamic case.
task_type (Optional[TaskResolverMixin]) – String task type to be associated with this Task
- compile(ctx, *args, **kwargs)#
Generates a node that encapsulates this task in a workflow definition.
- compile_into_workflow(ctx, task_function, **kwargs)#
In the case of dynamic workflows, this function will produce a workflow definition at execution time which will then proceed to be executed.
Used when constructing the node that encapsulates this task as part of a broader workflow definition.
- Return type
- dispatch_execute(ctx, input_literal_map)#
This method translates Flyte’s Type system based input values and invokes the actual call to the executor This method is also invoked during runtime.
VoidPromiseis returned in the case when the task itself declares no outputs.
Literal Mapis returned when the task returns either one more outputs in the declaration. Individual outputs may be none
DynamicJobSpecis returned when a dynamic workflow is executed
- dynamic_execute(task_function, **kwargs)#
By the time this function is invoked, the local_execute function should have unwrapped the Promises and Flyte literal wrappers so that the kwargs we are working with here are now Python native literal values. This function is also expected to return Python native literal values.
Since the user code within a dynamic task constitute a workflow, we have to first compile the workflow, and then execute that workflow.
When running for real in production, the task would stop after the compilation step, and then create a file representing that newly generated workflow, instead of executing it.
This method will be invoked to execute the task. If you do decide to override this method you must also handle dynamic tasks or you will no longer be able to use the task as a dynamic task generator.
- Return type
Returns the command which should be used in the container definition for the serialized version of this task registered on a hosted Flyte platform.
Returns the task config as a serializable dictionary. This task config consists of metadata about the custom defined for this task.
Returns the container definition (if any) that is used to run the task on hosted Flyte.
settings (flytekit.configuration.SerializationSettings) –
- Return type
Return additional plugin-specific custom data (if any) as a serializable dictionary.
Returns the default pyflyte-execute command used to run this on hosted Flyte platforms.
Returns the names and python types as a dictionary for the inputs of this task.
Returns the kubernetes pod definition (if any) that is used to run the task on hosted Flyte.
Returns the Sql definition (if any) that is used to run the task on hosted Flyte.
- get_type_for_input_var(k, v)#
Returns the python type for an input variable by name.
- get_type_for_output_var(k, v)#
Returns the python type for the specified output variable by name.
- local_execute(ctx, **kwargs)#
This function is used only in the local execution path and is responsible for calling dispatch execute. Use this function when calling a task with native values (or Promises containing Flyte literals derived from Python native values).
- post_execute(user_params, rval)#
In the case of distributed execution, we check the should_persist_predicate in the configuration to determine if the output should be persisted. This is because in distributed training, multiple nodes may produce partial outputs and only the user process knows the output that should be generated. They can control the choice using the predicate.
To control if output is generated across every execution, we override the post_execute method and sometimes return a None
Pre-execute for Sagemaker will automatically add the distributed context to the execution params, only if the number of execution instances is > 1. Otherwise this is considered to be a single node execution
Resets the command which should be used in the container definition of this task to the default arguments. This is useful when the command line is overridden at serialization time.
By default, the task will run on the Flyte platform using the pyflyte-execute command. However, it can be useful to update the command with which the task is serialized for specific cases like running map tasks (“pyflyte-map-execute”) or for fast-executed tasks.
If true, this task will not output deck html file
Any environment variables that supplied during the execution of the task.
Returns this task’s python interface.
Returns the user-specified task config which is used for plugin-specific handling of the task.