How to use the flytekit.models.literals.RetryStrategy function in flytekit

To help you get started, weโ€™ve selected a few flytekit examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github lyft / flytekit / tests / flytekit / common / parameterizers.py View on Github external
LIST_OF_RESOURCES = [
    task.Resources(request, limit)
    for request, limit in product(LIST_OF_RESOURCE_ENTRY_LISTS, LIST_OF_RESOURCE_ENTRY_LISTS)
]


LIST_OF_RUNTIME_METADATA = [
    task.RuntimeMetadata(task.RuntimeMetadata.RuntimeType.OTHER, "1.0.0", "python"),
    task.RuntimeMetadata(task.RuntimeMetadata.RuntimeType.FLYTE_SDK, "1.0.0b0", "golang")
]


LIST_OF_RETRY_POLICIES = [
    literals.RetryStrategy(retries=i) for i in [0, 1, 3, 100]
]


LIST_OF_TASK_METADATA = [
    task.TaskMetadata(
        discoverable,
        runtime_metadata,
        timeout,
        retry_strategy,
        discovery_version,
        deprecated
    )
    for discoverable, runtime_metadata, timeout, retry_strategy, discovery_version, deprecated in product(
        [True, False],
        LIST_OF_RUNTIME_METADATA,
        [timedelta(days=i) for i in range(3)],
github lyft / flytekit / tests / flytekit / unit / models / test_workflow_closure.py View on Github external
b1 = _literals.Binding('b', _literals.BindingData(
        promise=_types.OutputReference('my_node', 'b')))
    b2 = _literals.Binding('c', _literals.BindingData(
        promise=_types.OutputReference('my_node', 'c')))

    node_metadata = _workflow.NodeMetadata(
        name='node1',
        timeout=timedelta(seconds=10),
        retries=_literals.RetryStrategy(0)
    )

    task_metadata = _task.TaskMetadata(
        True,
        _task.RuntimeMetadata(_task.RuntimeMetadata.RuntimeType.FLYTE_SDK, "1.0.0", "python"),
        timedelta(days=1),
        _literals.RetryStrategy(3),
        "0.1.1b0",
        "This is deprecated!"
    )

    cpu_resource = _task.Resources.ResourceEntry(_task.Resources.ResourceName.CPU, "1")
    resources = _task.Resources(requests=[cpu_resource], limits=[cpu_resource])

    task = _task.TaskTemplate(
        _identifier.Identifier(_identifier.ResourceType.TASK, "project", "domain", "name", "version"),
        "python",
        task_metadata,
        typed_interface,
        {'a': 1, 'b': {'c': 2, 'd': 3}},
        container=_task.Container(
            "my_image",
            ["this", "is", "a", "cmd"],
github lyft / flytekit / tests / flytekit / unit / models / test_workflow_closure.py View on Github external
'b': _interface.Variable(int_type, "description2"),
            'c': _interface.Variable(int_type, "description3")
        }
    )

    b0 = _literals.Binding('a', _literals.BindingData(
        scalar=_literals.Scalar(primitive=_literals.Primitive(integer=5))))
    b1 = _literals.Binding('b', _literals.BindingData(
        promise=_types.OutputReference('my_node', 'b')))
    b2 = _literals.Binding('c', _literals.BindingData(
        promise=_types.OutputReference('my_node', 'c')))

    node_metadata = _workflow.NodeMetadata(
        name='node1',
        timeout=timedelta(seconds=10),
        retries=_literals.RetryStrategy(0)
    )

    task_metadata = _task.TaskMetadata(
        True,
        _task.RuntimeMetadata(_task.RuntimeMetadata.RuntimeType.FLYTE_SDK, "1.0.0", "python"),
        timedelta(days=1),
        _literals.RetryStrategy(3),
        "0.1.1b0",
        "This is deprecated!"
    )

    cpu_resource = _task.Resources.ResourceEntry(_task.Resources.ResourceName.CPU, "1")
    resources = _task.Resources(requests=[cpu_resource], limits=[cpu_resource])

    task = _task.TaskTemplate(
        _identifier.Identifier(_identifier.ResourceType.TASK, "project", "domain", "name", "version"),
github lyft / flytekit / tests / flytekit / unit / models / core / test_workflow.py View on Github external
def _get_sample_node_metadata():
    return _workflow.NodeMetadata(name='node1', timeout=timedelta(seconds=10), retries=_literals.RetryStrategy(0))
github lyft / flytekit / tests / flytekit / unit / common_tests / test_workflow_promote.py View on Github external
def get_sample_node_metadata(node_id):
    """
    :param Text node_id:
    :rtype: flytekit.models.core.workflow.NodeMetadata
    """

    return _workflow_model.NodeMetadata(
        name=node_id,
        timeout=timedelta(seconds=10),
        retries=_literals.RetryStrategy(0)
    )
github lyft / flytekit / tests / flytekit / unit / models / test_tasks.py View on Github external
def test_task_metadata():
    obj = task.TaskMetadata(
        True,
        task.RuntimeMetadata(task.RuntimeMetadata.RuntimeType.FLYTE_SDK, "1.0.0", "python"),
        timedelta(days=1),
        literals.RetryStrategy(3),
        True,
        "0.1.1b0",
        "This is deprecated!"
    )

    assert obj.discoverable is True
    assert obj.retries.retries == 3
    assert obj.interruptible is True
    assert obj.timeout == timedelta(days=1)
    assert obj.runtime.flavor == "python"
    assert obj.runtime.type == task.RuntimeMetadata.RuntimeType.FLYTE_SDK
    assert obj.runtime.version == "1.0.0"
    assert obj.deprecated_error_message == "This is deprecated!"
    assert obj.discovery_version == "0.1.1b0"
    assert obj == task.TaskMetadata.from_flyte_idl(obj.to_flyte_idl())
github lyft / flytekit / flytekit / common / launch_plan.py View on Github external
"When adding a launchplan as a node in a workflow, all inputs must be specified with kwargs only.  We "
                "detected {} positional args.".format(self, len(args))
            )

        # Take the default values from the launch plan
        default_inputs = {
            k: v.sdk_default
            for k, v in _six.iteritems(self.default_inputs.parameters) if not v.required
        }
        default_inputs.update(input_map)

        bindings, upstream_nodes = self.interface.create_bindings_for_inputs(default_inputs)

        return _nodes.SdkNode(
            id=None,
            metadata=_workflow_models.NodeMetadata("", _datetime.timedelta(), _literal_models.RetryStrategy(0)),
            bindings=sorted(bindings, key=lambda b: b.var),
            upstream_nodes=upstream_nodes,
            sdk_launch_plan=self
        )
github lyft / flytekit / flytekit / common / tasks / hive_task.py View on Github external
def _create_hive_job_node(name, hive_job, metadata):
    """
    :param Text name:
    :param _qubole.QuboleHiveJob hive_job: Hive job spec
    :param flytekit.models.task.TaskMetadata metadata: This contains information needed at runtime to determine
        behavior such as whether or not outputs are discoverable, timeouts, and retries.
    :rtype: _nodes.SdkNode:
    """
    return _nodes.SdkNode(
        id=_six.text_type(_uuid.uuid4()),
        upstream_nodes=[],
        bindings=[],
        metadata=_workflow_model.NodeMetadata(name, metadata.timeout, _literal_models.RetryStrategy(0)),
        sdk_task=SdkHiveJob(hive_job, metadata)
    )
github lyft / flytekit / flytekit / models / core / workflow.py View on Github external
def from_flyte_idl(cls, pb2_object):
        return cls(
            pb2_object.name,
            pb2_object.timeout.ToTimedelta(),
            _RetryStrategy.from_flyte_idl(pb2_object.retries)
        )