hdx-python-api 6.6.6__py3-none-any.whl → 6.6.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- hdx/api/_version.py +2 -2
- hdx/data/organization.py +50 -1
- hdx/data/resource.py +50 -0
- {hdx_python_api-6.6.6.dist-info → hdx_python_api-6.6.8.dist-info}/METADATA +2 -2
- {hdx_python_api-6.6.6.dist-info → hdx_python_api-6.6.8.dist-info}/RECORD +7 -7
- {hdx_python_api-6.6.6.dist-info → hdx_python_api-6.6.8.dist-info}/WHEEL +0 -0
- {hdx_python_api-6.6.6.dist-info → hdx_python_api-6.6.8.dist-info}/licenses/LICENSE +0 -0
hdx/api/_version.py
CHANGED
|
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
|
|
|
18
18
|
commit_id: str | None
|
|
19
19
|
__commit_id__: str | None
|
|
20
20
|
|
|
21
|
-
__version__ = version = '6.6.
|
|
22
|
-
__version_tuple__ = version_tuple = (6, 6,
|
|
21
|
+
__version__ = version = '6.6.8'
|
|
22
|
+
__version_tuple__ = version_tuple = (6, 6, 8)
|
|
23
23
|
|
|
24
24
|
__commit_id__ = commit_id = None
|
hdx/data/organization.py
CHANGED
|
@@ -260,7 +260,56 @@ class Organization(HDXObject):
|
|
|
260
260
|
List of all organization names in HDX
|
|
261
261
|
"""
|
|
262
262
|
organization = Organization(configuration=configuration)
|
|
263
|
-
|
|
263
|
+
|
|
264
|
+
# Early return for the standard, non-paginated case
|
|
265
|
+
if not kwargs.get("all_fields"):
|
|
266
|
+
return organization._write_to_hdx("list", kwargs)
|
|
267
|
+
|
|
268
|
+
compiled_orgs = {}
|
|
269
|
+
# Extract limit and offset to dictate our paging sizes, defaulting to 400 and 0
|
|
270
|
+
page_size = kwargs.pop("limit", 400)
|
|
271
|
+
current_offset = kwargs.pop("offset", 0)
|
|
272
|
+
|
|
273
|
+
# 1. Fetch in pages using the provided/default page size
|
|
274
|
+
while True:
|
|
275
|
+
page_kwargs = kwargs.copy()
|
|
276
|
+
page_kwargs["limit"] = page_size
|
|
277
|
+
page_kwargs["offset"] = current_offset
|
|
278
|
+
|
|
279
|
+
page_data = organization._write_to_hdx("list", page_kwargs)
|
|
280
|
+
|
|
281
|
+
if not page_data:
|
|
282
|
+
break
|
|
283
|
+
|
|
284
|
+
# Store by name to automatically deduplicate offset shifts
|
|
285
|
+
for org in page_data:
|
|
286
|
+
compiled_orgs[org["name"]] = org
|
|
287
|
+
|
|
288
|
+
if len(page_data) < page_size:
|
|
289
|
+
break
|
|
290
|
+
|
|
291
|
+
current_offset += page_size
|
|
292
|
+
|
|
293
|
+
# 2. Establish Ground Truth LAST (without limit/offset constraints)
|
|
294
|
+
truth_kwargs = kwargs.copy()
|
|
295
|
+
truth_kwargs["all_fields"] = False
|
|
296
|
+
|
|
297
|
+
ground_truth_names = organization._write_to_hdx("list", truth_kwargs)
|
|
298
|
+
|
|
299
|
+
# 3 & 4. Check for missing IDs, fetch individually, and implicitly prune deletes
|
|
300
|
+
final_orgs = []
|
|
301
|
+
for name in ground_truth_names:
|
|
302
|
+
if name in compiled_orgs:
|
|
303
|
+
final_orgs.append(compiled_orgs[name])
|
|
304
|
+
else:
|
|
305
|
+
try:
|
|
306
|
+
missing_org = organization._write_to_hdx("show", {"id": name})
|
|
307
|
+
if missing_org:
|
|
308
|
+
final_orgs.append(missing_org)
|
|
309
|
+
except Exception:
|
|
310
|
+
pass
|
|
311
|
+
|
|
312
|
+
return final_orgs
|
|
264
313
|
|
|
265
314
|
@classmethod
|
|
266
315
|
def autocomplete(
|
hdx/data/resource.py
CHANGED
|
@@ -62,6 +62,9 @@ class Resource(HDXObject):
|
|
|
62
62
|
"search": "resource_search",
|
|
63
63
|
"broken": "hdx_mark_broken_link_in_resource",
|
|
64
64
|
"datastore_delete": "datastore_delete",
|
|
65
|
+
"datastore_create": "datastore_create",
|
|
66
|
+
"datastore_insert": "datastore_insert",
|
|
67
|
+
"datastore_upsert": "datastore_upsert",
|
|
65
68
|
"datastore_search": "datastore_search",
|
|
66
69
|
}
|
|
67
70
|
|
|
@@ -701,6 +704,53 @@ class Resource(HDXObject):
|
|
|
701
704
|
return True
|
|
702
705
|
return False
|
|
703
706
|
|
|
707
|
+
def create_datastore(
|
|
708
|
+
self,
|
|
709
|
+
schema: Sequence[dict],
|
|
710
|
+
primary_key: str | Sequence[str] | None = None,
|
|
711
|
+
) -> None:
|
|
712
|
+
"""Create a datastore for the resource with the given schema.
|
|
713
|
+
|
|
714
|
+
Args:
|
|
715
|
+
schema: Sequence of field definitions, each a dict with 'id' and 'type' keys.
|
|
716
|
+
primary_key: Primary key field name(s). Defaults to None.
|
|
717
|
+
|
|
718
|
+
Returns:
|
|
719
|
+
None
|
|
720
|
+
"""
|
|
721
|
+
data: dict = {
|
|
722
|
+
"resource_id": self.data["id"],
|
|
723
|
+
"force": True,
|
|
724
|
+
"fields": schema,
|
|
725
|
+
}
|
|
726
|
+
if primary_key is not None:
|
|
727
|
+
if not isinstance(primary_key, str):
|
|
728
|
+
primary_key = ",".join(primary_key)
|
|
729
|
+
data["primary_key"] = primary_key
|
|
730
|
+
self._write_to_hdx("datastore_create", data, "resource_id")
|
|
731
|
+
|
|
732
|
+
def update_datastore(
|
|
733
|
+
self,
|
|
734
|
+
records: Sequence[dict],
|
|
735
|
+
method: str = "upsert",
|
|
736
|
+
) -> None:
|
|
737
|
+
"""Update (upsert) records into the resource datastore.
|
|
738
|
+
|
|
739
|
+
Args:
|
|
740
|
+
records: Sequence of record dicts to insert or update.
|
|
741
|
+
method: Datastore update method ('upsert', 'insert', or 'update'). Defaults to 'upsert'.
|
|
742
|
+
|
|
743
|
+
Returns:
|
|
744
|
+
None
|
|
745
|
+
"""
|
|
746
|
+
data = {
|
|
747
|
+
"resource_id": self.data["id"],
|
|
748
|
+
"force": True,
|
|
749
|
+
"method": method,
|
|
750
|
+
"records": records,
|
|
751
|
+
}
|
|
752
|
+
self._write_to_hdx("datastore_upsert", data, "resource_id")
|
|
753
|
+
|
|
704
754
|
def delete_datastore(self) -> None:
|
|
705
755
|
"""Delete a resource from the HDX datastore
|
|
706
756
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: hdx-python-api
|
|
3
|
-
Version: 6.6.
|
|
3
|
+
Version: 6.6.8
|
|
4
4
|
Summary: HDX Python API for interacting with the Humanitarian Data Exchange
|
|
5
5
|
Project-URL: Homepage, https://github.com/OCHA-DAP/hdx-python-api
|
|
6
6
|
Author: Michael Rans
|
|
@@ -25,7 +25,7 @@ Classifier: Programming Language :: Python :: 3.13
|
|
|
25
25
|
Classifier: Programming Language :: Python :: 3.14
|
|
26
26
|
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
27
27
|
Requires-Python: >=3.10
|
|
28
|
-
Requires-Dist: ckanapi>=4.
|
|
28
|
+
Requires-Dist: ckanapi>=4.11
|
|
29
29
|
Requires-Dist: defopt>=7.0.0
|
|
30
30
|
Requires-Dist: email-validator
|
|
31
31
|
Requires-Dist: hdx-python-country>=4.1.1
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
hdx/api/__init__.py,sha256=11ozJKiUsqDCZ3_mcAHhGYUyGK_Unl54djVSBBExFB4,59
|
|
2
|
-
hdx/api/_version.py,sha256=
|
|
2
|
+
hdx/api/_version.py,sha256=DuBvygFq7Ca-heE19aRqV-dGslR55qXsxEXRXjW5FNM,520
|
|
3
3
|
hdx/api/configuration.py,sha256=9WvuVI-3th2Dv70_t_4VoyrlJwB_9qUSN5_zUKbp4sQ,23805
|
|
4
4
|
hdx/api/hdx_base_configuration.yaml,sha256=9yJYroZwoyMQo6tcxGfWHWvYahnTma7Szx0J5Z378z4,2173
|
|
5
5
|
hdx/api/locations.py,sha256=blnqOjEASvh0mWgmo2iEE7ES_xOuRwQo3fOMqTPV_P0,4139
|
|
@@ -13,8 +13,8 @@ hdx/api/utilities/url_utils.py,sha256=Pb4r-BAqIHYmeoB_i7QjutDp6nOAUh_OHvCtiNLda3
|
|
|
13
13
|
hdx/data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
hdx/data/dataset.py,sha256=0gS7tQSswTgG0g8YeXg0FL8pFVkocBQSRPFpQAurN00,99455
|
|
15
15
|
hdx/data/hdxobject.py,sha256=_jlwYjb_CcjaXsTXObknMfq-OiNOcpJfLJ9b1vKV1Zo,27494
|
|
16
|
-
hdx/data/organization.py,sha256=
|
|
17
|
-
hdx/data/resource.py,sha256=
|
|
16
|
+
hdx/data/organization.py,sha256=HGopFsCYOWrR7sUtZzZSXq6wLFw4djus2gzg6yNXOqc,12296
|
|
17
|
+
hdx/data/resource.py,sha256=YcxGzKuFduLZIOnCvo-zcwJfnTGOmnvtDeFr2xKeOM4,35647
|
|
18
18
|
hdx/data/resource_matcher.py,sha256=Yzk9pWa4zk1p09m6zcZMj0XZf5Y16Pa3KToOdUt7rP8,4247
|
|
19
19
|
hdx/data/resource_view.py,sha256=GcYkh0iDAe6_m2ErY_A6i3Z7ZFX949eGt1TLnLZv_8s,7346
|
|
20
20
|
hdx/data/showcase.py,sha256=vnRZ45xd9Ct65eFQkWZtMIJPFifZfKOrH4obO5D5Pvc,14062
|
|
@@ -24,7 +24,7 @@ hdx/facades/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
|
24
24
|
hdx/facades/infer_arguments.py,sha256=DvyDuozfOPmoaV7HjhQySojGIrMWW9nos31auQBVVl8,4032
|
|
25
25
|
hdx/facades/keyword_arguments.py,sha256=aVapHCfqBO6H7xxBgTdK9ISdgrBFsNypPDWihfQ3edU,1125
|
|
26
26
|
hdx/facades/simple.py,sha256=QWsBkaHG_UM6X3Zu2u3LWVOQzeR24q-EUClrfsL_mkM,1064
|
|
27
|
-
hdx_python_api-6.6.
|
|
28
|
-
hdx_python_api-6.6.
|
|
29
|
-
hdx_python_api-6.6.
|
|
30
|
-
hdx_python_api-6.6.
|
|
27
|
+
hdx_python_api-6.6.8.dist-info/METADATA,sha256=tRdOttf0O-eRc7iASB0HkCahGiC4dzf5SIVCCv8VHxw,4946
|
|
28
|
+
hdx_python_api-6.6.8.dist-info/WHEEL,sha256=QccIxa26bgl1E6uMy58deGWi-0aeIkkangHcxk2kWfw,87
|
|
29
|
+
hdx_python_api-6.6.8.dist-info/licenses/LICENSE,sha256=wc-4GpMn-ODs-U_bTe1YCiPVgvcjzrpYOx2wPuyAeII,1079
|
|
30
|
+
hdx_python_api-6.6.8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|