Skip to content

pystac_client.exceptions.apierror: the request exceeded the maximum allowed time, please try again. if the issue persists, please contact [email protected]. #382

Description

@mmcfarland部署了一个似乎已解决问题的变更。我们会继续监控,但如果您继续看到这些错误,请告诉我们。

@mmcfarland部署了一个似乎已解决问题的变更。我们会继续监控,但如果您继续看到这些错误,请告诉我们。

@mmcfarland deployed a change that seems to have resolved things. We'll keep monitoring it, but do let us know if you continue to see these errors.

@mmcfarland deployed a change that seems to have resolved things. We'll keep monitoring it, but do let us know if you continue to see these errors.

import json
import pystac_client
import planetary_computer
from pystac_client import Client, Modifiable
from django.views.decorators.csrf import csrf_exempt
from django.views.decorators.http import require_POST
from django.http import JsonResponse
from urllib.parse import urlparse
@csrf_exempt
@require_POST
def search_NDVI(request):
if request.method == 'POST':
start_date = request.POST.get('start_date')
end_date = request.POST.get('end_date')
cloud_cover = request.POST.get('cloud_cover')
time_of_interest = f'{start_date}/{end_date}'
geojson_str = request.POST.get('geojson')

    if not geojson_str or not start_date or not end_date:
        return JsonResponse(status=400)

    try:
        geojson = json.loads(geojson_str)
    except json.JSONDecodeError:
        return JsonResponse({'error': 'geosonerror'}, status=400)

    
    if 'features' not in geojson or not geojson['features']:
        return JsonResponse({'error': 'GeoJSONerror'}, status=400)

    area_of_interest = geojson['features'][0]['geometry']

    catalog = pystac_client.Client.open(
        "https://planetarycomputer.microsoft.com/api/stac/v1",
        modifier=planetary_computer.sign_inplace,
    )  

    search = catalog.search(
        collections=["sentinel-2-l2a"],
        intersects=area_of_interest,
        datetime=time_of_interest,
        query={"eo:cloud_cover": {"lt": cloud_cover}},
    )

    items = list(search.get_items())
    if not items:
        return JsonResponse({'message': 'no image'}, status=200)

    item_details = []
    for item in items:

        item_link = item.assets["visual"].href

        parsed_url = urlparse(item_link)
        filename = parsed_url.path.split('/')[-1]
        filename_without_ext = filename.split('.')[0]

        cloud_cover = item.properties['eo:cloud_cover']

        item_details.append({
            'Image ID':item.id, 
            'Product parameters': filename_without_ext, 
            'Shooting date': str(item.datetime.date()), 
            'Cloud cover': cloud_cover, 
        })


    return JsonResponse({'message': 'successful', 'Data information': item_details})

return JsonResponse({'error': 'POST'}, status=405)

I also encountered the same problem when I integrated the functionality into Django

Wrong content:pystac_client.exceptions.apierror: the request exceeded the maximum allowed time, please try again. if the issue persists, please contact [email protected].

Originally posted by @Mrjoecen in #240

Activity

  1. 777arc commented on Oct 18, 2024

    @777arc
    Contributor

    Around the time you posted this issue we had a service degradation, mind checking again now that it's back up?

  2. 777arc commented on Oct 20, 2024

    @777arc
    Contributor

    Pretty sure this was due to the outage, closing, re-open if you find it is still happening

  3. Ethan-Chen421 commented on Oct 20, 2024

    @Ethan-Chen421
    Author

    Pretty sure this was due to the outage, closing, re-open if you find it is still happening

    Thank you for your reply. Yesterday, the service was accessible normally, but today it is intermittent.

  4. 777arc commented on Oct 21, 2024

    @777arc
    Contributor

    Hmm ok, can you elaborate on the intermittent aspect, eg what calls are being slow and how slow

  5. Ethan-Chen421 commented on Oct 22, 2024

    @Ethan-Chen421
    Author

    Hmm ok, can you elaborate on the intermittent aspect, eg what calls are being slow and how slow

    Hello, I visited today and the service has been restored quickly. Thank you very much for your reply

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions