udata 10.2.1.dev34693__py2.py3-none-any.whl → 10.2.1.dev34728__py2.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.
Potentially problematic release.
This version of udata might be problematic. Click here for more details.
- udata/core/dataset/rdf.py +2 -0
- udata/harvest/backends/base.py +1 -1
- udata/harvest/backends/dcat.py +48 -6
- udata/harvest/tests/factories.py +1 -1
- udata/harvest/tests/test_base_backend.py +2 -2
- udata/static/chunks/{10.471164b2a9fe15614797.js → 10.8ca60413647062717b1e.js} +3 -3
- udata/static/chunks/{10.471164b2a9fe15614797.js.map → 10.8ca60413647062717b1e.js.map} +1 -1
- udata/static/chunks/{11.51d706fb9521c16976bc.js → 11.b6f741fcc366abfad9c4.js} +3 -3
- udata/static/chunks/{11.51d706fb9521c16976bc.js.map → 11.b6f741fcc366abfad9c4.js.map} +1 -1
- udata/static/chunks/{13.f29411b06be1883356a3.js → 13.2d06442dd9a05d9777b5.js} +2 -2
- udata/static/chunks/{13.f29411b06be1883356a3.js.map → 13.2d06442dd9a05d9777b5.js.map} +1 -1
- udata/static/chunks/{17.3bd0340930d4a314ce9c.js → 17.e8e4caaad5cb0cc0bacc.js} +2 -2
- udata/static/chunks/{17.3bd0340930d4a314ce9c.js.map → 17.e8e4caaad5cb0cc0bacc.js.map} +1 -1
- udata/static/chunks/{19.8da42e8359d72afc2618.js → 19.f03a102365af4315f9db.js} +3 -3
- udata/static/chunks/{19.8da42e8359d72afc2618.js.map → 19.f03a102365af4315f9db.js.map} +1 -1
- udata/static/chunks/{8.54e44b102164ae5e7a67.js → 8.778091d55cd8ea39af6b.js} +2 -2
- udata/static/chunks/{8.54e44b102164ae5e7a67.js.map → 8.778091d55cd8ea39af6b.js.map} +1 -1
- udata/static/chunks/{9.07515e5187f475bce828.js → 9.033d7e190ca9e226a5d0.js} +3 -3
- udata/static/chunks/{9.07515e5187f475bce828.js.map → 9.033d7e190ca9e226a5d0.js.map} +1 -1
- udata/static/common.js +1 -1
- udata/static/common.js.map +1 -1
- {udata-10.2.1.dev34693.dist-info → udata-10.2.1.dev34728.dist-info}/METADATA +2 -1
- {udata-10.2.1.dev34693.dist-info → udata-10.2.1.dev34728.dist-info}/RECORD +27 -27
- {udata-10.2.1.dev34693.dist-info → udata-10.2.1.dev34728.dist-info}/LICENSE +0 -0
- {udata-10.2.1.dev34693.dist-info → udata-10.2.1.dev34728.dist-info}/WHEEL +0 -0
- {udata-10.2.1.dev34693.dist-info → udata-10.2.1.dev34728.dist-info}/entry_points.txt +0 -0
- {udata-10.2.1.dev34693.dist-info → udata-10.2.1.dev34728.dist-info}/top_level.txt +0 -0
udata/core/dataset/rdf.py
CHANGED
|
@@ -755,6 +755,8 @@ def dataset_from_rdf(graph: Graph, dataset=None, node=None, remote_url_prefix: s
|
|
|
755
755
|
|
|
756
756
|
dataset.title = rdf_value(d, DCT.title)
|
|
757
757
|
if not dataset.title:
|
|
758
|
+
# If the dataset is externaly defined (so without title and just with a link to the dataset XML)
|
|
759
|
+
# we should have skipped it way before in :ExcludeExternalyDefinedDataset
|
|
758
760
|
raise HarvestSkipException("missing title on dataset")
|
|
759
761
|
|
|
760
762
|
# Support dct:abstract if dct:description is missing (sometimes used instead)
|
udata/harvest/backends/base.py
CHANGED
|
@@ -256,7 +256,7 @@ class BaseBackend(object):
|
|
|
256
256
|
]
|
|
257
257
|
self.save_job()
|
|
258
258
|
|
|
259
|
-
def
|
|
259
|
+
def has_reached_max_items(self) -> bool:
|
|
260
260
|
"""Should be called after process_dataset to know if we reach the max items"""
|
|
261
261
|
return self.max_items and len(self.job.items) >= self.max_items
|
|
262
262
|
|
udata/harvest/backends/dcat.py
CHANGED
|
@@ -9,7 +9,7 @@ from rdflib.namespace import RDF
|
|
|
9
9
|
|
|
10
10
|
from udata.core.dataservices.rdf import dataservice_from_rdf
|
|
11
11
|
from udata.core.dataset.rdf import dataset_from_rdf
|
|
12
|
-
from udata.harvest.models import HarvestItem
|
|
12
|
+
from udata.harvest.models import HarvestError, HarvestItem
|
|
13
13
|
from udata.i18n import gettext as _
|
|
14
14
|
from udata.rdf import (
|
|
15
15
|
DCAT,
|
|
@@ -18,6 +18,7 @@ from udata.rdf import (
|
|
|
18
18
|
SPDX,
|
|
19
19
|
guess_format,
|
|
20
20
|
namespace_manager,
|
|
21
|
+
rdf_value,
|
|
21
22
|
url_from_rdf,
|
|
22
23
|
)
|
|
23
24
|
from udata.storage.s3 import store_as_json
|
|
@@ -77,9 +78,19 @@ class DcatBackend(BaseBackend):
|
|
|
77
78
|
self.process_one_datasets_page(page_number, page)
|
|
78
79
|
serialized_graphs.append(page.serialize(format=fmt, indent=None))
|
|
79
80
|
|
|
81
|
+
# We do a second pass to have all datasets in memory and attach datasets
|
|
82
|
+
# to dataservices. It could be better to be one pass of graph walking and
|
|
83
|
+
# then one pass of attaching datasets to dataservices.
|
|
80
84
|
for page_number, page in self.walk_graph(self.source.url, fmt):
|
|
81
85
|
self.process_one_dataservices_page(page_number, page)
|
|
82
86
|
|
|
87
|
+
if not self.dryrun and self.has_reached_max_items():
|
|
88
|
+
# We have reached the max_items limit. Warn the user that all the datasets may not be present.
|
|
89
|
+
error = HarvestError(
|
|
90
|
+
message=f"{self.max_items} max items reached, not all datasets/dataservices were retrieved"
|
|
91
|
+
)
|
|
92
|
+
self.job.errors.append(error)
|
|
93
|
+
|
|
83
94
|
# The official MongoDB document size in 16MB. The default value here is 15MB to account for other fields in the document (and for difference between * 1024 vs * 1000).
|
|
84
95
|
max_harvest_graph_size_in_mongo = current_app.config.get(
|
|
85
96
|
"HARVEST_MAX_CATALOG_SIZE_IN_MONGO"
|
|
@@ -146,7 +157,7 @@ class DcatBackend(BaseBackend):
|
|
|
146
157
|
break
|
|
147
158
|
|
|
148
159
|
yield page_number, subgraph
|
|
149
|
-
if self.
|
|
160
|
+
if self.has_reached_max_items():
|
|
150
161
|
return
|
|
151
162
|
|
|
152
163
|
page_number += 1
|
|
@@ -154,17 +165,48 @@ class DcatBackend(BaseBackend):
|
|
|
154
165
|
def process_one_datasets_page(self, page_number: int, page: Graph):
|
|
155
166
|
for node in page.subjects(RDF.type, DCAT.Dataset):
|
|
156
167
|
remote_id = page.value(node, DCT.identifier)
|
|
168
|
+
if self.is_dataset_external_to_this_page(page, node):
|
|
169
|
+
continue
|
|
170
|
+
|
|
157
171
|
self.process_dataset(remote_id, page_number=page_number, page=page, node=node)
|
|
158
172
|
|
|
159
|
-
if self.
|
|
173
|
+
if self.has_reached_max_items():
|
|
160
174
|
return
|
|
161
175
|
|
|
176
|
+
def is_dataset_external_to_this_page(self, page: Graph, node) -> bool:
|
|
177
|
+
# In dataservice nodes we have `servesDataset` or `hasPart` that can contains nodes
|
|
178
|
+
# with type=dataset. We don't want to process them because these nodes are empty (they
|
|
179
|
+
# only contains a link to the dataset definition).
|
|
180
|
+
# These datasets are either present in the catalog in previous or next pages or
|
|
181
|
+
# external from the catalog we are currently harvesting (so we don't want to harvest them).
|
|
182
|
+
# First we thought of skipping them inside `dataset_from_rdf` (see :ExcludeExternalyDefinedDataset)
|
|
183
|
+
# but it creates a lot of "fake" items in the job and raising problems (reaching the max harvest item for
|
|
184
|
+
# example and not getting to the "real" datasets/dataservices in subsequent pages)
|
|
185
|
+
# So to prevent creating a lot of useless items in the job we first thought about checking to see if there is no title and
|
|
186
|
+
# if `isPrimaryTopicOf` is present. But it may be better to check if the only link of the node with the current page is a
|
|
187
|
+
# `servesDataset` or `hasPart`. If it's the case, the node is only present in a dataservice. (maybe we could also check that
|
|
188
|
+
# the `_other_node` is a dataservice?)
|
|
189
|
+
# `isPrimaryTopicOf` is the tag present in the first harvester raising the problem, it may exists other
|
|
190
|
+
# values of the same sort we need to check here.
|
|
191
|
+
|
|
192
|
+
# This is not dangerous because we check for missing title in `dataset_from_rdf` later so we would have skipped
|
|
193
|
+
# this dataset anyway.
|
|
194
|
+
resource = page.resource(node)
|
|
195
|
+
title = rdf_value(resource, DCT.title)
|
|
196
|
+
if title:
|
|
197
|
+
return False
|
|
198
|
+
|
|
199
|
+
predicates = [link_type for (_other_node, link_type) in page.subject_predicates(node)]
|
|
200
|
+
return len(predicates) == 1 and (
|
|
201
|
+
predicates[0] == DCAT.servesDataset or predicates[0] == DCT.hasPart
|
|
202
|
+
)
|
|
203
|
+
|
|
162
204
|
def process_one_dataservices_page(self, page_number: int, page: Graph):
|
|
163
205
|
for node in page.subjects(RDF.type, DCAT.DataService):
|
|
164
206
|
remote_id = page.value(node, DCT.identifier)
|
|
165
207
|
self.process_dataservice(remote_id, page_number=page_number, page=page, node=node)
|
|
166
208
|
|
|
167
|
-
if self.
|
|
209
|
+
if self.has_reached_max_items():
|
|
168
210
|
return
|
|
169
211
|
|
|
170
212
|
def inner_process_dataset(self, item: HarvestItem, page_number: int, page: Graph, node):
|
|
@@ -266,7 +308,7 @@ class CswDcatBackend(DcatBackend):
|
|
|
266
308
|
subgraph.parse(data=ET.tostring(child), format=fmt)
|
|
267
309
|
|
|
268
310
|
yield page_number, subgraph
|
|
269
|
-
if self.
|
|
311
|
+
if self.has_reached_max_items():
|
|
270
312
|
return
|
|
271
313
|
|
|
272
314
|
next_record = self.next_record_if_should_continue(start, search_results)
|
|
@@ -375,7 +417,7 @@ class CswIso19139DcatBackend(DcatBackend):
|
|
|
375
417
|
raise ValueError("Failed to fetch CSW content")
|
|
376
418
|
|
|
377
419
|
yield page_number, subgraph
|
|
378
|
-
if self.
|
|
420
|
+
if self.has_reached_max_items():
|
|
379
421
|
return
|
|
380
422
|
|
|
381
423
|
next_record = self.next_record_if_should_continue(start, search_results)
|
udata/harvest/tests/factories.py
CHANGED
|
@@ -61,7 +61,7 @@ class FactoryBackend(backends.BaseBackend):
|
|
|
61
61
|
mock_initialize.send(self)
|
|
62
62
|
for i in range(self.config.get("count", DEFAULT_COUNT)):
|
|
63
63
|
self.process_dataset(str(i))
|
|
64
|
-
if self.
|
|
64
|
+
if self.has_reached_max_items():
|
|
65
65
|
return
|
|
66
66
|
|
|
67
67
|
def inner_process_dataset(self, item: HarvestItem):
|
|
@@ -44,12 +44,12 @@ class FakeBackend(BaseBackend):
|
|
|
44
44
|
def inner_harvest(self):
|
|
45
45
|
for remote_id in self.source.config.get("dataset_remote_ids", []):
|
|
46
46
|
self.process_dataset(remote_id)
|
|
47
|
-
if self.
|
|
47
|
+
if self.has_reached_max_items():
|
|
48
48
|
return
|
|
49
49
|
|
|
50
50
|
for remote_id in self.source.config.get("dataservice_remote_ids", []):
|
|
51
51
|
self.process_dataservice(remote_id)
|
|
52
|
-
if self.
|
|
52
|
+
if self.has_reached_max_items():
|
|
53
53
|
return
|
|
54
54
|
|
|
55
55
|
def inner_process_dataset(self, item: HarvestItem):
|