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

Add --err-regex | -er CLI flag to jf job rerun #186

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
9 changes: 9 additions & 0 deletions src/jobflow_remote/cli/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,14 @@ def rerun(
),
] = False,
raise_on_error: raise_on_error_opt = False,
err_regex: Annotated[
str,
typer.Option(
"--err-regex",
"-er",
help="A regular expression to match against job error messages. Only jobs with matching error messages will be rerun.",
),
] = None,
) -> None:
"""
Rerun a Job. By default, this is limited to jobs that failed and children did
Expand Down Expand Up @@ -333,6 +341,7 @@ def rerun(
break_lock=break_lock,
force=force,
raise_on_error=raise_on_error,
err_regex=err_regex,
)


Expand Down
7 changes: 6 additions & 1 deletion src/jobflow_remote/jobs/jobcontroller.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,7 @@ def rerun_jobs(
force: bool = False,
wait: int | None = None,
break_lock: bool = False,
err_regex: str | None = None,
) -> list[str]:
"""
Rerun a list of selected Jobs, i.e. bring their state back to READY.
Expand Down Expand Up @@ -811,6 +812,9 @@ def rerun_jobs(
Forcibly break the lock on locked documents. Use with care and
verify that the lock has been set by a process that is not running
anymore. Doing otherwise will likely lead to inconsistencies in the DB.
err_regex : str, optional
A regular expression to match against job error messages.
Only jobs with matching error messages will be rerun.

Returns
-------
Expand All @@ -829,7 +833,8 @@ def rerun_jobs(
name=name,
metadata=metadata,
workers=workers,
custom_query=custom_query,
custom_query=custom_query
| ({"error": {"$regex": err_regex}} if err_regex else {}),
raise_on_error=raise_on_error,
force=force,
wait=wait,
Expand Down
Loading