Skip to content

Unintended AttributeError when attempting to download granules before an order #688

@trey-stafford

Description

@trey-stafford

Prior to icepyx 2, it was possible to search for data and then immediately call download_granules, without calling order_granules first.

Now, it is expected that a harmony order be placed first. However, an AttributeError is raised instead of a ValueError with an informative error message:

import datetime as dt

import icepyx as ipx


date_range = (dt.date(2007, 1, 1), dt.date(2024, 10, 28))

lower_left_lon=-49.149
lower_left_lat=69.186
upper_right_lon=-48.949
upper_right_lat=69.238

result = ipx.Query(
    "ATL06",
    [
        lower_left_lon,
        lower_left_lat,
        upper_right_lon,
        upper_right_lat,
    ],
    date_range,
)

result.download_granules("downloaded-data/ATL06/")
Traceback (most recent call last):
  File "/home/trst2284/code/icepyx/scratch.py", line 24, in <module>
    result.download_granules("downloaded-data/ATL06/")
  File "/home/trst2284/code/icepyx/icepyx/core/query.py", line 1028, in download_granules
    status = self.last_order.status()
             ^^^^^^^^^^^^^^^
AttributeError: 'Query' object has no attribute 'last_order'

I think we just need to fix this line to:

if not hasattr(self, "last_order")

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions