Skip to content

Commit 125f489

Browse files
committed
Merge remote-tracking branch 'upstream/main' into feat/render-extension
2 parents 4c9f818 + 1cf7f3f commit 125f489

File tree

370 files changed

+11378
-10030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

370 files changed

+11378
-10030
lines changed

.github/workflows/continuous-integration.yml

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,12 @@ jobs:
3232
- ubuntu-latest
3333
- windows-latest
3434
- macos-latest
35-
exclude:
36-
# https://github.com/stac-utils/pystac/issues/1470
37-
- os: windows-latest
38-
python-version: "3.13"
3935
steps:
4036
- uses: actions/checkout@v4
4137
- uses: actions/setup-python@v5
4238
with:
4339
python-version: ${{ matrix.python-version }}
44-
- uses: astral-sh/setup-uv@v4
40+
- uses: astral-sh/setup-uv@v5
4541
with:
4642
enable-cache: true
4743
- name: Sync
@@ -64,7 +60,7 @@ jobs:
6460
- uses: actions/setup-python@v5
6561
with:
6662
python-version: "3.10"
67-
- uses: astral-sh/setup-uv@v4
63+
- uses: astral-sh/setup-uv@v5
6864
with:
6965
enable-cache: true
7066
- name: Install with dependencies
@@ -105,7 +101,7 @@ jobs:
105101
- uses: actions/setup-python@v5
106102
with:
107103
python-version: ${{ matrix.python-version }}
108-
- uses: astral-sh/setup-uv@v4
104+
- uses: astral-sh/setup-uv@v5
109105
with:
110106
enable-cache: true
111107
- name: Sync
@@ -120,7 +116,7 @@ jobs:
120116
- uses: actions/setup-python@v5
121117
with:
122118
python-version: "3.10"
123-
- uses: astral-sh/setup-uv@v4
119+
- uses: astral-sh/setup-uv@v5
124120
with:
125121
enable-cache: true
126122
- name: Sync
@@ -140,7 +136,7 @@ jobs:
140136
- uses: actions/setup-python@v5
141137
with:
142138
python-version: "3.10"
143-
- uses: astral-sh/setup-uv@v4
139+
- uses: astral-sh/setup-uv@v5
144140
with:
145141
enable-cache: true
146142
- name: Sync
@@ -157,7 +153,7 @@ jobs:
157153
- uses: actions/setup-python@v5
158154
with:
159155
python-version: "3.10"
160-
- uses: astral-sh/setup-uv@v4
156+
- uses: astral-sh/setup-uv@v5
161157
with:
162158
enable-cache: true
163159
- name: Install pandoc

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ stdout*
88
/integration*
99
.idea
1010
.vscode
11+
.actrc
1112

1213

1314
# Sphinx documentation

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,20 @@
22

33
## [Unreleased]
44

5+
### Added
6+
7+
- Top-level `item_assets` dict on `Collection`s ([#1476](https://github.com/stac-utils/pystac/pull/1476))
8+
59
### Changed
610

711
- Write STAC v1.1.0 ([#1427](https://github.com/stac-utils/pystac/pull/1427))
812
- Use [uv](https://github.com/astral-sh/uv) for development dependencies and docs ([#1439](https://github.com/stac-utils/pystac/pull/1439))
13+
- Correctly detect absolute file path ref on windows, reflecting change in python 3.13 ([#1475](https://github.com/stac-utils/pystac/pull/14750)) (only effects python 3.13)
14+
- Deprecated `ItemAssetExtension` ([#1476](https://github.com/stac-utils/pystac/pull/1476))
15+
16+
### Fixed
17+
18+
- Use `application/geo+json` for `item` links ([#1495](https://github.com/stac-utils/pystac/pull/1495))
919

1020
## [v1.11.0] - 2024-09-26
1121

docs/api/item_assets.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pystac.item_assets
2+
==================
3+
4+
.. automodule:: pystac.item_assets
5+
:members:
6+
:undoc-members:
7+
:noindex:

docs/api/pystac.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ pystac
1515
Summaries
1616
Item
1717
Asset
18+
ItemAssetDefinition
1819
CommonMetadata
1920
ItemCollection
2021
Link
@@ -116,6 +117,14 @@ Asset
116117
:members:
117118
:undoc-members:
118119

120+
ItemAssetDefinition
121+
-------------------
122+
123+
.. autoclass:: pystac.ItemAssetDefinition
124+
:members:
125+
:undoc-members:
126+
127+
119128
CommonMetadata
120129
--------------
121130

docs/tutorials/creating-a-landsat-stac.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1119,7 +1119,7 @@
11191119
"cell_type": "markdown",
11201120
"metadata": {},
11211121
"source": [
1122-
"Several QA bands are provided that utilize bit-wise masks which we can define using the [`classification` extension](https://github.com/stac-extensions/classification). Because these definitions can be verbose, we provide some additional helper functions to minimize the length of their definition."
1122+
"Several QA bands are provided that utilize bit-wise masks which we can define using the [classification extension](https://github.com/stac-extensions/classification). Because these definitions can be verbose, we provide some additional helper functions to minimize the length of their definition."
11231123
]
11241124
},
11251125
{

pystac/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"RangeSummary",
3434
"Item",
3535
"Asset",
36+
"ItemAssetDefinition",
3637
"ItemCollection",
3738
"Provider",
3839
"ProviderRole",
@@ -81,6 +82,7 @@
8182
from pystac.summaries import RangeSummary, Summaries
8283
from pystac.asset import Asset
8384
from pystac.item import Item
85+
from pystac.item_assets import ItemAssetDefinition
8486
from pystac.item_collection import ItemCollection
8587
from pystac.provider import ProviderRole, Provider
8688
from pystac.utils import HREF

pystac/asset.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ def ext(self) -> AssetExt:
267267
268268
Example::
269269
270-
asset.ext.proj.epsg = 4326
270+
asset.ext.proj.code = "EPSG:4326"
271271
"""
272272
from pystac.extensions.ext import AssetExt
273273

pystac/collection.py

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from pystac.asset import Asset, Assets
2121
from pystac.catalog import Catalog
2222
from pystac.errors import DeprecatedWarning, ExtensionNotImplemented, STACTypeError
23+
from pystac.item_assets import ItemAssetDefinition, _ItemAssets
2324
from pystac.layout import HrefLayoutStrategy
2425
from pystac.link import Link
2526
from pystac.provider import Provider
@@ -553,6 +554,7 @@ def __init__(
553554
self.keywords = keywords
554555
self.providers = providers
555556
self.summaries = summaries or Summaries.empty()
557+
self._item_assets: _ItemAssets | None = None
556558

557559
self.assets = {}
558560
if assets is not None:
@@ -731,6 +733,62 @@ def get_item(self, id: str, recursive: bool = False) -> Item | None:
731733
return super().get_item(id, recursive=recursive)
732734
raise e
733735

736+
@property
737+
def item_assets(self) -> dict[str, ItemAssetDefinition]:
738+
"""Accessor for `item_assets
739+
<https://github.com/radiantearth/stac-spec/blob/v1.1.0/collection-spec/collection-spec.md#item_assets>`__
740+
on this collection.
741+
742+
Example::
743+
744+
.. code-block:: python
745+
746+
>>> print(collection.item_assets)
747+
{'thumbnail': <pystac.item_assets.ItemAssetDefinition at 0x72aea0420750>,
748+
'metadata': <pystac.item_assets.ItemAssetDefinition at 0x72aea017dc90>,
749+
'B5': <pystac.item_assets.ItemAssetDefinition at 0x72aea017efd0>,
750+
'B6': <pystac.item_assets.ItemAssetDefinition at 0x72aea016d5d0>,
751+
'B7': <pystac.item_assets.ItemAssetDefinition at 0x72aea016e050>,
752+
'B8': <pystac.item_assets.ItemAssetDefinition at 0x72aea016da90>}
753+
>>> collection.item_assets["thumbnail"].title
754+
'Thumbnail'
755+
756+
Set attributes on :class:`~pystac.ItemAssetDefinition` objects
757+
758+
.. code-block:: python
759+
760+
>>> collection.item_assets["thumbnail"].title = "New Title"
761+
762+
Add to the ``item_assets`` dict:
763+
764+
.. code-block:: python
765+
766+
>>> collection.item_assets["B4"] = {
767+
'type': 'image/tiff; application=geotiff; profile=cloud-optimized',
768+
'eo:bands': [{'name': 'B4', 'common_name': 'red'}]
769+
}
770+
>>> collection.item_assets["B4"].owner == collection
771+
True
772+
"""
773+
if self._item_assets is None:
774+
self._item_assets = _ItemAssets(self)
775+
return self._item_assets
776+
777+
@item_assets.setter
778+
def item_assets(
779+
self, item_assets: dict[str, ItemAssetDefinition | dict[str, Any]] | None
780+
) -> None:
781+
# clear out the cached value
782+
self._item_assets = None
783+
784+
if item_assets is None:
785+
self.extra_fields.pop("item_assets")
786+
else:
787+
self.extra_fields["item_assets"] = {
788+
k: v if isinstance(v, dict) else v.to_dict()
789+
for k, v in item_assets.items()
790+
}
791+
734792
def update_extent_from_items(self) -> None:
735793
"""
736794
Update datetime and bbox based on all items to a single bbox and time window.

pystac/extensions/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
from abc import ABC, abstractmethod
66
from collections.abc import Iterable
77
from typing import (
8-
TYPE_CHECKING,
98
Any,
109
Generic,
1110
TypeVar,
@@ -14,9 +13,6 @@
1413

1514
import pystac
1615

17-
if TYPE_CHECKING:
18-
from pystac.extensions.item_assets import AssetDefinition
19-
2016
VERSION_REGEX = re.compile("/v[0-9].[0-9].*/")
2117

2218

@@ -158,7 +154,7 @@ def has_extension(cls, obj: S) -> bool:
158154
@classmethod
159155
def validate_owner_has_extension(
160156
cls,
161-
asset: pystac.Asset | AssetDefinition,
157+
asset: pystac.Asset | pystac.ItemAssetDefinition,
162158
add_if_missing: bool = False,
163159
) -> None:
164160
"""
@@ -190,7 +186,7 @@ def validate_owner_has_extension(
190186
@classmethod
191187
def ensure_owner_has_extension(
192188
cls,
193-
asset_or_link: pystac.Asset | AssetDefinition | pystac.Link,
189+
asset_or_link: pystac.Asset | pystac.ItemAssetDefinition | pystac.Link,
194190
add_if_missing: bool = False,
195191
) -> None:
196192
"""Given an :class:`~pystac.Asset`, checks if the asset's owner has this

0 commit comments

Comments
 (0)