oarepo-runtime 1.5.72__py3-none-any.whl → 1.5.73__py3-none-any.whl

Sign up to get free protection for your applications and to get access to all the features.
@@ -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
- index = record_indexer.record_to_index(record)
204
- body = record_indexer._prepare_record(record, index)
205
- index = record_indexer._prepare_index(index)
206
- data.append({"index": {"_index": index, "_id": body["uuid"]}})
207
- data.append(body)
208
- if len(data) >= bulk_size:
209
- yield data
210
- data = []
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}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.5.72
3
+ Version: 1.5.73
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -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=2dZvXtrph527YIgFTCQ8dIVsza-bZou9HBBzYRWAPTY,8243
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
@@ -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.72.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
135
- oarepo_runtime-1.5.72.dist-info/METADATA,sha256=NmVgzl6SJu489vMIebbEad-M3jpzpxTER2qZZEHQ6M4,4720
136
- oarepo_runtime-1.5.72.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
137
- oarepo_runtime-1.5.72.dist-info/entry_points.txt,sha256=0cschM0RHc6UJ1uudhu4EP0hrVStPGpgMO-XEDGRtY4,430
138
- oarepo_runtime-1.5.72.dist-info/top_level.txt,sha256=bHhlkT1_RQC4IkfTQCqA3iN4KCB6cSFQlsXpQMSP-bE,21
139
- oarepo_runtime-1.5.72.dist-info/RECORD,,
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,,