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

ENV variable loading is fragile #116

Open
wildintellect opened this issue Sep 25, 2023 · 4 comments
Open

ENV variable loading is fragile #116

wildintellect opened this issue Sep 25, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@wildintellect
Copy link
Collaborator

  • stac ipyleaflet version: 0.3.3
  • Python version: Any
  • Operating System: Any

Description

If you miss any of the required ENV variables in the conda config of the environment or don't specify them early enough in a notebook before trying to load a map then you get errors that are not the easiest to read...
image (7)

Ideally we would check/trap these constant loads and issue a clear warning with possible workaround to the users before the Map throws an error. I'm not actually sure why MAAP and VEDA urls are handled differently anyways, can't we just expect a full url supplied every time?

Example:

# @TODO: We need to come here clean this up to make it more agnostic
if "maap" in STAC_BROWSER_URL:
stac_browser_url = self.stac_data["collection"]["href"].replace(
"https://", STAC_BROWSER_URL
)
elif "veda" in STAC_BROWSER_URL:
stac_browser_url = self.stac_data["collection"]["href"].replace(
STAC_CATALOG["url"], STAC_BROWSER_URL

@wildintellect wildintellect added the bug Something isn't working label Sep 25, 2023
wildintellect added a commit that referenced this issue Sep 25, 2023
#116 
Always just sub BROWSER url for STAC url. Can better describe in docs what values are expected. See also #116
@sandrahoang686
Copy link
Collaborator

We will need to update the constants file so that STAC_BROWSER_URL defaults to an empty string as it should be an optional env var. We wont need to check for it then in the checking logic because it will be defaulted.

@wildintellect
Copy link
Collaborator Author

@sandrahoang686 but we would need to handle on the UI side what to do if it's blank.

@chuckwondo
Copy link

I would suggest not using env vars to begin with, in this case. The approach of populating "constants" from env vars is not only very fragile, it also means that it is hard/clumsy to test, and it also means that you cannot have different widgets configured differently.

When using env vars, you want to push their usage to the system interface boundaries. In this case, however, you could probably simply eliminate them altogether.

Of course, I'm not particularly familiar with this code, but I'd suggest eliminating the env vars and adding keyword parameters to the constructor, some of which might have reasonable defaults (e.g., timeout and rescale could have defaults).

This would allow multiple widgets to be configured differently, if that would be something someone might want to do.

@wildintellect
Copy link
Collaborator Author

@chuckwondo I agree that they should be arguments on the constructor, however the defaults vary by platform, e.g. VEDA and MAAP have different defaults and we don't expect users to know all that parameters. So we need some way to set the defaults by platform managers (at install time), with the ability for users to easily override.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants