planetary-computer


Nameplanetary-computer JSON
Version 1.0.0 PyPI version JSON
download
home_page
SummaryPlanetary Computer SDK for Python
upload_time2023-07-05 13:06:58
maintainer
docs_urlNone
author
requires_python>=3.7
licenseMIT License Copyright (c) Microsoft Corporation. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Planetary Computer SDK for Python

Python library for interacting with the Microsoft Planetary Computer.

For general questions or discussions about the Planetary Computer, use the [microsoft/PlanetaryComputer](http://github.com/microsoft/PlanetaryComputer) repository.

## Installation

```python
pip install planetary-computer
```

If you have an API subscription key, you may provide it to the library by using the included configuration CLI:

```bash
planetarycomputer configure
```

Alternatively, a subscription key may be provided by specifying it in the `PC_SDK_SUBSCRIPTION_KEY` environment variable. A subcription key is not required for interacting with the service, however having one in place allows for less restricted rate limiting.


## Usage

This library assists with signing Azure Blob Storage URLs. The `sign` function operates directly on an HREF string, as well as several [PySTAC](https://github.com/stac-utils/pystac) objects: `Asset`, `Item`, and `ItemCollection`. In addition, the `sign` function accepts a [STAC API Client](https://pystac-client.readthedocs.io/en/stable/) `ItemSearch`, which performs a search and returns the resulting `ItemCollection` with all assets signed.

### Automatic signing

If you're using pystac-client we recommend you use its feature to [automatically sign results](https://pystac-client.readthedocs.io/en/stable/usage.html#automatically-modifying-results) with ``planetary_computer.sign_inplace``:

```python
import planetary_computer
import pystac_client

from pystac_client import Client
import planetary_computer, requests
api = Client.open(
   'https://planetarycomputer.microsoft.com/api/stac/v1',
   modifier=planetary_computer.sign_inplace,
)
```

Now all the results you get from that client will be signed.

### Manual signing

Alternatively, you can manually call ``planetary_computer.sign`` on your results.

```python
from pystac import Asset, Item, ItemCollection
from pystac_client import ItemSearch
import planetary_computer as pc


# The sign function may be called directly on the Item
raw_item: Item = ...
item: Item = pc.sign(raw_item)
# Now use the item however you want. All appropriate assets are signed for read access.

# The sign function also works with an Asset
raw_asset: Asset = raw_item.assets['SR_B4']
asset = pc.sign(raw_asset)

# The sign function also works with an HREF
raw_href: str = raw_asset.href
href = pc.sign(raw_href)

# The sign function also works with an ItemCollection
raw_item_collection = ItemCollection([raw_item])
item_collection = pc.sign(raw_item_collection)

# The sign function also accepts an ItemSearch, and signs the resulting ItemCollection
search = ItemSearch(
    url=...,
    bbox=...,
    collections=...,
    limit=...,
    max_items=...,
)
signed_item_collection = pc.sign(search)
```

### Convenience methods

You'll occasionally need to interact with the Blob Storage container directly, rather than
using STAC items. We include two convenience methods for this:

* `planetary_computer.get_container_client`: Get an [`azure.storage.blob.ContainerClient`](https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.containerclient?view=azure-python)
* `planetary_computer.get_adlfs_filesystem`: Get an [`adlfs.AzureBlobFilesystem`](https://github.com/fsspec/adlfs)

## Development

The following steps may be followed in order to develop locally:

```bash
## Create and activate venv
python3 -m venv env
source env/bin/activate

## Install requirements
python3 -m pip install -r requirements-dev.txt

## Install locally
pip install -e .

## Format code
./scripts/format

## Run tests
./scripts/test
```

## Contributing

This project welcomes contributions and suggestions.  Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.

## Trademarks

This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
trademarks or logos is subject to and must follow
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies.

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "planetary-computer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "",
    "author": "",
    "author_email": "microsoft <planetarycomputer@microsoft.com>",
    "download_url": "https://files.pythonhosted.org/packages/9b/d3/ccfb0e823e9beb72b7e6b749f0985c4db1530d4e4a145b1b5d12f5de417e/planetary-computer-1.0.0.tar.gz",
    "platform": null,
    "description": "# Planetary Computer SDK for Python\n\nPython library for interacting with the Microsoft Planetary Computer.\n\nFor general questions or discussions about the Planetary Computer, use the [microsoft/PlanetaryComputer](http://github.com/microsoft/PlanetaryComputer) repository.\n\n## Installation\n\n```python\npip install planetary-computer\n```\n\nIf you have an API subscription key, you may provide it to the library by using the included configuration CLI:\n\n```bash\nplanetarycomputer configure\n```\n\nAlternatively, a subscription key may be provided by specifying it in the `PC_SDK_SUBSCRIPTION_KEY` environment variable. A subcription key is not required for interacting with the service, however having one in place allows for less restricted rate limiting.\n\n\n## Usage\n\nThis library assists with signing Azure Blob Storage URLs. The `sign` function operates directly on an HREF string, as well as several [PySTAC](https://github.com/stac-utils/pystac) objects: `Asset`, `Item`, and `ItemCollection`. In addition, the `sign` function accepts a [STAC API Client](https://pystac-client.readthedocs.io/en/stable/) `ItemSearch`, which performs a search and returns the resulting `ItemCollection` with all assets signed.\n\n### Automatic signing\n\nIf you're using pystac-client we recommend you use its feature to [automatically sign results](https://pystac-client.readthedocs.io/en/stable/usage.html#automatically-modifying-results) with ``planetary_computer.sign_inplace``:\n\n```python\nimport planetary_computer\nimport pystac_client\n\nfrom pystac_client import Client\nimport planetary_computer, requests\napi = Client.open(\n   'https://planetarycomputer.microsoft.com/api/stac/v1',\n   modifier=planetary_computer.sign_inplace,\n)\n```\n\nNow all the results you get from that client will be signed.\n\n### Manual signing\n\nAlternatively, you can manually call ``planetary_computer.sign`` on your results.\n\n```python\nfrom pystac import Asset, Item, ItemCollection\nfrom pystac_client import ItemSearch\nimport planetary_computer as pc\n\n\n# The sign function may be called directly on the Item\nraw_item: Item = ...\nitem: Item = pc.sign(raw_item)\n# Now use the item however you want. All appropriate assets are signed for read access.\n\n# The sign function also works with an Asset\nraw_asset: Asset = raw_item.assets['SR_B4']\nasset = pc.sign(raw_asset)\n\n# The sign function also works with an HREF\nraw_href: str = raw_asset.href\nhref = pc.sign(raw_href)\n\n# The sign function also works with an ItemCollection\nraw_item_collection = ItemCollection([raw_item])\nitem_collection = pc.sign(raw_item_collection)\n\n# The sign function also accepts an ItemSearch, and signs the resulting ItemCollection\nsearch = ItemSearch(\n    url=...,\n    bbox=...,\n    collections=...,\n    limit=...,\n    max_items=...,\n)\nsigned_item_collection = pc.sign(search)\n```\n\n### Convenience methods\n\nYou'll occasionally need to interact with the Blob Storage container directly, rather than\nusing STAC items. We include two convenience methods for this:\n\n* `planetary_computer.get_container_client`: Get an [`azure.storage.blob.ContainerClient`](https://learn.microsoft.com/en-us/python/api/azure-storage-blob/azure.storage.blob.containerclient?view=azure-python)\n* `planetary_computer.get_adlfs_filesystem`: Get an [`adlfs.AzureBlobFilesystem`](https://github.com/fsspec/adlfs)\n\n## Development\n\nThe following steps may be followed in order to develop locally:\n\n```bash\n## Create and activate venv\npython3 -m venv env\nsource env/bin/activate\n\n## Install requirements\npython3 -m pip install -r requirements-dev.txt\n\n## Install locally\npip install -e .\n\n## Format code\n./scripts/format\n\n## Run tests\n./scripts/test\n```\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.\n\nWhen you submit a pull request, a CLA bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n\n## Trademarks\n\nThis project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft\ntrademarks or logos is subject to and must follow\n[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).\nUse of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.\nAny use of third-party trademarks or logos are subject to those third-party's policies.\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) Microsoft Corporation.  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE ",
    "summary": "Planetary Computer SDK for Python",
    "version": "1.0.0",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4f7a3965a2b58d172e106c1064af19707d29f86a0142c28ff40185490a0a8cfe",
                "md5": "59e83e7a29c30b619d8ce0394062abff",
                "sha256": "7af5839f9346c1d23d53fff4e80e955db18a2d81992877816e22dcbc2f90c40d"
            },
            "downloads": -1,
            "filename": "planetary_computer-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "59e83e7a29c30b619d8ce0394062abff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 14163,
            "upload_time": "2023-07-05T13:06:57",
            "upload_time_iso_8601": "2023-07-05T13:06:57.060518Z",
            "url": "https://files.pythonhosted.org/packages/4f/7a/3965a2b58d172e106c1064af19707d29f86a0142c28ff40185490a0a8cfe/planetary_computer-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9bd3ccfb0e823e9beb72b7e6b749f0985c4db1530d4e4a145b1b5d12f5de417e",
                "md5": "d51b57ce8592625e901a634dd97becf0",
                "sha256": "5958a8e1d8ba1aafc7ac45878df2d7d03405806ae31ed2e675333faebca960cc"
            },
            "downloads": -1,
            "filename": "planetary-computer-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d51b57ce8592625e901a634dd97becf0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 17076,
            "upload_time": "2023-07-05T13:06:58",
            "upload_time_iso_8601": "2023-07-05T13:06:58.679159Z",
            "url": "https://files.pythonhosted.org/packages/9b/d3/ccfb0e823e9beb72b7e6b749f0985c4db1530d4e4a145b1b5d12f5de417e/planetary-computer-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-07-05 13:06:58",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "planetary-computer"
}
        
Elapsed time: 0.27315s