Commit 373df3ba authored by Mitar's avatar Mitar

Improving style.

parent 00b38d6c
Pipeline #99046401 failed with stages
in 35 minutes and 41 seconds
......@@ -71,7 +71,7 @@ def resolve_pipeline(pipelines_dir, pipeline_id):
def process_interface_version(interface_version):
known_primitives = {}
primitives_used_in_pipelines = set()
error = False
has_errored = False
for primitive_annotation_path in glob.iglob('{interface_version}/*/*/*/primitive.json'.format(interface_version=interface_version)):
try:
......@@ -79,7 +79,7 @@ def process_interface_version(interface_version):
primitive_annotation = json.load(primitive_annotation_file)
if primitive_annotation['id'] in known_primitives:
error = True
has_errored = True
print("Error: Duplicate primitive IDs, '{first_python_path}' and '{second_python_path}'.".format(
first_python_path=known_primitives[primitive_annotation['id']]['python_path'],
second_python_path=primitive_annotation['python_path'],
......@@ -90,7 +90,7 @@ def process_interface_version(interface_version):
print("Error at primitive '{primitive_annotation_path}'.".format(primitive_annotation_path=primitive_annotation_path), flush=True)
traceback.print_exc()
sys.stdout.flush()
error = True
has_errored = True
for pipeline_run_path in itertools.chain(
glob.iglob('{interface_version}/*/*/*/pipeline_runs/*.yaml.gz'.format(interface_version=interface_version)),
......@@ -107,7 +107,7 @@ def process_interface_version(interface_version):
try:
pipeline = resolve_pipeline(pipelines_dir, pipeline_id)
except PipelineNotFoundError:
error = True
has_errored = True
print("Error: Could not resolve pipeline '{pipeline_id}' in '{pipelines_dir}' for pipeline run '{pipeline_run_path}'.".format(
pipeline_id=pipeline_id,
pipelines_dir=pipelines_dir,
......@@ -122,14 +122,14 @@ def process_interface_version(interface_version):
print("Error at pipeline run '{pipeline_run_path}'.".format(pipeline_run_path=pipeline_run_path), flush=True)
traceback.print_exc()
sys.stdout.flush()
error = True
has_errored = True
for primitive_id, primitive in known_primitives.items():
if primitive_id not in primitives_used_in_pipelines:
error = True
has_errored = True
print(primitive['source']['name'], primitive['id'], primitive['python_path'], flush=True)
return error
return has_errored
def main():
......@@ -137,11 +137,11 @@ def main():
parser.add_argument('interface_versions', metavar='INTERFACE', nargs='*', help="interface version(s) to compute coverage for", default=())
arguments = parser.parse_args()
error = False
has_errored = False
for interface_version in arguments.interface_versions:
error = process_interface_version(interface_version) or error
has_errored = process_interface_version(interface_version) or has_errored
if error:
if has_errored:
sys.exit(1)
......
......@@ -9,7 +9,7 @@ import traceback
def process_interface_version(interface_version):
known_primitives = {}
error = False
has_errored = False
for primitive_annotation_path in glob.iglob('{interface_version}/*/*/*/primitive.json'.format(interface_version=interface_version)):
try:
......@@ -17,7 +17,7 @@ def process_interface_version(interface_version):
primitive_annotation = json.load(primitive_annotation_file)
if primitive_annotation['id'] in known_primitives:
error = True
has_errored = True
print("Error: Duplicate primitive IDs, '{first_python_path}' and '{second_python_path}'.".format(
first_python_path=known_primitives[primitive_annotation['id']]['python_path'],
second_python_path=primitive_annotation['python_path'],
......@@ -28,9 +28,9 @@ def process_interface_version(interface_version):
print("Error at primitive '{primitive_annotation_path}'.".format(primitive_annotation_path=primitive_annotation_path), flush=True)
traceback.print_exc()
sys.stdout.flush()
error = True
has_errored = True
return error
return has_errored
def main():
......@@ -38,11 +38,11 @@ def main():
parser.add_argument('interface_versions', metavar='INTERFACE', nargs='*', help="interface version(s) to check primitives for", default=())
arguments = parser.parse_args()
error = False
has_errored = False
for interface_version in arguments.interface_versions:
error = process_interface_version(interface_version) or error
has_errored = process_interface_version(interface_version) or has_errored
if error:
if has_errored:
sys.exit(1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment