Skip to content

Commit

Permalink
deploy: reverse volume mapping
Browse files Browse the repository at this point in the history
deploy: more efficient service meta
fix: tests/remapping url
  • Loading branch information
xgui3783 committed Aug 29, 2024
1 parent c565a9e commit eef3c7d
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 25 deletions.
1 change: 0 additions & 1 deletion .helm/adhoc/configmaps-siibra-api-common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ data:
# when prod migrates to 0.3.18, remove prepend
_MONITOR_FIRSTLVL_DIR: /siibra-api-volume
SIIBRA_API_REMAP_PROVIDERS: |-
https://neuroglancer.humanbrainproject.eu::https://data-proxy.ebrains.eu/api/v1/buckets/reference-atlas-data
https://object.cscs.ch/v1/AUTH_08c08f9f119744cbbf77e216988da3eb::https://data-proxy.ebrains.eu/api/v1/buckets/reference-atlas-data/imgsvc
kind: ConfigMap
metadata:
Expand Down
10 changes: 5 additions & 5 deletions api/serialization/volumes/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ def remap_provider(obj: Dict[str, Union[dict, str]]) -> None:
"""
if len(SIIBRA_API_REMAP_PROVIDERS) == 0:
return obj
for key, value in obj.items():
if isinstance(value, str):
for key in obj:
if isinstance(obj[key], str):
for from_host, to_host in SIIBRA_API_REMAP_PROVIDERS.items():
obj[key] = value.replace(from_host, to_host)
if isinstance(value, dict):
remap_provider(value)
obj[key] = obj[key].replace(from_host, to_host)
if isinstance(obj[key], dict):
remap_provider(obj[key])


@serialize(Volume)
Expand Down
21 changes: 13 additions & 8 deletions api/server/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,23 @@ def get_ready():
TODO: implement me"""
return "ready"

_code_meta = None
@siibra_api.get("/about", include_in_schema=False)
def servicemeta():
with open(Path(__file__).parent.parent.parent / "codemeta.json", "r") as fp:
code_meta = json.load(fp=fp)
global _code_meta
if _code_meta is None:
with open(Path(__file__).parent.parent.parent / "codemeta.json", "r") as fp:
_code_meta = json.load(fp=fp)
if _code_meta is None:
raise Exception("code meta is not found, cannot populate servicemeta")
return {
"@context": "https://gitlab.ebrains.eu/lauramble/servicemeta/-/raw/main/data/contexts/servicemeta.jsonld",
"type": "WebApplication",
"author": code_meta["author"],
"dateModified": code_meta["dateModified"],
"author": _code_meta["author"],
"dateModified": _code_meta["dateModified"],
"documentation": DOCUMENTATION_URL,
"name": code_meta["name"],
"version": code_meta["version"],
"name": _code_meta["name"],
"version": _code_meta["version"],
"inputFormat": INPUT_FORMAT,
"outputFormat": OUTPUT_FORMAT
}
Expand Down Expand Up @@ -113,7 +118,7 @@ async def read_bytes(generator) -> bytes:
"metrics",
"openapi.json",
"atlas_download",
"servicemeta",
"/about",
]

do_no_cache_query_list = [
Expand All @@ -124,7 +129,7 @@ async def read_bytes(generator) -> bytes:
do_not_logs = (
"/ready",
"/metrics",
"servicemeta"
"/about"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
instance_to_model
)

receptor_fp_feats = ReceptorDensityFingerprint._get_instances()
receptor_fp_feats = ReceptorDensityFingerprint.get_instances()

def test_length():
assert len(receptor_fp_feats) > 0
Expand Down
11 changes: 6 additions & 5 deletions test/serialization/features/test_connectivity.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

jba29 = parcellations['2.9']

streamline_counts = [f for f in StreamlineCounts._get_instances()]
streamline_lengths = [f for f in StreamlineLengths._get_instances()]
functional_conn = [f for f in FunctionalConnectivity._get_instances()]
streamline_counts = [f for f in StreamlineCounts.get_instances()]
streamline_lengths = [f for f in StreamlineLengths.get_instances()]
functional_conn = [f for f in FunctionalConnectivity.get_instances()]

all_connectivity: list[RegionalConnectivity] = [
*streamline_counts,
Expand All @@ -25,14 +25,15 @@ def test_conn(conn: RegionalConnectivity):

if not os.getenv("FAST_RUN"):
@pytest.mark.parametrize("conn,subject",
[(f, f.subject)
[(f, subject)
for f in all_connectivity
for subject in f.subjects
if jba29 in f.anchor.parcellations],
ids=lambda arg: f"name: {arg.name!r} paradigm: {arg.paradigm if hasattr(arg, 'paradigmn') else ''}"
if isinstance(arg, RegionalConnectivity)
else f"subject: {arg!r}")
def test_conn_subject(conn: RegionalConnectivity, subject: str):
model = instance_to_model(conn, subject=subject, detail=True)
assert isinstance(model, SiibraRegionalConnectivityModel)
assert model.matrix is not None
assert model.matrices is not None
model.dict()
6 changes: 3 additions & 3 deletions test/serialization/features/test_tabular.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ def get_random_n(n: int, lls: List[List[Any]]):
for ls in lls
]

celldensity = LayerwiseCellDensity._get_instances()
bb_intensities = LayerwiseBigBrainIntensities._get_instances()
receptor_fp_features = ReceptorDensityFingerprint._get_instances()
celldensity = LayerwiseCellDensity.get_instances()
bb_intensities = LayerwiseBigBrainIntensities.get_instances()
receptor_fp_features = ReceptorDensityFingerprint.get_instances()

all_fp_features = [
*bb_intensities[10:],
Expand Down
4 changes: 2 additions & 2 deletions test/serialization/features/test_voi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
)

features = [feat
for Cls in Feature._SUBCLASSES[Image]
for feat in Cls._get_instances()]
for Cls in Feature.SUBCLASSES[Image]
for feat in Cls.get_instances()]

def test_len():
assert len(features) > 0
Expand Down

0 comments on commit eef3c7d

Please sign in to comment.