Skip to content

Commit 62c3c8e

Browse files
Allow localtileserver prefix override and fix inferred prefix on JH (#1314)
* Allow localtileserver prefix override and fix inferred prefix on JH * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * apply copilot recommendations --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 02fddd9 commit 62c3c8e

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

leafmap/common.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3316,19 +3316,23 @@ def get_local_tile_layer(
33163316
for key in client_args:
33173317
kwargs[key] = client_args[key]
33183318

3319-
# Make it compatible with binder and JupyterHub
3320-
if os.environ.get("JUPYTERHUB_SERVICE_PREFIX") is not None:
3321-
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = (
3322-
f"{os.environ['JUPYTERHUB_SERVICE_PREFIX'].lstrip('/')}/proxy/{{port}}"
3323-
)
3319+
# Only override LOCALTILESERVER_CLIENT_PREFIX if it's unset
3320+
if os.environ.get("LOCALTILESERVER_CLIENT_PREFIX") is None:
3321+
# Make it compatible with binder and JupyterHub
3322+
if os.environ.get("JUPYTERHUB_SERVICE_PREFIX") is not None:
3323+
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = (
3324+
f"{os.environ['JUPYTERHUB_SERVICE_PREFIX'].strip('/')}/proxy/{{port}}"
3325+
)
33243326

3325-
if is_studio_lab():
3326-
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = (
3327-
f"studiolab/default/jupyter/proxy/{{port}}"
3328-
)
3329-
elif is_on_aws():
3330-
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = "proxy/{port}"
3331-
elif "prefix" in kwargs:
3327+
if is_studio_lab():
3328+
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = (
3329+
f"studiolab/default/jupyter/proxy/{{port}}"
3330+
)
3331+
elif is_on_aws():
3332+
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = "proxy/{port}"
3333+
3334+
# The prefix kwarg has final precedence
3335+
if "prefix" in kwargs:
33323336
os.environ["LOCALTILESERVER_CLIENT_PREFIX"] = kwargs["prefix"]
33333337
kwargs.pop("prefix")
33343338

0 commit comments

Comments
 (0)