Motivation: Implement async requests
This is a very simple performance comparison between approaches for running search queries via pystac-client:
In an effort to aid comparison (not only performance, but also code differences), the code is intentionally simple, and has been construction such that diffing the files should make it readily apparent as to the required changes from the baseline to the 2 concurrent approaches.
The code here is based upon the code in the notebook in this other gist: https://gist.github.com/TomAugspurger/50c3573d39213a2cb450d02074e4db01
python -m venv .venv
source .venv/bin/activate
python -m pip install -U pip
python -m pip install dask-geopandas gevent httpx pystac-client requests scalene
Generate polygons (written to hulls.json
) to use for search intersection by
the 3 approaches listed above:
python hulls.py
We'll use Scalene so we can get more information than simply elapsed times. The general form is as follows:
scalene --cli QUERY_SCRIPT [--- N]
where QUERY_SCRIPT
is one of:
query.py
(sequential)query-asyncio.py
(HTTPX)query-gevent.py
(gevent)
and N
is an integer specifying the number of queries to execute (default: 10).
Note that there are 3 dashes (not 2) preceding N
, as required by Scalene.
Further, as hulls.py
is written here, only 250 polygons are generated, so the
maximum value for N
is 250.
For example, to run each query implementation, running 50 queries for each:
scalene --cli query.py --- 50
scalene --cli query-asyncio.py --- 50
scalene --cli query-gevent.py --- 50
For other output options, including web output, run scalene -h
.