-
Notifications
You must be signed in to change notification settings - Fork 99
Expand file tree
/
Copy pathanalysis.py
More file actions
22 lines (21 loc) · 1.05 KB
/
analysis.py
File metadata and controls
22 lines (21 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import subprocess
from .SDAHelper import *
def handler(event):
benchmark_bucket = event["benchmark_bucket"]
cluster_output_bucket = event["cluster_output_bucket"]
TMP_DIR = create_tmp_dir()
analysis_input_file = download_shp_file(benchmark_bucket,cluster_output_bucket,event["cluster_output_file"],TMP_DIR)
config_file = load_config(event, TMP_DIR)
OUTPUT_STEM = "Analysis_"+Path(analysis_input_file).stem
command = ["SettlementDelineationAnalysis", "-i", str(analysis_input_file), "-c", str(config_file), "--outputStem", OUTPUT_STEM]
result = subprocess.run(command,capture_output=True,text=True, cwd=TMP_DIR)
if result.returncode != 0:
event["stdout"] = result.stdout
event["stderr"] = result.stderr
return event
event.pop("cluster_output_file", None)
event["analysis_output_files"]= []
for file in Path(TMP_DIR).glob(f"{OUTPUT_STEM}*.shp"):
upload_shp_file(benchmark_bucket, event["analysis_output_bucket"],file)
event["analysis_output_files"].append(file.name)
return event