Commit 0d3c4ca9 authored by Nico's avatar Nico
Browse files

fix when pipeline id file doesnt exists

parent beb2863e
......@@ -16,7 +16,7 @@ PROJECT_ID = 1
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-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()
def find_version_from_archive(archive_file_list):
......@@ -52,11 +52,13 @@ if args.pipeline_id is None:
pipeline_id = find_latest_pipeline_id()
if args.pipeline_id_file:
pipeline_id_file = args.pipeline_id_file.read()
if pipeline_id == args.pipeline_id_file:
print("Pipeline up to date")
sys.exit(1)
try:
with open(args.pipeline_id_file, "r") as pipeline_id_file:
if pipeline_id == pipeline_id_file.read():
print("Pipeline up to date")
sys.exit(1)
except FileNotFoundError:
pass
else:
pipeline_id = args.pipeline_id
......@@ -79,8 +81,8 @@ for job in pipeline_jobs:
artifact_zip.extractall("gluon/output/")
os.rename("gluon/output", version)
if args.pipeline_id_file:
args.pipeline_id_file.truncate(0)
args.pipeline_id_file.write(pipeline_id)
with open(args.pipeline_id_file, "w") as pipeline_id_file:
pipeline_id_file.write(str(pipeline_id))
else:
print(f"'{version}' already exists")
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