Skip to content
Snippets Groups Projects
Commit 0d3c4ca9 authored by Nico's avatar Nico
Browse files

fix when pipeline id file doesnt exists

parent beb2863e
No related branches found
No related tags found
No related merge requests found
...@@ -16,7 +16,7 @@ PROJECT_ID = 1 ...@@ -16,7 +16,7 @@ PROJECT_ID = 1
ap = argparse.ArgumentParser() ap = argparse.ArgumentParser()
ap.add_argument("--pipeline-id", help="Pipeline ID to download. If omitted, download latest successfull.", default=None) ap.add_argument("--pipeline-id", help="Pipeline ID to download. If omitted, download latest successfull.", default=None)
ap.add_argument("--pipeline-id-file", help="Store downloaded Pipeline ID in this file and only download if latest pipeline ID doesn't match file contents", type=argparse.FileType("r+")) ap.add_argument("--pipeline-id-file", help="Store downloaded Pipeline ID in this file and only download if latest pipeline ID doesn't match file contents")
args = ap.parse_args() args = ap.parse_args()
def find_version_from_archive(archive_file_list): def find_version_from_archive(archive_file_list):
...@@ -52,11 +52,13 @@ if args.pipeline_id is None: ...@@ -52,11 +52,13 @@ if args.pipeline_id is None:
pipeline_id = find_latest_pipeline_id() pipeline_id = find_latest_pipeline_id()
if args.pipeline_id_file: if args.pipeline_id_file:
pipeline_id_file = args.pipeline_id_file.read() try:
with open(args.pipeline_id_file, "r") as pipeline_id_file:
if pipeline_id == args.pipeline_id_file: if pipeline_id == pipeline_id_file.read():
print("Pipeline up to date") print("Pipeline up to date")
sys.exit(1) sys.exit(1)
except FileNotFoundError:
pass
else: else:
pipeline_id = args.pipeline_id pipeline_id = args.pipeline_id
...@@ -79,8 +81,8 @@ for job in pipeline_jobs: ...@@ -79,8 +81,8 @@ for job in pipeline_jobs:
artifact_zip.extractall("gluon/output/") artifact_zip.extractall("gluon/output/")
os.rename("gluon/output", version) os.rename("gluon/output", version)
if args.pipeline_id_file: if args.pipeline_id_file:
args.pipeline_id_file.truncate(0) with open(args.pipeline_id_file, "w") as pipeline_id_file:
args.pipeline_id_file.write(pipeline_id) pipeline_id_file.write(str(pipeline_id))
else: else:
print(f"'{version}' already exists") print(f"'{version}' already exists")
sys.exit(1) sys.exit(1)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment