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

i.eodag: Adjust configuration to breaking changes in EODAG 3.0 #1263

Open
wants to merge 2 commits into
base: grass8
Choose a base branch
from

Conversation

ninsbl
Copy link
Member

@ninsbl ninsbl commented Dec 12, 2024

In EODAG 3.0, kwarg for download outputs_prefix has been renamed to output_dir. See: https://eodag.readthedocs.io/en/stable/breaking_changes.html#b3

In consequence, the output parameter of the module is not respected, and downloaded files end up in a local tempdir.

This PR adjust the kwarg name according to the changes in EODAG.

In EODAG 3.0, kwarg for download _outputs_prefix_ has been renamed to _output_dir_. See: https://eodag.readthedocs.io/en/stable/breaking_changes.html#b3 This PR adjust the kwarg name accordingly.
@ninsbl ninsbl added bug Something isn't working Python Related code is in Python labels Dec 12, 2024
@ninsbl ninsbl requested a review from veroandreo December 12, 2024 14:23
@veroandreo
Copy link
Contributor

@HamedElgizery would you mind checking this, please? Looks fine to me, but I cannot test it right now. Thanks! 🙏

Copy link
Contributor

@HamedElgizery HamedElgizery left a comment

Choose a reason for hiding this comment

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

Thanks for the fix, @ninsbl!
I tested the output_dir change and it is working fine.

Could you please consider the suggestions I left in the skip_existing function, other than that it is working fine.

@@ -879,11 +879,7 @@ def skip_existing(output, search_result):
if scene_file.exists():
creation_time = datetime.utcfromtimestamp(os.path.getctime(scene_file))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
creation_time = datetime.utcfromtimestamp(os.path.getctime(scene_file))
creation_time = str(
datetime.utcfromtimestamp(os.path.getctime(scene_file))
)

Converting to string to be able to normalize it below...

@@ -879,11 +879,7 @@ def skip_existing(output, search_result):
if scene_file.exists():
creation_time = datetime.utcfromtimestamp(os.path.getctime(scene_file))
ingestion_time = scene.properties.get("modificationDate")
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
ingestion_time = scene.properties.get("modificationDate")
ingestion_time = scene.properties.get(
"modificationDate",
scene.properties.get(
"publicationDate", scene.properties.get("creationDate")
),
)

Rollback in case modificationDate doesn't exist...

and datetime.fromisoformat(ingestion_time).replace(tzinfo=None)
<= creation_time
):
if normalize_time(ingestion_time) <= creation_time:
Copy link
Contributor

Choose a reason for hiding this comment

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

There is some cases where ingestion_time woud be None, e.g. if you use the "onda" provider to search for S2_MSI_L2A products there will be no modificationDate parameter. So it is necessary to check if it is None or not before attempting to normalize.

If you run the following for example there won't be modificationDate.
i.eodag -j provider=onda producttype=S2_MSI_L2A output="Onda_S2" limit=1 start=2024-12-20

Suggested change
if normalize_time(ingestion_time) <= creation_time:
if ingestion_time and normalize_time(ingestion_time) <= normalize_time(
creation_time
):

and datetime.fromisoformat(ingestion_time).replace(tzinfo=None)
<= creation_time
):
if normalize_time(ingestion_time) <= creation_time:
# This is to check that the file was completely downloaded
# without interruptions.
# The reason this works:
Copy link
Contributor

Choose a reason for hiding this comment

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

There is also a change that needs to be done to line 892, in accordance with this EODAG change: https://github.com/CS-SI/eodag/pull/1023/files

Could you please change lines [891, 893] to be:

hashed_file = (
    downloaded_dir / md5((scene.product_type+"-"+scene.properties['id']).encode()).hexdigest()
)

To align with the new hashing method.

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

Successfully merging this pull request may close these issues.

3 participants