diff --git a/app.py b/app.py index dcf9d92..373bf3b 100644 --- a/app.py +++ b/app.py @@ -70,6 +70,7 @@ def return_cutouts(payload=None): return format_and_send_cutout(payload) + if __name__ == "__main__": import yaml diff --git a/apps/utils.py b/apps/utils.py index 53f3649..1277a5d 100644 --- a/apps/utils.py +++ b/apps/utils.py @@ -26,11 +26,10 @@ def readstamp(stamp: str, return_type="array", gzipped=True): - """ - """ + """ """ + def extract_stamp(fitsdata): - """ - """ + """ """ with fits.open(fitsdata, ignore_missing_simple=True) as hdul: if return_type == "array": data = hdul[0].data.tolist() @@ -49,6 +48,7 @@ def extract_stamp(fitsdata): else: return extract_stamp(stamp) + def format_and_send_cutout(payload: dict) -> pd.DataFrame: """Extract data returned by HBase and jsonify it @@ -68,7 +68,9 @@ def format_and_send_cutout(payload: dict) -> pd.DataFrame: elif payload["kind"] in ["Science", "Template", "Difference"]: columns = ["objectId", "cutout{}".format(payload["kind"])] else: - raise AssertionError("`col_kind` must be one of Science, Template, Difference, or All.") + raise AssertionError( + "`col_kind` must be one of Science, Template, Difference, or All." + ) return_type = payload.get("return_type", "array") @@ -97,9 +99,10 @@ def format_and_send_cutout(payload: dict) -> pd.DataFrame: ) # TODO: check the table is not empty dic = table.to_pydict() - cutouts = [] - for col in columns[1:]: - cutouts.append(readstamp(dic[col][0]["stampData"], return_type=return_type)) + cutouts = [ + readstamp(dic[col][0]["stampData"], return_type=return_type) + for col in columns[1:] + ] if return_type == "array": return jsonify(cutouts)