Skip to content

Commit

Permalink
[docs] retry policy invocation example (#7716)
Browse files Browse the repository at this point in the history
  • Loading branch information
alangenfeld committed May 3, 2022
1 parent d32fcff commit bc2e62d
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
10 changes: 10 additions & 0 deletions docs/content/concepts/ops-jobs-graphs/op-retries.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ def even_better():

In addition to being able to set the policy directly on the op definition, it can also be set on specific invocations of an op, or a <PyObject module="dagster" object="job" decorator /> to apply to all ops contained within.

```python file=/concepts/solids_pipelines/retries.py startafter=policy3_start endbefore=policy3_end
default_policy = RetryPolicy(max_retries=1)
flakey_op_policy = RetryPolicy(max_retries=10)


@job(op_retry_policy=default_policy)
def default_and_override_job():
problematic.with_retry_policy(flakey_op_policy)()
```

### RetryRequested

In certain more nuanced situations, we may need to evaluate code to determine if we want to retry or not. For this we can use a manual <PyObject module="dagster" object="RetryRequested" /> exception.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ def even_better():

# policy2_end

# policy3_start
default_policy = RetryPolicy(max_retries=1)
flakey_op_policy = RetryPolicy(max_retries=10)


@job(op_retry_policy=default_policy)
def default_and_override_job():
problematic.with_retry_policy(flakey_op_policy)()


# policy3_end

# manual_start
@op
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
one_plus_one_from_constructor,
tagged_add_one,
)
from docs_snippets.concepts.solids_pipelines.retries import retry_job
from docs_snippets.concepts.solids_pipelines.retries import (
default_and_override_job,
retry_job,
)


def test_one_plus_one():
Expand Down Expand Up @@ -90,4 +93,6 @@ def test_dynamic_examples():


def test_retry_examples():
assert retry_job.execute_in_process(raise_on_error=False) # just that it runs
# just that they run
assert retry_job.execute_in_process(raise_on_error=False)
assert default_and_override_job.execute_in_process(raise_on_error=False)

1 comment on commit bc2e62d

@vercel
Copy link

@vercel vercel bot commented on bc2e62d May 3, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.