Skip to content

Commit

Permalink
feat: log standardised image gdal virtual path when non visual qa error
Browse files Browse the repository at this point in the history
TDE-563 (#239)

* feat: log standardised image gdal virtual path when non visual qa error

* fix: too many local variables, remove useless variable

* refactor: use os.path.join to build virtual path

* style: disable pylint msg for too many local variables
  • Loading branch information
paulfouquet authored Dec 6, 2022
1 parent 58d4cd2 commit e121df8
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions scripts/standardise_validate.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@


def main() -> None:
# pylint: disable-msg=too-many-locals
parser = argparse.ArgumentParser()
parser.add_argument("--preset", dest="preset", required=True)
parser.add_argument("--source", dest="source", nargs="+", required=True)
Expand All @@ -28,10 +29,8 @@ def main() -> None:
arguments = parser.parse_args()

source = format_source(arguments.source)
scale = int(arguments.scale)
start_datetime = format_date(arguments.start_datetime)
end_datetime = format_date(arguments.end_datetime)
collection_id = arguments.collection_id
concurrency: int = 1
if is_argo():
concurrency = 4
Expand All @@ -48,16 +47,20 @@ def main() -> None:
continue

# Validate the file
file_check = FileCheck(file, scale, srs)
file_check = FileCheck(file, int(arguments.scale), srs)
if not file_check.validate():
get_log().info("non_visual_qa_errors", file=file_check.path, errors=file_check.errors)
vfs_path = ""
env_argo_template = os.environ.get("ARGO_TEMPLATE")
if env_argo_template:
argo_template = json.loads(env_argo_template)
s3_information = argo_template["archiveLocation"]["s3"]
vfs_path = os.path.join("/vsis3", s3_information["bucket"], s3_information["key"], file_check.path)
get_log().info("non_visual_qa_errors", file=file_check.path, vfspath=vfs_path, errors=file_check.errors)
else:
get_log().info("non_visual_qa_passed", file=file_check.path)
# Get the new path if the file has been renamed
file = file_check.path

# Create STAC
gdalinfo = file_check.get_gdalinfo()
item = create_item(file, start_datetime, end_datetime, collection_id, gdalinfo)
item = create_item(file_check.path, start_datetime, end_datetime, arguments.collection_id, file_check.get_gdalinfo())
tmp_file_path = os.path.join("/tmp/", f"{item.stac['id']}.json")
write(tmp_file_path, json.dumps(item.stac).encode("utf-8"))
get_log().info("stac item written to tmp", location=tmp_file_path)
Expand Down

0 comments on commit e121df8

Please sign in to comment.