Skip to content

Commit

Permalink
linter
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPeloton committed Nov 22, 2024
1 parent 10a5b32 commit d7cf5f0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def return_cutouts(payload=None):

return format_and_send_cutout(payload)


if __name__ == "__main__":
import yaml

Expand Down
19 changes: 11 additions & 8 deletions apps/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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
Expand All @@ -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")

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit d7cf5f0

Please sign in to comment.