Skip to content

imagery: Update i.eodag for EODAG v4 compatibility and add pyotp support#1663

Open
polucifier wants to merge 2 commits intoOSGeo:grass8from
polucifier:grass8
Open

imagery: Update i.eodag for EODAG v4 compatibility and add pyotp support#1663
polucifier wants to merge 2 commits intoOSGeo:grass8from
polucifier:grass8

Conversation

@polucifier
Copy link
Copy Markdown

Description

This PR updates the i.eodag module to ensure compatibility with the latest EODAG v4 release while maintaining full backward compatibility for users on EODAG v3. It also introduces automated two-factor authentication (TOTP) for the Creodias provider.

Solves #1659

Changes

  • EODAG v4 Support: Updated internal logic to handle Pydantic-based STAC objects, new property accessors, and the transition from productType to collection.
  • Backward Compatibility: Implemented a compatibility layer to detect EODAG version and switch between v3/v4 API calls dynamically.
  • Automated MFA (2FA): Added integration with the pyotp library. If a totp_secret is provided in the EODAG configuration, the module now generates the 6-digit OTP code automatically, removing the need for manual terminal input.
  • Improved Testsuite: Updated test_eodag.py to adapt search parameters to the installed EODAG version.
  • Code Cleanup: Removed obsolete TODOs and improved inline documentation/comments.

Verification

  • Verified with EODAG v4.x.
  • Verified with EODAG v3.x.
  • Successfully performed automated downloads from Creodias using the new PyOTP logic.
  • All test_eodag.py tests passed in both environments.

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

pre-commit

[pre-commit] reported by reviewdog 🐶


[pre-commit] reported by reviewdog 🐶


[pre-commit] reported by reviewdog 🐶


[pre-commit] reported by reviewdog 🐶


[pre-commit] reported by reviewdog 🐶

Copy link
Copy Markdown
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Remaining comments which cannot be posted as a review comment to avoid GitHub Rate Limit

ruff

[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

p_id = p.get("ID") # This is fine for v3


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

def print_eodag_queryables(eodag_api, **kwargs) -> None:


[ruff] reported by reviewdog 🐶

The function extracts metadata (type, default value, and requirement)


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

if hasattr(potential_type, "__name__") and potential_type.__name__ == "Optional":


[ruff] reported by reviewdog 🐶

q_dict["type"] = getattr(potential_type, "__name__", str(potential_type))


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

q_dict["type"] = "int" # Fallback assumption for v3 ranges


[ruff] reported by reviewdog 🐶

if len(inner_args) > 0 and hasattr(inner_args[0], "__metadata__"):


[ruff] reported by reviewdog 🐶

getattr(range_meta[1], "lt", None)


[ruff] reported by reviewdog 🐶

def print_query(geometry, queryables, **kwargs) -> None:


[ruff] reported by reviewdog 🐶

p["ID"] if isinstance(p, dict) else getattr(p, "id", str(p))


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

gs.fatal(_("Product type <{}> not available.").format(options["producttype"]))


[ruff] reported by reviewdog 🐶

{pid.strip() for pid in options["id"].split(",")}, # product.id is consistent


[ruff] reported by reviewdog 🐶

gs.verbose(_("Reading stored search result from file <{}>").format(options["file"]))


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

ids = {pid.strip() for pid in id_file.read_text(encoding="UTF8").strip().split("\n")}


[ruff] reported by reviewdog 🐶

gs.fatal(_("Unable to read product IDs from file <{}>.").format(options["file"]))


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

dates_to_iso_format() # Validates date order and formats


[ruff] reported by reviewdog 🐶

search_parameters = {


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

gs.message(_("Please enter Creodias OTP (enter '-' to discard Creodias scenes): "))


[ruff] reported by reviewdog 🐶

search_result = SearchResult([s for s in search_result if s.provider != "creodias"])


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶


[ruff] reported by reviewdog 🐶

flags="j", # Use -j to get JSON output for easier parsing


[ruff] reported by reviewdog 🐶

scene_id = scene["id"] # Get ID directly from JSON output


[ruff] reported by reviewdog 🐶

sensor_mode = props.get("instrumentMode") or \
props.get("platform:instrument:mode") or \
props.get("sat:instrument_mode")

@polucifier polucifier force-pushed the grass8 branch 3 times, most recently from 61c586f to 3b6728c Compare March 29, 2026 00:48
- Add full support for EODAG v4 API (handling Pydantic STAC objects, .collection, and .providers).
- Maintain strict backward compatibility with EODAG v3 (fallback to .productType and dictionary properties).
- Implement automatic TOTP (2FA) generation for the Creodias provider using the 'pyotp' library.
- Fix testsuite (test_eodag.py) to dynamically switch between v3/v4 search parameters.
@neteler neteler requested a review from landam March 31, 2026 19:30
@neteler neteler added the Python Related code is in Python label Mar 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Python Related code is in Python

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants