Skip to content

Commit ab747be

Browse files
authored
Update migrate code to handle license updates for v1.1.0 (#1491)
* Migrate license from 'various' and 'proprietary' to 'other' * Update license in 1.1.0 test files * Remove item-assets extension from v1.1.0 files
1 parent 24e16e4 commit ab747be

File tree

32 files changed

+53
-53
lines changed

32 files changed

+53
-53
lines changed

Diff for: pystac/serialization/migrate.py

+7-16
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ def _migrate_catalog(
2020
d: dict[str, Any], version: STACVersionID, info: STACJSONDescription
2121
) -> None:
2222
d["type"] = pystac.STACObjectType.CATALOG
23+
_migrate_license(d)
2324

2425

2526
def _migrate_collection_summaries(
@@ -38,25 +39,20 @@ def _migrate_collection(
3839
d: dict[str, Any], version: STACVersionID, info: STACJSONDescription
3940
) -> None:
4041
d["type"] = pystac.STACObjectType.COLLECTION
42+
_migrate_license(d)
4143
_migrate_collection_summaries(d, version, info)
4244

4345

4446
def _migrate_item(
4547
d: dict[str, Any], version: STACVersionID, info: STACJSONDescription
4648
) -> None:
47-
# No migrations necessary for supported STAC versions (>=0.8)
48-
pass
49+
_migrate_license(d["properties"])
4950

5051

51-
# Extensions
52-
def _migrate_item_assets(
53-
d: dict[str, Any], version: STACVersionID, info: STACJSONDescription
54-
) -> set[str] | None:
55-
if version < "1.0.0-beta.2":
56-
if info.object_type == pystac.STACObjectType.COLLECTION:
57-
if "assets" in d:
58-
d["item_assets"] = d["assets"]
59-
del d["assets"]
52+
def _migrate_license(d: dict[str, Any]) -> None:
53+
if d.get("license") in ["various", "proprietary"]:
54+
d["license"] = "other"
55+
6056
return None
6157

6258

@@ -158,11 +154,6 @@ def _get_removed_extension_migrations() -> (
158154
}
159155

160156

161-
# TODO: Item Assets
162-
def _get_extension_renames() -> dict[str, str]:
163-
return {"asset": "item-assets"}
164-
165-
166157
def migrate_to_latest(
167158
json_dict: dict[str, Any], info: STACJSONDescription
168159
) -> dict[str, Any]:

Diff for: tests/data-files/catalogs/cbers-partial/CBERS4AWFI/collection.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
}
1717
],
1818
"stac_extensions": [
19-
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
20-
"https://schemas.stacspec.org/v1.0.0-beta.2/extensions/item-assets/json-schema/schema.json"
19+
"https://stac-extensions.github.io/eo/v1.1.0/schema.json"
2120
],
2221
"providers": [
2322
{

Diff for: tests/data-files/catalogs/cbers-partial/CBERS4MUX/collection.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
}
1717
],
1818
"stac_extensions": [
19-
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
20-
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json"
19+
"https://stac-extensions.github.io/eo/v1.1.0/schema.json"
2120
],
2221
"providers": [
2322
{

Diff for: tests/data-files/catalogs/cbers-partial/CBERS4PAN10M/collection.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
}
1717
],
1818
"stac_extensions": [
19-
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
20-
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json"
19+
"https://stac-extensions.github.io/eo/v1.1.0/schema.json"
2120
],
2221
"providers": [
2322
{

Diff for: tests/data-files/catalogs/cbers-partial/CBERS4PAN5M/collection.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
}
1717
],
1818
"stac_extensions": [
19-
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",
20-
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json"
19+
"https://stac-extensions.github.io/eo/v1.1.0/schema.json"
2120
],
2221
"providers": [
2322
{

Diff for: tests/data-files/catalogs/test-case-1/country-1/area-1-1/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
]
4747
}
4848
},
49-
"license": "proprietary"
49+
"license": "other"
5050
}

Diff for: tests/data-files/catalogs/test-case-1/country-1/area-1-2/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
]
4747
}
4848
},
49-
"license": "proprietary"
49+
"license": "other"
5050
}

Diff for: tests/data-files/catalogs/test-case-1/country-2/area-2-1/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
]
4747
}
4848
},
49-
"license": "proprietary"
49+
"license": "other"
5050
}

Diff for: tests/data-files/catalogs/test-case-1/country-2/area-2-2/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
]
4747
}
4848
},
49-
"license": "proprietary"
49+
"license": "other"
5050
}

Diff for: tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/5b922d42-9a77-4f79-a672-86096f7f849e/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@
4747
]
4848
}
4949
},
50-
"license": "proprietary"
50+
"license": "other"
5151
}

Diff for: tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,5 @@
5353
]
5454
}
5555
},
56-
"license": "proprietary"
56+
"license": "other"
5757
}

Diff for: tests/data-files/catalogs/test-case-2/1a8c1632-fa91-4a62-b33e-3a87c2ebdf16/f433578c-f879-414d-8101-83142a0a13c3/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,5 +47,5 @@
4747
]
4848
}
4949
},
50-
"license": "proprietary"
50+
"license": "other"
5151
}

Diff for: tests/data-files/catalogs/test-case-4/acc/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@
7676
]
7777
}
7878
},
79-
"license": "various"
79+
"license": "other"
8080
}

Diff for: tests/data-files/catalogs/test-case-4/dar/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,5 +96,5 @@
9696
]
9797
}
9898
},
99-
"license": "various"
99+
"license": "other"
100100
}

Diff for: tests/data-files/catalogs/test-case-4/kam/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
]
4747
}
4848
},
49-
"license": "various"
49+
"license": "other"
5050
}

