Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NickAkhmetov/HMP-549 Revise to use assaytype endpoint #3361

Merged
merged 12 commits into from
Jan 4, 2024
Merged
2 changes: 2 additions & 0 deletions CHANGELOG-HMP-549.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Update portal-visualization to 0.1.0.
- Remove vitessce conf generation usage of TypeClient.
18 changes: 10 additions & 8 deletions context/app/api/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import requests
import json
from werkzeug.exceptions import HTTPException
from hubmap_commons.type_client import TypeClient

from .client_utils import files_from_response
from portal_visualization.builder_factory import get_view_config_builder
Expand Down Expand Up @@ -70,11 +69,15 @@ def __init__(self, url_base=None, groups_token=None):
self.url_base = url_base
self.groups_token = groups_token

def _get_headers(self):
headers = {'Authorization': 'Bearer ' + self.groups_token} if self.groups_token else {}
return headers

def _request(self, url, body_json=None):
'''
Makes request to HuBMAP APIs behind API Gateway (Search, Entity, UUID).
'''
headers = {'Authorization': 'Bearer ' + self.groups_token} if self.groups_token else {}
headers = self._get_headers()
response = _handle_request(url, headers, body_json)
status = response.status_code
# HuBMAP APIs will redirect to s3 if the response payload over 10 MB.
Expand Down Expand Up @@ -205,12 +208,11 @@ def get_vitessce_conf_cells_and_lifted_uuid(self, entity, marker=None, wrap_erro
# Otherwise, just try to visualize the data for the entity itself:
else:
try:
def get_assay(name):
type_client = TypeClient(
current_app.config["TYPE_SERVICE_ENDPOINT"]
+ current_app.config["TYPE_SERVICE_PATH"])
return type_client.getAssayType(name)
Builder = get_view_config_builder(entity=entity, get_assay=get_assay)
def get_assaytype(entity):
uuid = entity.get('uuid')
url = f"{current_app.config['SOFT_ASSAY_ENDPOINT']}/{uuid}"
return requests.get(url, headers=self._get_headers()).json()
Builder = get_view_config_builder(entity, get_assaytype)
builder = Builder(entity, self.groups_token, current_app.config["ASSETS_ENDPOINT"])
vitessce_conf = builder.get_conf_cells(marker=marker)
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions context/app/default_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ class DefaultConfig(object):
WORKSPACES_WS_ENDPOINT = 'should-be-overridden'
USER_TEMPLATES_ENDPOINT = 'should-be-overriden'
UBKG_ENDPOINT = 'should-be-overridden'
SOFT_ASSAY_ENDPOINT = 'should-be-overridden'

SECRET_KEY = 'should-be-overridden'
APP_CLIENT_ID = 'should-be-overridden'
Expand Down
2 changes: 1 addition & 1 deletion context/requirements.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ hubmap-commons>=2.1.10
boto3==1.28.17

# Plain "git+https://github.com/..." references can't be hashed, so we point to a release zip instead.
https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.0.13.zip
https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.1.0.zip

# Security warning for older versions;
# Can be removed when commons drops prov dependency.
Expand Down
31 changes: 15 additions & 16 deletions context/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# This file is autogenerated by pip-compile with Python 3.9
# by the following command:
# This file is autogenerated by pip-compile with python 3.9
# To update, run:
#
# pip-compile --allow-unsafe --generate-hashes --output-file=context/requirements.txt context/requirements.in
#
Expand Down Expand Up @@ -146,7 +146,7 @@ boto3==1.28.17 \
--hash=sha256:90f7cfb5e1821af95b1fc084bc50e6c47fa3edc99f32de1a2591faa0c546bea7 \
--hash=sha256:bca0526f819e0f19c0f1e6eba3e2d1d6b6a92a45129f98c0d716e5aab6d9444b
# via
# -r requirements.in
# -r context/requirements.in
# hubmap-commons
botocore==1.31.17 \
--hash=sha256:396459065dba4339eb4da4ec8b4e6599728eb89b7caaceea199e26f7d824a41c \
Expand Down Expand Up @@ -312,7 +312,7 @@ flask==2.3.3 \
--hash=sha256:09c347a92aa7ff4a8e7f3206795f30d826654baf38b873d0744cd571ca609efc \
--hash=sha256:f69fcd559dc907ed196ab9df0e48471709175e696d6e698dd4dbe940f96ce66b
# via
# -r requirements.in
# -r context/requirements.in
# hubmap-commons
fonttools==4.42.0 \
--hash=sha256:01cfe02416b6d416c5c8d15e30315cbcd3e97d1b50d3b34b0ce59f742ef55258 \
Expand Down Expand Up @@ -425,7 +425,7 @@ globus-sdk==3.9.0 \
--hash=sha256:456f707b25a8c502607134f1d699b5970ef1aa9d17877474db73fc6d87c711e9 \
--hash=sha256:a196070b549d6af534a7fa8a180eae6ab84c0745959d5ee2d3863705eef9c7fc
# via
# -r requirements.in
# -r context/requirements.in
# hubmap-commons
h5py==3.9.0 \
--hash=sha256:12aa556d540f11a2cae53ea7cfb94017353bd271fb3962e1296b342f6550d1b8 \
Expand Down Expand Up @@ -455,12 +455,12 @@ h5py==3.9.0 \
hubmap-api-py-client==0.0.9 \
--hash=sha256:8af6df46374ed838d3aeb5fb7298d7212145eb0f8dca01c095147fb05e304ee2 \
--hash=sha256:9a4601d8d3df9c56d6803cee2678844589808bd9df71657ac459a2559c0a3ccd
# via -r requirements.in
# via -r context/requirements.in
hubmap-commons==2.1.10 \
--hash=sha256:38c83d9d05457a22ba0a5ccad2001887917d9729ffcfb605395b59c46bfafdba \
--hash=sha256:571d8dbd881982453bb36e1b88de9f5bf52d7c9345e5689cc3a625c64241e0f6
# via
# -r requirements.in
# -r context/requirements.in
# portal-visualization
idna==3.3 \
--hash=sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff \
Expand Down Expand Up @@ -704,7 +704,7 @@ lxml==4.9.1 \
--hash=sha256:fe17d10b97fdf58155f858606bddb4e037b805a60ae023c009f760d8361a4eb8 \
--hash=sha256:fe749b052bb7233fe5d072fcb549221a8cb1a16725c47c37e42b0b9cb3ff2c3f
# via
# -r requirements.in
# -r context/requirements.in
# prov
markupsafe==2.1.1 \
--hash=sha256:0212a68688482dc52b2d45013df70d169f542b7394fc744c02a57374a4207003 \
Expand Down Expand Up @@ -1111,9 +1111,9 @@ platformdirs==2.5.1 \
--hash=sha256:7535e70dfa32e84d4b34996ea99c5e432fa29a708d0f4e394bbcb2a8faa4f16d \
--hash=sha256:bcae7cab893c2d310a711b70b24efb93334febe65f8de776ee320b517471e227
# via black
portal-visualization @ https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.0.13.zip \
--hash=sha256:535aae34a790942445bf67b54f1df8c64adfd4cdd813599791005264cd7834a9
# via -r requirements.in
portal-visualization @ https://github.com/hubmapconsortium/portal-visualization/archive/refs/tags/0.1.0.zip \
--hash=sha256:2eb042bd492e5e9c0007c38d2c2b644ccc614ce65d92792dc3a25bdd703ca665
# via -r context/requirements.in
property==2.2 \
--hash=sha256:d25e4da4e415408b9eb39b6521c088e4e2b8a9e2f9f96fb2d91680e97207ea19
# via hubmap-commons
Expand Down Expand Up @@ -1164,7 +1164,7 @@ pyrsistent==0.18.1 \
python-datauri==0.2.8 \
--hash=sha256:5d6062ff85bc785a2230c40151d5aded80f1ce8652d5a31e3a64c78aa6e52a20 \
--hash=sha256:68e8699cf2754a66f185f486c8d4c73e7ee5304aa53253bad0434fdbbde3f0b7
# via -r requirements.in
# via -r context/requirements.in
python-dateutil==2.8.2 \
--hash=sha256:0123cacc1627ae19ddf3c27a5de5bd67ee4586fbdd6440d9748f8abb483d3e86 \
--hash=sha256:961d03dc3453ebbc59dbdea9e4e11c5651520a876d0f4db161e8674aae935da9
Expand All @@ -1176,7 +1176,7 @@ python-dateutil==2.8.2 \
python-frontmatter==0.5.0 \
--hash=sha256:a7dcdfdaf498d488dce98bfa9452f8b70f803a923760ceab1ebd99291d98d28a \
--hash=sha256:a9c2e90fc38e9f0c68d8b82299040f331ca3b8525ac7fa5f6beffef52b26c426
# via -r requirements.in
# via -r context/requirements.in
pytz==2022.1 \
--hash=sha256:1e760e2fe6a8163bc0b3d9a19c4f84342afa0a2affebfaa84b01b978a02ecaa7 \
--hash=sha256:e68985985296d9a66a881eb3193b0906246245294a881e7c8afe623866ac6a5c
Expand Down Expand Up @@ -1234,7 +1234,7 @@ pyyaml==5.4 \
--hash=sha256:f7a21e3d99aa3095ef0553e7ceba36fb693998fbb1226f1392ce33681047465f \
--hash=sha256:fdc6b2cb4b19e431994f25a9160695cc59a4e861710cc6fc97161c5e845fc579
# via
# -r requirements.in
# -r context/requirements.in
# dask
# hubmap-commons
# python-frontmatter
Expand All @@ -1246,7 +1246,7 @@ requests==2.27.1 \
--hash=sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61 \
--hash=sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d
# via
# -r requirements.in
# -r context/requirements.in
# globus-sdk
# hubmap-api-py-client
# hubmap-commons
Expand Down Expand Up @@ -1425,7 +1425,6 @@ typing-extensions==4.1.1 \
--hash=sha256:1a9462dcc3347a79b1f1c0271fbe79e844580bb598bafa1ed208b94da3cdcd42 \
--hash=sha256:21c85e0fe4b9a155d0799430b0ad741cdce7e359660ccbd8b530613e8df88ce2
# via
# aioitertools
# black
# globus-sdk
umap-learn==0.5.3 \
Expand Down
39 changes: 21 additions & 18 deletions example-app.conf
Copy link
Collaborator Author

@NickAkhmetov NickAkhmetov Jan 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I adjusted the spacing of the commented out endpoints so they're all aligned with the USER_TEMPLATES_ENDPOINT - this was purely an aesthetic change. The meaningful additions are the different SOFT_ASSAY_ENDPOINT values for the TEST, DEV and PROD environments and the removal of the TYPE_SERVICE values.

Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,26 @@ WORKSPACES_ENDPOINT = 'https://workspaces-api.dev.hubmapconsortium.org'
WORKSPACES_WS_ENDPOINT = 'https://ws-workspaces-api.dev.hubmapconsortium.org'
USER_TEMPLATES_ENDPOINT = 'https://user-templates-api.dev.hubmapconsortium.org'
UBKG_ENDPOINT = 'https://ontology.api.hubmapconsortium.org'

# GATEWAY_ENDPOINT = 'https://gateway.api.hubmapconsortium.org'
# ELASTICSEARCH_ENDPOINT = 'https://search-api.dev.hubmapconsortium.org'
# TYPE_SERVICE_ENDPOINT = 'https://search-api.dev.hubmapconsortium.org'
# ENTITY_API_BASE = 'https://entity-api.dev.hubmapconsortium.org'
# ASSETS_ENDPOINT = 'https://assets.dev.hubmapconsortium.org'
# XMODALITY_ENDPOINT = 'https://cells.api.hubmapconsortium.org'
# WORKSPACES_ENDPOINT = 'https://workspaces-api.dev.hubmapconsortium.org'
# WORKSPACES_WS_ENDPOINT = 'https://ws-workspaces-api.dev.hubmapconsortium.org'
SOFT_ASSAY_ENDPOINT = 'https://ingest-api.test.hubmapconsortium.org/assaytype'

# GATEWAY_ENDPOINT = 'https://gateway.api.hubmapconsortium.org'
# ELASTICSEARCH_ENDPOINT = 'https://search-api.dev.hubmapconsortium.org'
# TYPE_SERVICE_ENDPOINT = 'https://search-api.dev.hubmapconsortium.org'
# ENTITY_API_BASE = 'https://entity-api.dev.hubmapconsortium.org'
# ASSETS_ENDPOINT = 'https://assets.dev.hubmapconsortium.org'
# XMODALITY_ENDPOINT = 'https://cells.api.hubmapconsortium.org'
# WORKSPACES_ENDPOINT = 'https://workspaces-api.dev.hubmapconsortium.org'
# WORKSPACES_WS_ENDPOINT = 'https://ws-workspaces-api.dev.hubmapconsortium.org'
# USER_TEMPLATES_ENDPOINT = 'https://user-templates-api.dev.hubmapconsortium.org'

# GATEWAY_ENDPOINT = 'https://gateway.api.hubmapconsortium.org'
# ELASTICSEARCH_ENDPOINT = 'https://search.api.hubmapconsortium.org'
# TYPE_SERVICE_ENDPOINT = 'https://search.api.hubmapconsortium.org'
# ENTITY_API_BASE = 'https://entity.api.hubmapconsortium.org'
# ASSETS_ENDPOINT = 'https://assets.hubmapconsortium.org'
# XMODALITY_ENDPOINT = 'https://cells.api.hubmapconsortium.org'
# WORKSPACES_ENDPOINT = 'https://workspaces.api.hubmapconsortium.org'
# WORKSPACES_WS_ENDPOINT = 'https://ws-workspaces.api.hubmapconsortium.org'
# SOFT_ASSAY_ENDPOINT = 'https://ingest-api.dev.hubmapconsortium.org/assaytype'

# GATEWAY_ENDPOINT = 'https://gateway.api.hubmapconsortium.org'
# ELASTICSEARCH_ENDPOINT = 'https://search.api.hubmapconsortium.org'
# TYPE_SERVICE_ENDPOINT = 'https://search.api.hubmapconsortium.org'
# ENTITY_API_BASE = 'https://entity.api.hubmapconsortium.org'
# ASSETS_ENDPOINT = 'https://assets.hubmapconsortium.org'
# XMODALITY_ENDPOINT = 'https://cells.api.hubmapconsortium.org'
# WORKSPACES_ENDPOINT = 'https://workspaces.api.hubmapconsortium.org'
# WORKSPACES_WS_ENDPOINT = 'https://ws-workspaces.api.hubmapconsortium.org'
# USER_TEMPLATES_ENDPOINT = 'https://user-templates.api.hubmapconsortium.org'
# SOFT_ASSAY_ENDPOINT = 'https://ingest.api.hubmapconsortium.org/assaytype'
Loading