Skip to content

Commit

Permalink
debug: access log middleware
Browse files Browse the repository at this point in the history
  • Loading branch information
xgui3783 committed Oct 2, 2024
1 parent 7478fb6 commit fd88739
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .helm/adhoc/copy-cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
- /bin/ash
args:
- -c
- "echo FROM_DIR: $FROM_DIR TO_DIR: $TO_DIR && mkdir $TO_DIR && cp -r $FROM_DIR/* $TO_DIR/"
- "echo FROM_DIR: $FROM_DIR TO_DIR: $TO_DIR && mkdir -p $TO_DIR && cp -r $FROM_DIR/* $TO_DIR/"
resources:
limits:
cpu: 1000m
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.3.18
0.3.19
3 changes: 3 additions & 0 deletions api/server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,8 @@ async def middleware_add_version_header(request: Request, call_next):
@siibra_api.middleware("http")
async def middleware_access_log(request: Request, call_next):
"""Access log middleware"""

print("AccessLog middleware called")

if request.url.path in do_not_logs:
return await call_next(request)
Expand All @@ -324,6 +326,7 @@ async def middleware_access_log(request: Request, call_next):
"hit_cache": "cache_miss"
})
except Exception as e:
print("Exception at logging:", type(e), str(e))
general_logger.critical(e)

# some plugins may strip origin header for privacy reasons
Expand Down
1 change: 0 additions & 1 deletion api/server/volumes/parcellationmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ def get_resampled_map(parcellation_id: str, space_id: str, *, func):
"""Get resampled map according to specification"""
if func is None:
raise HTTPException(500, f"func: None passsed")
raise HTTPException(501, "Not yet implemented. If you are using this endpoint, please contact us.")
headers={
"content-type": "application/octet-stream",
"content-disposition": f'attachment; filename="labelled_map.nii.gz"'
Expand Down
1 change: 1 addition & 0 deletions api/siibra_api_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ def get_config_dir_short_hash(path_to_config: str):
"features",
"volumes",
"compounds",
"vocabularies",
]

class CELERY_CONFIG:
Expand Down
10 changes: 6 additions & 4 deletions new_api/data_handlers/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,15 @@ def cache_resampled_map(parcellation_id: str, space_id: str, *, no_cache: bool):

import nibabel as nib
import siibra
from siibra.commons.maps import resample_img_to_img
from siibra.operations.volume_fetcher.nifti import ResampleNifti

mp = siibra.get_map(parcellation_id, space_id, "labelled")
nii = mp.fetch()
src_dp = mp.extract_full_map()
nii = src_dp.get_data()
space = siibra.get_space(space_id)
tmpl_nii = space.fetch_template()
resampled = resample_img_to_img(nii, tmpl_nii)
target_dp = space.get_dataprovider(index=0)
tmpl_nii = target_dp.get_data()
resampled = ResampleNifti.resample_img_to_img(nii, tmpl_nii)

nib.save(resampled, full_filename)
with open(f"{full_filename}.{str(int(time.time()))}.json", "w") as fp:
Expand Down
2 changes: 1 addition & 1 deletion requirements/v4-siibra.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# refactor_attr is... borked since dataops are being introduced
git+https://github.com/xgui3783/siibra-python.git@aeffb478a1c98f3bec276ab820f5e50355c598a4
git+https://github.com/xgui3783/siibra-python.git@90ba8150f4d3b01c36176b03ffa906f8090907cd

0 comments on commit fd88739

Please sign in to comment.