Skip to main content

Python library for working with Spatiotemporal Asset Catalog (STAC).

Project description

STAC Client

CI Release PyPI version Documentation codecov

A Python client for working with STAC Catalogs and APIs.

Table of Contents

Installation

Install from PyPi. Other than PySTAC itself, the only dependencies for pystac-client is the Python requests and dateutil libraries.

$ pip install pystac-client

Documentation

See the documentation page for the latest docs.

Development

For development, clone the repository and use the standard Python method for installing the library as an "editable link", then install the development dependencies:

$ git clone https://github.com/stac-utils/pystac-client.git
$ cd pystac-client
$ pip install -e .
$ pip install -r requirements-dev.txt

pre-commit is used to ensure a standard set of formatting and linting is run before every commit. These hooks should be installed with:

$ pre-commit install

These can then be run independent of a commit with:

$ pre-commit run --all-files

To run just the tests:

$ pytest -v -s --block-network --cov pystac_client --cov-report term-missing

The pystac-client tests use vcrpy to mock API calls with "pre-recorded" API responses. When adding new tests use the @pytest.mark.vcr decorator function to indicate vcrpy should be used. Record the new responses and commit them to the repository.

$ pytest -v -s --record-mode new_episodes --block-network
$ git add <new files here>
$ git commit -a -m 'new test episodes'

To update pystac-client to use future versions of STAC API, the existing recorded API responses should be "re-recorded":

$ pytest -v -s --record-mode rewrite --block-network
$ git commit -a -m 'updated test episodes'

Pull Requests

To make Pull Requests to pystac-client, the code must pass linting, formatting, and code tests. To run the entire suit of checks and tests that will be run the GitHub Action Pipeline, use the test script.

$ scripts/test

If automatic formatting is desired (incorrect formatting will cause the GitHub Action to fail), use the format script and commit the resulting files:

$ scripts/format
$ git commit -a -m 'formatting updates'

To build the documentation, install Pandoc, install the Python documentation requirements via pip, then use the build-docs script:

$ pip install -r requirements-docs.txt
$ scripts/build-docs

Benchmark

By default, pystac-client benchmarks are skipped during test runs. To run the benchmarks, use the --benchmark-only flag:

$ pytest --benchmark-only
============================= test session starts ==============================
platform darwin -- Python 3.9.13, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
benchmark: 3.4.1 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: /Users/gadomski/Code/pystac-client, configfile: pytest.ini
plugins: benchmark-3.4.1, recording-0.11.0, console-scripts-1.1.0, requests-mock-1.9.3, cov-2.11.1, typeguard-2.13.3
collected 75 items

tests/test_cli.py ss                                                     [  2%]
tests/test_client.py ssssssssssssssss                                    [ 24%]
tests/test_collection_client.py ss                                       [ 26%]
tests/test_item_search.py ...sssssssssssssssssssssssssssssssssssssssssss [ 88%]
s                                                                        [ 89%]
tests/test_stac_api_io.py ssssssss                                       [100%]


--------------------------------------------------------------------------------------- benchmark: 3 tests --------------------------------------------------------------------------------------
Name (time in ms)                Min                 Max                Mean              StdDev              Median                IQR            Outliers     OPS            Rounds  Iterations
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test_single_item_search     213.4729 (1.0)      284.8732 (1.0)      254.9405 (1.0)       32.9424 (3.27)     271.0926 (1.0)      58.2907 (4.95)          1;0  3.9225 (1.0)           5           1
test_single_item            314.6746 (1.47)     679.7592 (2.39)     563.9692 (2.21)     142.7451 (14.18)    609.5605 (2.25)     93.9942 (7.98)          1;1  1.7731 (0.45)          5           1
test_requests               612.9212 (2.87)     640.5024 (2.25)     625.6871 (2.45)      10.0637 (1.0)      625.1143 (2.31)     11.7822 (1.0)           2;0  1.5982 (0.41)          5           1
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
======================== 3 passed, 72 skipped in 11.86s ========================

For more information on running and comparing benchmarks, see the pytest-benchmark documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pystac-client-0.5.0.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pystac_client-0.5.0-py3-none-any.whl (29.0 kB view details)

Uploaded Python 3

File details

Details for the file pystac-client-0.5.0.tar.gz.

File metadata

  • Download URL: pystac-client-0.5.0.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for pystac-client-0.5.0.tar.gz
Algorithm Hash digest
SHA256 cc45075c9fe6ae4c01db8099bf7ce70da9461d148c0dabe7e7e4a96ff2c82774
MD5 405ee14b6794e79e43b79d1795e5461a
BLAKE2b-256 e7fbd221db2e450815a4ea68022a0a98298cd87fdaabc8b79ba99f3443fef3c7

See more details on using hashes here.

File details

Details for the file pystac_client-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: pystac_client-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 29.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.6

File hashes

Hashes for pystac_client-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c4094222004ea369fd40a3c97bc85088bfea6c386d653678c673c4c2f6904155
MD5 9b098aa5476c9ac761bd5f5505ef5eb2
BLAKE2b-256 8dbd4f7428b5049d3ddc59b9424ff146310f726a6fc28e3169dc1bd4279fa21a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page