Skip to content

Commit

Permalink
Add URL HOST redirect
Browse files Browse the repository at this point in the history
  • Loading branch information
GeekLogan committed Sep 10, 2024
1 parent 5f7aa4c commit 9e0529a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ ARG dataset_id=packed2
ARG public_url=http://localhost

ENV CDN_URL=$cdn_url
ENV CDN_URL_HOST=$cdn_url
ENV CDN_URL_LOCAL=$cdn_url
ENV CDN_URL_LOCAL_HOST=$cdn_url
ENV NEUROGLANCER_PORT=$neuroglancer_port
Expand Down
2 changes: 1 addition & 1 deletion backend/ntracer/ntracer_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ def request_fileserver_update(state: NtracerState):
with state.viewer.txn() as s:
nonce = random.getrandbits(16)
s.layers["annotate_pre"] = neuroglancer.viewer_state.SegmentationLayer(
source=f"{state.precomputed_cdn_url_local_host.geturl()}+{nonce}/skeleton/",
source=f"precomputed://{state.cdn_url_local_host_dataset.geturl()}+{nonce}/skeleton/",
skeleton_rendering=neuroglancer.viewer_state.SkeletonRenderingOptions(
mode2d="lines", line_width2d=1
),
Expand Down
22 changes: 8 additions & 14 deletions backend/ntracer/ntracer_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,20 @@ class NtracerState:
dataset_id: str = os.environ["DATASET_ID"]

cdn_url = urlparse(os.environ["CDN_URL"])
"""Base URL for CDN server"""
cdn_url_dataset = urlparse(posixpath.join(cdn_url.geturl(), dataset_id))
"""Base URL for CDN server used by SERVER"""

cdn_url_host = urlparse(os.environ["CDN_URL_HOST"])
cdn_url_host_dataset = urlparse(posixpath.join(cdn_url_host.geturl(), dataset_id))
"""URL used to show CDN images to HOST"""

cdn_url_local = urlparse(os.environ["CDN_URL_LOCAL"])
cdn_url_local_dataset = urlparse(posixpath.join(cdn_url_local.geturl(), dataset_id))
"""URL used for tracing skeletons, default CDN_URL"""

cdn_url_local_host = urlparse(os.environ["CDN_URL_LOCAL_HOST"])
cdn_url_local_host_dataset = urlparse(posixpath.join(cdn_url_local_host.geturl(), dataset_id))
"""URL used for tracing skeleton host access, default CDN_URL"""

precomputed_cdn_url_local_host = urlparse(posixpath.join(cdn_url_local_host.geturl(), dataset_id))
precomputed_cdn_url_local_host = precomputed_cdn_url_local_host._replace(
scheme=f'precomputed://{precomputed_cdn_url_local_host.scheme}'
)

cdn_url_dataset = urlparse(posixpath.join(cdn_url.geturl(), dataset_id))
"""CDN URL with dataset appended"""

precomputed_base = cdn_url_dataset._replace(
scheme=f"precomputed://{cdn_url.scheme}"
)
"""CDN URL with dataset and precomputed scheme"""

database_url: str = posixpath.join(
#cdn_url.geturl(), f"{dataset_id}/skeleton_api"
Expand Down
4 changes: 2 additions & 2 deletions backend/ntracer/visualization/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def image_init(

s.layers["image"] = neuroglancer.viewer_state.ImageLayer(
# source=coords.layer, #need to make this nicer?
source=state.precomputed_base.geturl(),
source=f'precomputed://{state.cdn_url_host_dataset.geturl()}',
shader=Constants.DEFAULT_SHADER,
)

s.layers["annotate_pre"] = neuroglancer.viewer_state.SegmentationLayer(
source=f"{state.precomputed_cdn_url_local_host.geturl()}/skeleton",
source=f"precomputed://{state.cdn_url_host_dataset.geturl()}/skeleton",
skeleton_rendering=neuroglancer.viewer_state.SkeletonRenderingOptions(
mode2d="lines", line_width2d=1
),
Expand Down

0 comments on commit 9e0529a

Please sign in to comment.