oarepo-runtime 1.5.71__py3-none-any.whl → 1.5.73__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.
- oarepo_runtime/cli/index.py +28 -9
- oarepo_runtime/services/components.py +27 -0
- {oarepo_runtime-1.5.71.dist-info → oarepo_runtime-1.5.73.dist-info}/METADATA +1 -1
- {oarepo_runtime-1.5.71.dist-info → oarepo_runtime-1.5.73.dist-info}/RECORD +8 -8
- {oarepo_runtime-1.5.71.dist-info → oarepo_runtime-1.5.73.dist-info}/LICENSE +0 -0
- {oarepo_runtime-1.5.71.dist-info → oarepo_runtime-1.5.73.dist-info}/WHEEL +0 -0
- {oarepo_runtime-1.5.71.dist-info → oarepo_runtime-1.5.73.dist-info}/entry_points.txt +0 -0
- {oarepo_runtime-1.5.71.dist-info → oarepo_runtime-1.5.73.dist-info}/top_level.txt +0 -0
oarepo_runtime/cli/index.py
CHANGED
@@ -7,6 +7,7 @@ from flask.cli import with_appcontext
|
|
7
7
|
from invenio_db import db
|
8
8
|
from invenio_records_resources.proxies import current_service_registry
|
9
9
|
from invenio_search.proxies import current_search
|
10
|
+
import traceback
|
10
11
|
from werkzeug.utils import ImportStringError, import_string
|
11
12
|
|
12
13
|
try:
|
@@ -102,9 +103,10 @@ def record_or_service(model):
|
|
102
103
|
@click.option("--verbose/--no-verbose", default=False)
|
103
104
|
def reindex(model, bulk_size, verbose):
|
104
105
|
if not model:
|
105
|
-
services = current_service_registry._services.keys()
|
106
|
+
services = list(current_service_registry._services.keys())
|
106
107
|
else:
|
107
108
|
services = [model]
|
109
|
+
services = sort_services(services)
|
108
110
|
for service_id in services:
|
109
111
|
click.secho(f"Preparing to index {service_id}", file=sys.stderr)
|
110
112
|
|
@@ -200,14 +202,17 @@ def generate_bulk_data(record_generator, record_indexer, bulk_size):
|
|
200
202
|
data = []
|
201
203
|
n = 0
|
202
204
|
for record in tqdm(record_generator):
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
205
|
+
try:
|
206
|
+
index = record_indexer.record_to_index(record)
|
207
|
+
body = record_indexer._prepare_record(record, index)
|
208
|
+
index = record_indexer._prepare_index(index)
|
209
|
+
data.append({"index": {"_index": index, "_id": body["uuid"]}})
|
210
|
+
data.append(body)
|
211
|
+
if len(data) >= bulk_size:
|
212
|
+
yield data
|
213
|
+
data = []
|
214
|
+
except:
|
215
|
+
traceback.print_exc()
|
211
216
|
if data:
|
212
217
|
yield data
|
213
218
|
|
@@ -240,5 +245,19 @@ def users_record_generator(model_class):
|
|
240
245
|
except Exception as e:
|
241
246
|
click.secho(f"Could not index {model_class}: {e}", fg="red", file=sys.stderr)
|
242
247
|
|
248
|
+
priorities = [
|
249
|
+
'vocabular',
|
250
|
+
'users',
|
251
|
+
'groups'
|
252
|
+
]
|
253
|
+
|
254
|
+
def sort_services(services):
|
255
|
+
def idx(x):
|
256
|
+
for idx, p in enumerate(priorities):
|
257
|
+
if p in x:
|
258
|
+
return idx, x
|
259
|
+
return len(priorities), x
|
260
|
+
services.sort(key=idx)
|
261
|
+
return services
|
243
262
|
|
244
263
|
RECORD_GENERATORS = {"users": users_record_generator}
|
@@ -9,6 +9,7 @@ from invenio_records import Record
|
|
9
9
|
from oarepo_runtime.services.custom_fields import CustomFieldsMixin, CustomFields, InlinedCustomFields
|
10
10
|
from oarepo_runtime.services.generators import RecordOwners
|
11
11
|
|
12
|
+
|
12
13
|
try:
|
13
14
|
from invenio_drafts_resources.services.records.uow import ParentRecordCommitOp
|
14
15
|
except ImportError:
|
@@ -88,3 +89,29 @@ class CustomFieldsComponent(ServiceComponent):
|
|
88
89
|
config = current_app.config.get(cf.config_key, {})
|
89
90
|
for c in config:
|
90
91
|
record[c.name] =data.get(c.name)
|
92
|
+
|
93
|
+
def process_service_configs(service_configs):
|
94
|
+
"""
|
95
|
+
Processes a list of service_config classes. If a class has a `components` attribute,
|
96
|
+
it extends the result with the values in it.
|
97
|
+
|
98
|
+
:param service_config: List of service_config classes to process.
|
99
|
+
:return: A flattened list of processed components.
|
100
|
+
"""
|
101
|
+
processed_components = []
|
102
|
+
|
103
|
+
for config in service_configs:
|
104
|
+
|
105
|
+
if hasattr(config, "build"):
|
106
|
+
config = config.build(current_app)
|
107
|
+
|
108
|
+
if hasattr(config, 'components'):
|
109
|
+
component_property = config.components
|
110
|
+
if isinstance(component_property, list):
|
111
|
+
processed_components.extend(component_property)
|
112
|
+
elif isinstance(component_property, tuple):
|
113
|
+
processed_components.extend(list (component_property))
|
114
|
+
else:
|
115
|
+
raise ValueError(f"{config} component's definition is not supported")
|
116
|
+
|
117
|
+
return processed_components
|
@@ -12,7 +12,7 @@ oarepo_runtime/cli/cf.py,sha256=W0JEJK2JqKubQw8qtZJxohmADDRUBode4JZAqYLDGvc,339
|
|
12
12
|
oarepo_runtime/cli/check.py,sha256=sCe2PeokSHvNOXHFZ8YHF8NMhsu5nYjyuZuvXHJ6X18,5092
|
13
13
|
oarepo_runtime/cli/configuration.py,sha256=_iMmESs2dd1Oif95gxgpnkSxc13ymwr82_sTJfxlhrM,1091
|
14
14
|
oarepo_runtime/cli/fixtures.py,sha256=l6zHpz1adjotrbFy_wcN2TOL8x20i-1jbQmaoEEo-UU,5419
|
15
|
-
oarepo_runtime/cli/index.py,sha256=
|
15
|
+
oarepo_runtime/cli/index.py,sha256=KH5PArp0fCNbgJI1zSz0pb69U9eyCdnJuy0aMIgf2tg,8685
|
16
16
|
oarepo_runtime/cli/validate.py,sha256=HpSvHQCGHlrdgdpKix9cIlzlBoJEiT1vACZdMnOUGEY,2827
|
17
17
|
oarepo_runtime/datastreams/__init__.py,sha256=_i52Ek9J8DMARST0ejZAZPzUKm55xrrlKlCSO7dl6y4,1008
|
18
18
|
oarepo_runtime/datastreams/asynchronous.py,sha256=JwT-Hx6P7KwV0vSJlxX6kLSIX5vtsekVsA2p_hZpJ_U,7402
|
@@ -71,7 +71,7 @@ oarepo_runtime/resources/file_resource.py,sha256=Ta3bFce7l0xwqkkOMOEu9mxbB8BbKj5
|
|
71
71
|
oarepo_runtime/resources/json_serializer.py,sha256=82_-xQEtxKaPakv8R1oBAFbGnxskF_Ve4tcfcy4PetI,963
|
72
72
|
oarepo_runtime/resources/localized_ui_json_serializer.py,sha256=3V9cJaG_e1PMXKVX_wKfBp1LmbeForwHyBNYdyha4uQ,1878
|
73
73
|
oarepo_runtime/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
74
|
-
oarepo_runtime/services/components.py,sha256=
|
74
|
+
oarepo_runtime/services/components.py,sha256=k--zu1RinwoKzg5qHp4H-Ddp9AFyjMJ97fydQ0DvI-A,4238
|
75
75
|
oarepo_runtime/services/generators.py,sha256=j87HitHA_w2awsz0C5IAAJ0qjg9JMtvdO3dvh6FQyfg,250
|
76
76
|
oarepo_runtime/services/results.py,sha256=_Din6CxQH7E5TP0TVZjIXJb2vyJRL_o_97jkUQo-GOc,4062
|
77
77
|
oarepo_runtime/services/search.py,sha256=9xGTN5Yg6eTdptQ9qjO_umbacf9ooMuHYGXWYfla4-M,6227
|
@@ -131,9 +131,9 @@ tests/marshmallow_to_json/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJW
|
|
131
131
|
tests/marshmallow_to_json/test_datacite_ui_schema.py,sha256=82iLj8nW45lZOUewpWbLX3mpSkpa9lxo-vK-Qtv_1bU,48552
|
132
132
|
tests/marshmallow_to_json/test_simple_schema.py,sha256=izZN9p0v6kovtSZ6AdxBYmK_c6ZOti2_z_wPT_zXIr0,1500
|
133
133
|
tests/pkg_data/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
134
|
-
oarepo_runtime-1.5.
|
135
|
-
oarepo_runtime-1.5.
|
136
|
-
oarepo_runtime-1.5.
|
137
|
-
oarepo_runtime-1.5.
|
138
|
-
oarepo_runtime-1.5.
|
139
|
-
oarepo_runtime-1.5.
|
134
|
+
oarepo_runtime-1.5.73.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
|
135
|
+
oarepo_runtime-1.5.73.dist-info/METADATA,sha256=8Bid-R0AnVSDDv-EI6lCJbtTANbDTy8wDGYN60nsWY0,4720
|
136
|
+
oarepo_runtime-1.5.73.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
137
|
+
oarepo_runtime-1.5.73.dist-info/entry_points.txt,sha256=0cschM0RHc6UJ1uudhu4EP0hrVStPGpgMO-XEDGRtY4,430
|
138
|
+
oarepo_runtime-1.5.73.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
|
139
|
+
oarepo_runtime-1.5.73.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|