eodash_catalog 0.0.34__tar.gz → 0.0.36__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/.bumpversion.cfg +1 -1
  2. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/PKG-INFO +1 -1
  3. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/__about__.py +1 -1
  4. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/sh_endpoint.py +7 -5
  5. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/.github/workflows/ci.yml +0 -0
  6. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/.github/workflows/python-publish.yml +0 -0
  7. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/.gitignore +0 -0
  8. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/.vscode/extensions.json +0 -0
  9. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/.vscode/settings.json +0 -0
  10. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/LICENSE.txt +0 -0
  11. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/README.md +0 -0
  12. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/pyproject.toml +0 -0
  13. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/requirements.txt +0 -0
  14. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/ruff.toml +0 -0
  15. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/__init__.py +0 -0
  16. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/duration.py +0 -0
  17. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/endpoints.py +0 -0
  18. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/generate_indicators.py +0 -0
  19. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/stac_handling.py +0 -0
  20. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/thumbnails.py +0 -0
  21. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/src/eodash_catalog/utils.py +0 -0
  22. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/__init__.py +0 -0
  23. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/test-data/regional_forecast.json +0 -0
  24. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/test_generate.py +0 -0
  25. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-catalogs/testing.yaml +0 -0
  26. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-collections/test_CROPOMAT1.yaml +0 -0
  27. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-collections/test_see_solar_energy.yaml +0 -0
  28. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-collections/test_tif_demo_1.yaml +0 -0
  29. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-collections/test_tif_demo_2.yaml +0 -0
  30. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-collections/test_wms_no_time.yaml +0 -0
  31. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-indicators/test_indicator.yaml +0 -0
  32. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-layers/baselayers.yaml +0 -0
  33. {eodash_catalog-0.0.34 → eodash_catalog-0.0.36}/tests/testing-layers/overlays.yaml +0 -0
@@ -1,5 +1,5 @@
1
1
  [bumpversion]
2
- current_version = 0.0.34
2
+ current_version = 0.0.36
3
3
  commit = True
4
4
  tag = True
5
5
  parse = (?P<major>\d+)\.(?P<minor>\d+)\.(?P<patch>\d+)(\-(?P<release>[a-z]+)\.(?P<build>\d+))?
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: eodash_catalog
3
- Version: 0.0.34
3
+ Version: 0.0.36
4
4
  Summary: This package is intended to help create a compatible STAC catalog for the eodash dashboard client. It supports configuration of multiple endpoint types for information extraction.
5
5
  Project-URL: Documentation, https://github.com/eodash/eodash_catalog#readme
6
6
  Project-URL: Issues, https://github.com/eodash/eodash_catalog/issues
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2024-present Daniel Santillan <daniel.santillan@eox.at>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.0.34"
4
+ __version__ = "0.0.36"
@@ -1,10 +1,11 @@
1
1
  import os
2
+ import time
2
3
 
3
4
  from oauthlib.oauth2 import BackendApplicationClient
4
5
  from requests_oauthlib import OAuth2Session
5
6
 
6
7
  SH_TOKEN_URL = "https://services.sentinel-hub.com/oauth/token"
7
- _token_cache: dict[str, str] = {}
8
+ _token_cache: dict[str, dict] = {}
8
9
 
9
10
 
10
11
  def get_SH_token(endpoint_config: dict) -> str:
@@ -14,8 +15,10 @@ def get_SH_token(endpoint_config: dict) -> str:
14
15
  if env_id := endpoint_config.get("CustomSHEnvId"):
15
16
  client_id = os.getenv(f"SH_CLIENT_ID_{env_id}", "")
16
17
  client_secret = os.getenv(f"SH_CLIENT_SECRET_{env_id}", "")
17
- if client_id in _token_cache:
18
- return _token_cache[client_id]
18
+ # 10 minutes before end of validity
19
+ safety_buffer_validity = _token_cache[client_id]["expires_at"] - (60 * 10)
20
+ if client_id in _token_cache and (safety_buffer_validity) > (time.time()):
21
+ return _token_cache[client_id]["access_token"]
19
22
  # Create a session
20
23
  client = BackendApplicationClient(client_id=client_id)
21
24
  oauth = OAuth2Session(client=client)
@@ -25,6 +28,5 @@ def get_SH_token(endpoint_config: dict) -> str:
25
28
  client_secret=client_secret,
26
29
  )
27
30
  access_token = token["access_token"]
28
- _token_cache[client_id] = access_token
29
-
31
+ _token_cache[client_id] = {"access_token": access_token, "expires_at": token["expires_at"]}
30
32
  return access_token