Skip to content

Commit

Permalink
feat: remove s3 upload as is now uploaded to artifacts bucket
Browse files Browse the repository at this point in the history
  • Loading branch information
MDavidson17 committed Jul 22, 2022
1 parent 23c9058 commit 4492929
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
8 changes: 5 additions & 3 deletions scripts/gdal_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ def command_to_string(command: List[str]) -> str:
return " ".join(command)


def run_gdal(command: List[str], input_file: str = "", output_file: str = "") -> "subprocess.CompletedProcess[bytes]":
def run_gdal(
command: List[str], input_file: Optional[str] = None, output_file: Optional[str] = None, input_file_index: Optional[int] = None
) -> "subprocess.CompletedProcess[bytes]":
"""Run the GDAL command. The permissions to access to the input file are applied to the gdal environment.
Args:
command (List[str]): each arguments of the GDAL command.
input_file (str, optional): the input file path. Defaults to "".
output_file (str, optional): the output file path. Defaults to "".
input_file (str, optional): the input file path.
output_file (str, optional): the output file path.
Raises:
cpe: CalledProcessError is raised if something goes wrong during the execution of the command.
Expand Down
16 changes: 4 additions & 12 deletions scripts/standardising.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,22 @@
import os
import tempfile

from aws_helper import get_bucket, parse_path
from aws_helper import parse_path
from file_helper import get_file_name_from_path
from format_source import format_source
from gdal_helper import run_gdal
from linz_logger import get_log

parser = argparse.ArgumentParser()
parser.add_argument("--source", dest="source", nargs="+", required=True)
parser.add_argument("--destination", dest="destination", required=True)

arguments = parser.parse_args()
source = arguments.source
destination = arguments.destination


source = format_source(source)

get_log().info("standardising", source=source, destination=destination)
dst_bucket_name, dst_path = parse_path(destination)
get_log().debug("destination", bucket=dst_bucket_name, file_path=dst_path)
dst_bucket = get_bucket(dst_bucket_name)
get_log().info("standardising", source=source)
gdal_env = os.environ.copy()

for file in source:
Expand Down Expand Up @@ -69,8 +66,3 @@
"sparse_ok=true",
]
run_gdal(command, input_file=file, output_file=tmp_file_path)

# Upload the standardized file to destination
dst_file_path = os.path.join(dst_path, standardized_file_name).strip("/")
get_log().debug("upload_file", path=dst_file_path)
dst_bucket.upload_file(tmp_file_path, dst_file_path)

0 comments on commit 4492929

Please sign in to comment.