Diff for: tests/data-files/catalogs/test-case-4/mon/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,5 +76,5 @@
7676
]
7777
}
7878
},
79-
"license": "various"
79+
"license": "other"
8080
}

Diff for: tests/data-files/catalogs/test-case-4/nia/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,5 @@
4646
]
4747
}
4848
},
49-
"license": "various"
49+
"license": "other"
5050
}

Diff for: tests/data-files/catalogs/test-case-4/ptn/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@
5656
]
5757
}
5858
},
59-
"license": "various"
59+
"license": "other"
6060
}

Diff for: tests/data-files/classification/collection-item-assets-raster-bands.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
]
111111
}
112112
},
113-
"license": "proprietary",
113+
"license": "other",
114114
"stac_extensions": [
115115
"https://stac-extensions.github.io/projection/v1.1.0/schema.json",
116116
"https://stac-extensions.github.io/eo/v1.1.0/schema.json",

Diff for: tests/data-files/collections/multi-extent.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@
6262
]
6363
}
6464
},
65-
"license": "proprietary"
65+
"license": "other"
6666
}

Diff for: tests/data-files/collections/with-assets.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,5 +56,5 @@
5656
]
5757
}
5858
},
59-
"license": "proprietary"
59+
"license": "other"
6060
}

Diff for: tests/data-files/invalid/shared-id/test/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@
4141
]
4242
}
4343
},
44-
"license": "proprietary"
44+
"license": "other"
4545
}

Diff for: tests/data-files/item-assets/example-landsat8.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"stac_version": "1.1.0",
33
"stac_extensions": [
4-
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json",
54
"eo"
65
],
76
"type": "Collection",

Diff for: tests/data-files/projection/collection-with-summaries.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@
4848
]
4949
}
5050
},
51-
"license": "proprietary"
51+
"license": "other"
5252
}

Diff for: tests/data-files/storage/collection-naip.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,5 @@
6161
]
6262
}
6363
},
64-
"license": "proprietary"
64+
"license": "other"
6565
}

Diff for: tests/data-files/table/collection-2.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
"description": "desc",
66
"links": [],
77
"stac_extensions": [
8-
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json",
98
"https://stac-extensions.github.io/table/v1.2.0/schema.json"
109
],
1110
"extent": {
@@ -28,7 +27,7 @@
2827
]
2928
}
3029
},
31-
"license": "proprietary",
30+
"license": "other",
3231
"item_assets": {},
3332
"table:columns": []
3433
}

Diff for: tests/data-files/table/collection.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"stac_version": "1.1.0",
33
"stac_extensions": [
4-
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json",
54
"https://stac-extensions.github.io/table/v1.2.0/schema.json"
65
],
76
"type": "Collection",

Diff for: tests/data-files/table/table-collection.json

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"stac_version": "1.1.0",
33
"stac_extensions": [
4-
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json",
54
"https://stac-extensions.github.io/table/v1.2.0/schema.json"
65
],
76
"type": "Collection",

Diff for: tests/data-files/view/collection-with-summaries.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,5 +65,5 @@
6565
]
6666
}
6767
},
68-
"license": "proprietary"
68+
"license": "other"
6969
}

Diff for: tests/data-files/windows_hrefs/test-collection/collection.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,5 @@
4040
]
4141
}
4242
},
43-
"license": "proprietary"
43+
"license": "other"
4444
}

Diff for: tests/serialization/test_migrate.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def test_migrates_added_extension(self) -> None:
6767
assert view_ext.sun_elevation, 58.8
6868
assert view_ext.off_nadir, 1
6969

70-
def test_migrates_renamed_extension(self) -> None:
70+
def test_migrates_removes_extension(self) -> None:
7171
collection = pystac.Collection.from_file(
7272
TestCases.get_path(
7373
"data-files/examples/0.9.0/extensions/asset/"
@@ -78,7 +78,8 @@ def test_migrates_renamed_extension(self) -> None:
7878
assert ItemAssetsExtension.get_schema_uri() not in collection.stac_extensions
7979
assert not ItemAssetsExtension.has_extension(collection)
8080
assert "item_assets" in collection.extra_fields
81-
assert collection.item_assets
81+
82+
assert collection.stac_extensions == []
8283
assert collection.item_assets["thumbnail"].title == "Thumbnail"
8384

8485
def test_migrates_pre_1_0_0_rc1_stats_summary(self) -> None:
@@ -112,3 +113,19 @@ def test_migrate_works_even_if_stac_extensions_is_null(
112113
collection_dict["stac_extensions"] = None
113114

114115
pystac.Collection.from_dict(collection_dict, migrate=True)
116+
117+
118+
def test_migrate_updates_license_from_various() -> None:
119+
path = TestCases.get_path("data-files/examples/1.0.0/collectionless-item.json")
120+
121+
item = pystac.Item.from_file(path)
122+
assert item.properties["license"] == "other"
123+
124+
125+
def test_migrate_updates_license_from_proprietary() -> None:
126+
path = TestCases.get_path(
127+
"data-files/examples/1.0.0/collection-only/collection.json"
128+
)
129+
130+
collection = pystac.Collection.from_file(path)
131+
assert collection.license == "other"

Diff for: tests/test_catalog.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ def test_self_contained_catalog_collection_item_links(self) -> None:
11201120
spatial=pystac.SpatialExtent([[-180.0, -90.0, 180.0, 90.0]]),
11211121
temporal=pystac.TemporalExtent([[datetime(2021, 11, 1), None]]),
11221122
),
1123-
license="proprietary",
1123+
license="other",
11241124
)
11251125

11261126
item = pystac.Item(

0 commit comments

Comments
 (0)