Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: log standardised image gdal virtual path when non visual qa error TDE-563 #239

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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")
amfage marked this conversation as resolved.
Show resolved Hide resolved
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