-
Notifications
You must be signed in to change notification settings - Fork 48
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
Optionally ignore errors during iteration #680
Comments
Try something like this: for item in results.items():
try:
results_data.append([item.id, item.datetime, item.bbox, str(item.links[3]).split('=')[2][:-1]])
except Exception as err:
print(f"error during iteration: {err}") |
Hi @gadomski , I tried that already and gives the same error. I think the problem is inside the |
My apologies, I didn't think too hard about the problem ... that's my bad. It may be nice to have a |
Thank you! Probably something like this:
|
@EmanuelCastanho I started on an implementation, but it wasn't feeling right. I'm not sure that an
items = list()
try:
for item in results.items():
items.append(item)
except APIError:
pass
# you've gotten as many items as you can |
I was checking this just now and I will see if I can deal with the error. Meanwhile, the error can be replicated with:
Unfortunately, I don't know which product is causing the crash, so the example has 5046 products, the error happens at 4840. |
Looks like it's a problem with the server — it's generating really long The script: import json
import tqdm
from pystac_client import Client
api = Client.open("https://eocat.esa.int/eo-catalogue/")
results = api.search(
method="GET",
collections=["GEOSAT-2.Portugal.Coverage", "GEOSAT2SpainCoverage10"],
max_items=None,
filter="instrument = 'HiRAIS' and sensorMode = 'PM4'",
)
progress_bar = tqdm.tqdm()
try:
last_page = None
for page in results.pages_as_dicts():
progress_bar.total = page["numberMatched"]
progress_bar.update(page["numberReturned"])
last_page = page
except:
print(json.dumps(last_page)) Going to close this issue as not-a-problem-with-pystac-client — you can use this issue as a reference if you contact that API's maintainers to tell them about this issue. The really long linkhttps://eocat.esa.int/eo-catalogue/search?collections=GEOSAT-2.Portugal.Coverage%2CGEOSAT2SpainCoverage10&filter=instrument+%3D+%27HiRAIS%27+and+sensorMode+%3D+%27PM4%27&filter-lang=cql2-text&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&status=695,4351&startRecord=4841 |
I have this piece of code:
At some point in the loop it gives me this error:
pystac_client.exceptions.APIError: <!doctype html><html lang="en"><head><title>HTTP Status 400 – Bad Request</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} h1 {font-size:22px;} h2 {font-size:16px;} h3 {font-size:14px;} p {font-size:12px;} a {color:black;} .line {height:1px;background-color:#525D76;border:none;}</style></head><body><h1>HTTP Status 400 – Bad Request</h1></body></html>
I understand there is some item that is making the loop to break, but how to ignore this item in the generator?
The text was updated successfully, but these errors were encountered: