-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cli:ppg2-filter-constraint-violations
- Loading branch information
1 parent
3fc485a
commit 4dc423e
Showing
3 changed files
with
67 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
"""CLI interface to ppg2""" | ||
|
||
import pyzstd | ||
import re | ||
import sys | ||
import pypipegraph2 as ppg2 | ||
|
||
|
||
def filter_constraint_violations(filename=None, pipegraph=None): | ||
"""For when you really need to remove some jobs from the pipegraph's history. | ||
Takes a filename with job ids. | ||
Defaults to .ppg/errors/latest/constraint_violations.jobs | ||
If you have your ppg history in a non standard place, pass in a ppg | ||
with the correct directories set. | ||
""" | ||
if pipegraph is None: | ||
pipegraph = ppg2.new() | ||
|
||
if sys.argv[1:]: | ||
filename = sys.argv[1] | ||
if filename is None: | ||
filename = pipegraph.error_dir / "latest/constraint_violations.jobs" | ||
|
||
history = pipegraph._load_history() | ||
|
||
to_del = set() | ||
for key, v in history.items(): | ||
found = False | ||
for x in q: | ||
if key.startswith(x) or key.endswith(x): | ||
print("Would delete") | ||
print("\t", key) | ||
print("\t", x) | ||
print("") | ||
to_del.add(key) | ||
found = True | ||
if found: | ||
break | ||
print("Delete {len(to_del)} history entries?") | ||
print("type yes<enter> to proceed") | ||
print("This tool does not create backups. Make a snapshot of your project first") | ||
for x in to_del: | ||
del history[x] | ||
if input() == "yes": | ||
ppg2.global_pipegraph._save_history(history) | ||
else: | ||
print("aborted") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters