Ejemplo n.º 1
0
    def wrapper(fn) -> PythonFunctionTask:
        _metadata = TaskMetadata(
            cache=cache,
            cache_serialize=cache_serialize,
            cache_version=cache_version,
            retries=retries,
            interruptible=interruptible,
            deprecated=deprecated,
            timeout=timeout,
        )

        task_instance = TaskPlugins.find_pythontask_plugin(type(task_config))(
            task_config,
            fn,
            metadata=_metadata,
            container_image=container_image,
            environment=environment,
            requests=requests,
            limits=limits,
            secret_requests=secret_requests,
            execution_mode=execution_mode,
            task_resolver=task_resolver,
            disable_deck=disable_deck,
        )
        update_wrapper(task_instance, fn)
        return task_instance
Ejemplo n.º 2
0
def get_serializable_references(
    entity_mapping: OrderedDict,
    settings: SerializationSettings,
    entity: FlyteLocalEntity,
    fast: bool,
) -> FlyteControlPlaneEntity:
    # TODO: This entire function isn't necessary. We should just return None or raise an Exception or something.
    #   Reference entities should already exist on the Admin control plane - they should not be serialized/registered
    #   again. Indeed we don't actually have enough information to serialize it properly.

    if isinstance(entity, ReferenceTask):
        cp_entity = SdkTask(
            type="ignore",
            metadata=TaskMetadata().to_taskmetadata_model(),
            interface=entity.interface,
            custom={},
            container=None,
        )

    elif isinstance(entity, ReferenceWorkflow):
        workflow_metadata = WorkflowMetadata(
            on_failure=WorkflowFailurePolicy.FAIL_IMMEDIATELY)

        cp_entity = SdkWorkflow(
            nodes=[],  # Fake an empty list for nodes,
            id=entity.reference.id,
            metadata=workflow_metadata,
            metadata_defaults=workflow_model.WorkflowMetadataDefaults(),
            interface=entity.interface,
            output_bindings=[],
        )

    elif isinstance(entity, ReferenceLaunchPlan):
        cp_entity = SdkLaunchPlan(
            workflow_id=None,
            entity_metadata=_launch_plan_models.LaunchPlanMetadata(
                schedule=None, notifications=[]),
            default_inputs=interface_models.ParameterMap({}),
            fixed_inputs=literal_models.LiteralMap({}),
            labels=_common_models.Labels({}),
            annotations=_common_models.Annotations({}),
            auth_role=_common_models.AuthRole(assumable_iam_role="fake:role"),
            raw_output_data_config=RawOutputDataConfig(""),
        )
        # Because of how SdkNodes work, it needs one of these interfaces
        # Hopefully this is more trickery that can be cleaned up in the future
        cp_entity._interface = TypedInterface.promote_from_model(
            entity.interface)

    else:
        raise Exception("Invalid reference type when serializing")

    # Make sure we don't serialize this
    cp_entity._has_registered = True
    cp_entity.assign_name(entity.id.name)
    cp_entity._id = entity.id
    return cp_entity
Ejemplo n.º 3
0
    def wrapper(fn) -> PythonFunctionTask:
        _metadata = TaskMetadata(
            cache=cache,
            cache_version=cache_version,
            retries=retries,
            interruptable=interruptable,
            deprecated=deprecated,
            timeout=timeout,
        )

        task_instance = TaskPlugins.find_pythontask_plugin(type(task_config))(
            task_config, fn, metadata=_metadata, container_image=container_image, environment=environment, **kwargs,
        )

        return task_instance