Skip to content

Commit

Permalink
format script and pyproject config
Browse files Browse the repository at this point in the history
  • Loading branch information
marshtompsxd committed Sep 12, 2021
1 parent 68af99f commit 326fcc1
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 57 deletions.
3 changes: 3 additions & 0 deletions format.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash

python3 -m black .
95 changes: 40 additions & 55 deletions oracle.py
Original file line number Diff line number Diff line change
Expand Up @@ -235,14 +235,11 @@ def check_status(learning_status, testing_status):
for attr in learning_status[rtype]:
if learning_status[rtype][attr] != testing_status[rtype][attr]:
alarm += 1
bug_report += (
"[ERROR] %s %s inconsistency: %s seen after learning run, but %s seen after testing run\n"
% (
rtype,
attr.upper(),
str(learning_status[rtype][attr]),
str(testing_status[rtype][attr]),
)
bug_report += "[ERROR] %s %s inconsistency: %s seen after learning run, but %s seen after testing run\n" % (
rtype,
attr.upper(),
str(learning_status[rtype][attr]),
str(testing_status[rtype][attr]),
)
final_bug_report = (
"Liveness assertion failed:\n" + bug_report if bug_report != "" else ""
Expand Down Expand Up @@ -328,16 +325,13 @@ def check_side_effect(
continue
if learning_entry[attr] != testing_entry[attr]:
alarm += 1
bug_report += (
"[ERROR] %s/%s/%s %s inconsistency: %s events seen during learning run, but %s seen during testing run\n"
% (
rtype,
namespace,
name,
attr.upper(),
str(learning_entry[attr]),
str(testing_entry[attr]),
)
bug_report += "[ERROR] %s/%s/%s %s inconsistency: %s events seen during learning run, but %s seen during testing run\n" % (
rtype,
namespace,
name,
attr.upper(),
str(learning_entry[attr]),
str(testing_entry[attr]),
)
final_bug_report = (
"Safety assertion failed:\n" + bug_report if bug_report != "" else ""
Expand All @@ -346,34 +340,28 @@ def check_side_effect(


def generate_time_travel_debugging_hint(testing_config):
desc = (
"Sieve makes the controller time travel back to the history to see the status just %s %s: %s"
% (
testing_config["timing"],
testing_config["ce-rtype"]
+ "/"
+ testing_config["ce-namespace"]
+ "/"
+ testing_config["ce-name"],
testing_config["ce-diff-current"],
)
desc = "Sieve makes the controller time travel back to the history to see the status just %s %s: %s" % (
testing_config["timing"],
testing_config["ce-rtype"]
+ "/"
+ testing_config["ce-namespace"]
+ "/"
+ testing_config["ce-name"],
testing_config["ce-diff-current"],
)
suggestion = (
"Please check how controller reacts when seeing %s: %s, the controller might issue %s to %s without proper checking"
% (
testing_config["ce-rtype"]
+ "/"
+ testing_config["ce-namespace"]
+ "/"
+ testing_config["ce-name"],
testing_config["ce-diff-current"],
"deletion" if testing_config["se-etype"] == "ADDED" else "creation",
testing_config["se-rtype"]
+ "/"
+ testing_config["se-namespace"]
+ "/"
+ testing_config["se-name"],
)
suggestion = "Please check how controller reacts when seeing %s: %s, the controller might issue %s to %s without proper checking" % (
testing_config["ce-rtype"]
+ "/"
+ testing_config["ce-namespace"]
+ "/"
+ testing_config["ce-name"],
testing_config["ce-diff-current"],
"deletion" if testing_config["se-etype"] == "ADDED" else "creation",
testing_config["se-rtype"]
+ "/"
+ testing_config["se-namespace"]
+ "/"
+ testing_config["se-name"],
)
return desc + "\n" + suggestion + "\n"

Expand All @@ -387,16 +375,13 @@ def generate_obs_gap_debugging_hint(testing_config):
+ testing_config["ce-name"],
testing_config["ce-diff-current"],
)
suggestion = (
"Please check how controller reacts when seeing %s: %s, the event can trigger a controller side effect, and it might be cancelled by following events"
% (
testing_config["ce-rtype"]
+ "/"
+ testing_config["ce-namespace"]
+ "/"
+ testing_config["ce-name"],
testing_config["ce-diff-current"],
)
suggestion = "Please check how controller reacts when seeing %s: %s, the event can trigger a controller side effect, and it might be cancelled by following events" % (
testing_config["ce-rtype"]
+ "/"
+ testing_config["ce-namespace"]
+ "/"
+ testing_config["ce-name"],
testing_config["ce-diff-current"],
)
return desc + "\n" + suggestion + "\n"

Expand Down
21 changes: 21 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[tool.black]
line-length = 88
target-version = ['py36']
include = '\.pyi?$'
exclude = '''
/(
\.eggs # exclude a few common directories in the
| \.git # root of the project
| \.hg
| \.mypy_cache
| \.tox
| \.venv
| _build
| buck-out
| build
| dist
| fakegopath
| log
| app
)/
'''
8 changes: 6 additions & 2 deletions sieve.py
Original file line number Diff line number Diff line change
Expand Up @@ -664,14 +664,18 @@ def run_batch(project, test, dir, mode, stage, docker):
sieve_modes.OBS_GAP,
sieve_modes.ATOM_VIO,
"learn",
], ("invalid mode option: %s" % options.mode)
], (
"invalid mode option: %s" % options.mode
)
assert options.phase in [
"all",
"setup_only",
"workload_only",
"check_only",
"workload_and_check",
], ("invalid phase option: %s" % options.phase)
], (
"invalid phase option: %s" % options.phase
)

print("Running Sieve with %s: %s..." % (options.stage, options.mode))

Expand Down

0 comments on commit 326fcc1

Please sign in to comment.