Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] feature: support argo retry #2277

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions metaflow/cli_components/step_cmd.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,13 @@ def step(
ctx.obj.monitor,
ubf_context,
)

latest_done_attempt = task.flow_datastore.get_latest_done_attempt(
run_id=run_id, step_name=step_name, task_id=task_id
)
if latest_done_attempt:
retry_count = latest_done_attempt + 1

if clone_only:
task.clone_only(
step_name,
Expand Down
9 changes: 9 additions & 0 deletions metaflow/datastore/flow_datastore.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import itertools
import json
from typing import Optional

from .. import metaflow_config

Expand Down Expand Up @@ -67,6 +68,14 @@ def __init__(
def datastore_root(self):
return self._storage_impl.datastore_root

def get_latest_done_attempt(self, run_id, step_name, task_id) -> Optional[int]:
t_datastores = self.get_task_datastores(
pathspecs=[f"{run_id}/{step_name}/{task_id}"], include_prior=True
)
return max(
[t.attempt for t in t_datastores], default=None
) # returns default, if this was a first attempt.

def get_task_datastores(
self,
run_id=None,
Expand Down
6 changes: 5 additions & 1 deletion metaflow/mflog/save_logs.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ def print_clean(line, **kwargs):
flow_datastore = FlowDataStore(
flow_name, None, storage_impl=storage_impl, ds_root=ds_root
)
# Use inferred attempt - to save task_stdout.log and task_stderr.log
latest_done_attempt = flow_datastore.get_latest_done_attempt(
run_id=run_id, step_name=step_name, task_id=task_id
)
task_datastore = flow_datastore.get_task_datastore(
run_id, step_name, task_id, int(attempt), mode="w"
run_id, step_name, task_id, latest_done_attempt, mode="w"
)

try:
Expand Down