diff --git a/lambdas/list_tiled_analysis/src/lambda_function.py b/lambdas/list_tiled_analysis/src/lambda_function.py index cf57a5f..97ee3c7 100644 --- a/lambdas/list_tiled_analysis/src/lambda_function.py +++ b/lambdas/list_tiled_analysis/src/lambda_function.py @@ -12,39 +12,38 @@ @xray_recorder.capture("Tiled Analysis") def handler(event, context): - raise NameError("foo") - # try: - # LOGGER.info(f"Running analysis with parameters: {event}") - - # query = event["query"] - # fid = event.get("fid", None) - # geojson = mapping(loads(bytes.fromhex(event["geometry"]))) - # data_environment = DataEnvironment(layers=event["data_environment"]) - - # LOGGER.info(f"Executing query: {query}") - # LOGGER.info(f"On geometry: {geojson}") - - # tiler = AnalysisTiler(query, geojson, context.aws_request_id, data_environment) - # tiler.execute() - - # results = tiler.result_as_dict() - - # LOGGER.info("Successfully merged tiled results") - # response = {"status": "success", "data": results} - # if fid: - # response["fid"] = fid - - # return response - # except QueryParseException as e: - # response = {"status": "failed", "message": str(e)} - # if fid: - # response["fid"] = fid - - # return response - # except Exception as e: - # LOGGER.exception(e) - # response = {"status": "error", "message": str(e)} - # if fid: - # response["fid"] = fid - - # return response + try: + LOGGER.info(f"Running analysis with parameters: {event}") + + query = event["query"] + fid = event.get("fid", None) + geojson = mapping(loads(bytes.fromhex(event["geometry"]))) + data_environment = DataEnvironment(layers=event["data_environment"]) + + LOGGER.info(f"Executing query: {query}") + LOGGER.info(f"On geometry: {geojson}") + + tiler = AnalysisTiler(query, geojson, context.aws_request_id, data_environment) + tiler.execute() + + results = tiler.result_as_dict() + + LOGGER.info("Successfully merged tiled results") + response = {"status": "success", "data": results} + if fid: + response["fid"] = fid + + return response + except QueryParseException as e: + response = {"status": "failed", "message": str(e)} + if fid: + response["fid"] = fid + + return response + except Exception as e: + LOGGER.exception(e) + response = {"status": "error", "message": str(e)} + if fid: + response["fid"] = fid + + return response