apply suggestions from code review

This commit is contained in:
Stavros kois
2024-07-11 14:31:29 +03:00
parent 17175ec345
commit f4a0f7def9
3 changed files with 42 additions and 14 deletions

View File

@@ -1,2 +1,2 @@
[flake8]
max-line-length = 250
max-line-length = 120

52
.github/scripts/ci.py vendored
View File

@@ -25,11 +25,35 @@ def print_stderr(msg):
def parse_args():
parser = argparse.ArgumentParser()
parser.add_argument("--app", required=True, help="The name of the app")
parser.add_argument("--train", required=True, help="The name of the train for the app")
parser.add_argument("--test-file", required=True, help="Name of the test file to use as values")
parser.add_argument("--render-only", required=False, default=False, type=bool, help="Prints the rendered docker-compose file")
parser.add_argument("--render-only-debug", required=False, default=False, type=bool, help="Prints the rendered docker-compose file even if it's not a valid yaml")
parser.add_argument(
"--app",
required=True,
help="The name of the app",
)
parser.add_argument(
"--train",
required=True,
help="The name of the train for the app",
)
parser.add_argument(
"--test-file",
required=True,
help="Name of the test file to use as values",
)
parser.add_argument(
"--render-only",
required=False,
default=False,
type=bool,
help="Prints the rendered docker-compose file",
)
parser.add_argument(
"--render-only-debug",
required=False,
default=False,
type=bool,
help="Prints the rendered docker-compose file even if it's not a valid yaml",
)
parsed = parser.parse_args()
return {
@@ -188,9 +212,9 @@ def get_failed_containers():
# Outputs one container per line, in json format
cmd = f"{get_base_cmd()} ps --all --format json"
print_cmd(cmd)
failed = subprocess.run(cmd, shell=True, capture_output=True).stdout.decode("utf-8")
all_containers = subprocess.run(cmd, shell=True, capture_output=True).stdout.decode("utf-8")
failed_containers = []
for line in failed.split("\n"):
for line in all_containers.split("\n"):
if not line:
continue
try:
@@ -199,9 +223,10 @@ def get_failed_containers():
print_stderr(f"Failed to parse container status output:\n {line}")
sys.exit(1)
actual_failed = []
failed = []
for container in failed_containers:
# Skip containers that are exited with 0 (eg init containers), but not restarting (during a restart exit code is 0)
# Skip containers that are exited with 0 (eg init containers),
# but not restarting (during a restart exit code is 0)
if all(
[
container.get("Health", "") == "" or container.get("Health", "") == "healthy",
@@ -209,11 +234,14 @@ def get_failed_containers():
not container.get("State", "") == "restarting",
]
):
print_stderr(f"Skipping container [{container['Name']}({container['ID']})] with status [{container.get('State')}] because it exited with 0 and has no health status")
print_stderr(
f"Skipping container [{container['Name']}({container['ID']})] with status [{container.get('State')}]"
+ " because it exited with 0 and has no health status"
)
continue
actual_failed.append(container)
failed.append(container)
return actual_failed
return failed
def get_container_name(container):

View File

@@ -9,7 +9,7 @@
"editor.formatOnSave": false,
"editor.formatOnPaste": false
},
"black-formatter.args": ["--line-length", "250"],
"black-formatter.args": ["--line-length", "120"],
"[python]": {
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.defaultFoldingRangeProvider": "ms-python.flake8",