oarepo-runtime 1.3.10__py3-none-any.whl → 1.3.13__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.
@@ -6,6 +6,7 @@ from flask import current_app
6
6
  from flask.cli import with_appcontext
7
7
  from invenio_files_rest.models import Location
8
8
  from invenio_pidstore.models import PersistentIdentifier
9
+ from invenio_db import db
9
10
  from invenio_records_resources.proxies import current_service_registry
10
11
  from opensearchpy import TransportError
11
12
 
@@ -32,18 +33,21 @@ def check(output_file):
32
33
 
33
34
  def check_database():
34
35
  try:
35
- PersistentIdentifier.query.all()[:1]
36
- except:
37
- return 'not_initialized'
38
- alembic = current_app.extensions['invenio-db'].alembic
39
- context = alembic.migration_context
40
- db_heads = set(context.get_current_heads())
41
- source_heads = [x.revision for x in alembic.current()]
42
- for h in source_heads:
43
- if h not in db_heads:
44
- return 'migration_pending'
45
- return 'ok'
46
-
36
+ db.session.begin()
37
+ try:
38
+ PersistentIdentifier.query.all()[:1]
39
+ except:
40
+ return 'not_initialized'
41
+ alembic = current_app.extensions['invenio-db'].alembic
42
+ context = alembic.migration_context
43
+ db_heads = set(context.get_current_heads())
44
+ source_heads = [x.revision for x in alembic.current()]
45
+ for h in source_heads:
46
+ if h not in db_heads:
47
+ return 'migration_pending'
48
+ return 'ok'
49
+ finally:
50
+ db.session.rollback()
47
51
 
48
52
  def check_opensearch():
49
53
  services = current_service_registry._services.keys()
@@ -63,9 +67,15 @@ def check_opensearch():
63
67
 
64
68
 
65
69
  def check_files():
66
- # check that there is the default location and that is readable
67
- default_location = Location.get_default()
68
- if default_location:
69
- return 'ok'
70
- else:
71
- return 'default-location-missing'
70
+ try:
71
+ db.session.begin()
72
+ # check that there is the default location and that is readable
73
+ default_location = Location.get_default()
74
+ if default_location:
75
+ return 'ok'
76
+ else:
77
+ return 'default-location-missing'
78
+ except:
79
+ return 'db-error'
80
+ finally:
81
+ db.session.rollback()
@@ -76,6 +76,10 @@ def reindex(model):
76
76
 
77
77
  service = current_service_registry.get(service_id)
78
78
  record_class = service.config.record_cls
79
+
80
+ if not hasattr(service, 'indexer'):
81
+ continue
82
+
79
83
  try:
80
84
  id_generator = (
81
85
  x[0]
@@ -19,12 +19,13 @@ def fixtures():
19
19
  @click.argument("fixture_dir", required=False)
20
20
  @click.option("--include", multiple=True)
21
21
  @click.option("--exclude", multiple=True)
22
+ @click.option("--system-fixtures/--no-system-fixtures", default=True, is_flag=True)
22
23
  @with_appcontext
23
- def load(fixture_dir=None, include=None, exclude=None):
24
+ def load(fixture_dir=None, include=None, exclude=None, system_fixtures=None):
24
25
  """Loads fixtures"""
25
26
  with current_app.wsgi_app.mounts["/api"].app_context():
26
27
  results: FixturesResult = load_fixtures(
27
- fixture_dir, _make_list(include), _make_list(exclude)
28
+ fixture_dir, _make_list(include), _make_list(exclude), system_fixtures=system_fixtures
28
29
  )
29
30
  _show_stats(results, "Load fixtures")
30
31
 
@@ -182,6 +182,9 @@ class DataStream(AbstractDataStream):
182
182
  try:
183
183
  writer.write(stream_entry)
184
184
  except WriterError as err:
185
+ log.error(
186
+ "Error in writer: %s: %s", err, repr(stream_entry.entry)
187
+ )
185
188
  stream_entry.errors.append(StreamEntryError.from_exception(err))
186
189
  except Exception as err:
187
190
  log.error(
@@ -33,7 +33,7 @@ class FixturesResult:
33
33
  self.results[fixture_name] = result
34
34
 
35
35
 
36
- def load_fixtures(fixture_dir=None, include=None, exclude=None) -> FixturesResult:
36
+ def load_fixtures(fixture_dir=None, include=None, exclude=None, system_fixtures=True) -> FixturesResult:
37
37
  """
38
38
  Loads fixtures. If fixture dir is set, fixtures are loaded from that directory first.
39
39
  The directory must contain a catalogue.yaml file containing datastreams to load the
@@ -55,15 +55,16 @@ def load_fixtures(fixture_dir=None, include=None, exclude=None) -> FixturesResul
55
55
  if fixture_dir:
56
56
  catalogue = DataStreamCatalogue(Path(fixture_dir) / "catalogue.yaml")
57
57
  _load_fixtures_from_catalogue(catalogue, fixtures, include, exclude, result)
58
- for r in reversed(
59
- sorted(pkg_resources.iter_entry_points("oarepo.fixtures"), key=lambda r: r.name)
60
- ):
61
- pkg = r.load()
62
- pkg_fixture_dir = Path(pkg.__file__)
63
- if pkg_fixture_dir.is_file():
64
- pkg_fixture_dir = pkg_fixture_dir.parent
65
- catalogue = DataStreamCatalogue(pkg_fixture_dir / "catalogue.yaml")
66
- _load_fixtures_from_catalogue(catalogue, fixtures, include, exclude, result)
58
+ if system_fixtures:
59
+ for r in reversed(
60
+ sorted(pkg_resources.iter_entry_points("oarepo.fixtures"), key=lambda r: r.name)
61
+ ):
62
+ pkg = r.load()
63
+ pkg_fixture_dir = Path(pkg.__file__)
64
+ if pkg_fixture_dir.is_file():
65
+ pkg_fixture_dir = pkg_fixture_dir.parent
66
+ catalogue = DataStreamCatalogue(pkg_fixture_dir / "catalogue.yaml")
67
+ _load_fixtures_from_catalogue(catalogue, fixtures, include, exclude, result)
67
68
  return result
68
69
 
69
70
 
@@ -1,3 +1,5 @@
1
+ import traceback
2
+
1
3
  from invenio_access.permissions import system_identity
2
4
  from invenio_pidstore.errors import PIDAlreadyExists
3
5
  from invenio_records.systemfields.relations.errors import InvalidRelationValue
@@ -42,10 +44,12 @@ class ServiceWriter(BaseWriter):
42
44
  service_kwargs["uow"] = uow
43
45
  try:
44
46
  try:
47
+ print("Calling service create")
45
48
  entry = self._service.create(self._identity, entry, **service_kwargs)
46
49
  except PIDAlreadyExists:
47
50
  if not self._update:
48
51
  raise WriterError([f"Entry already exists: {entry}"])
52
+ print("Calling service update")
49
53
  entry_id = self._entry_id(entry)
50
54
  current = self._resolve(entry_id)
51
55
  updated = dict(current.to_dict(), **entry)
@@ -60,6 +64,9 @@ class ServiceWriter(BaseWriter):
60
64
  except InvalidRelationValue as err:
61
65
  # TODO: Check if we can get the error message easier
62
66
  raise WriterError([{"InvalidRelationValue": err.args[0]}])
67
+ except Exception as err:
68
+ traceback.print_exc()
69
+ raise WriterError([{"Unknown error": str(err)}])
63
70
 
64
71
  def delete(self, stream_entry: StreamEntry, uow=None):
65
72
  service_kwargs = {}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: oarepo-runtime
3
- Version: 1.3.10
3
+ Version: 1.3.13
4
4
  Summary: A set of runtime extensions of Invenio repository
5
5
  Description-Content-Type: text/markdown
6
6
  License-File: LICENSE
@@ -9,8 +9,8 @@ oarepo_runtime/cf/mappings.py,sha256=_Gcje90WpE2e9IKPvr5xZR263Cks2IW4YP0ENp-pjUY
9
9
  oarepo_runtime/cli/__init__.py,sha256=VIbVNJh_r856s4sA4-7hZpmyuQtxPIOGRp1YXjXHsjo,178
10
10
  oarepo_runtime/cli/assets.py,sha256=yFpHMAI0fvJBy4wUz1GcNjmfzN_9KegqCj9NgGDfZ9g,1444
11
11
  oarepo_runtime/cli/base.py,sha256=xZMsR2rati5Mz0DZzmnlhVI7E6ePCfnOiTayrxT9cWU,259
12
- oarepo_runtime/cli/check.py,sha256=Q9Ye0T1_RZP49QTanTrVOtk-MScSg0lJUNvpHffnLRE,2047
13
- oarepo_runtime/cli/index.py,sha256=bxw4yE1ah_pSxnmql6fwG8jqbH640DQ5yE0-Y3RBkG8,3145
12
+ oarepo_runtime/cli/check.py,sha256=5_dpCDcnVqsjzxDpgDlU5WPRDOpAfiKLrfdBoj0KEgs,2340
13
+ oarepo_runtime/cli/index.py,sha256=bT28rqf_EyuH1MiiFr3WovW6MapG61IGwSfVD_kbtUs,3212
14
14
  oarepo_runtime/cli/validate.py,sha256=hw4aW-DPaZFgvrmeRaIbyKck7w_KypU_6nrnzE8_ibY,1460
15
15
  oarepo_runtime/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
16
16
  oarepo_runtime/config/permissions_presets.py,sha256=rQcvTsxyPOGtgjWUunE4oSzIwfm4W6VAOOvnYJSJosY,5766
@@ -18,11 +18,11 @@ oarepo_runtime/config/service.py,sha256=Js5Dyklqt8diul2HdqoAMxy5Jl6jk2moznHLUDPf
18
18
  oarepo_runtime/datastreams/__init__.py,sha256=bscO2zTYf1eEppYx74b54-fcb2wz7YUDjGupqafuFc0,724
19
19
  oarepo_runtime/datastreams/batch.py,sha256=Xe0kXZigDeHU6Sjvo7w4_zjas8lShc2aTJpaAAQ3Iq0,551
20
20
  oarepo_runtime/datastreams/catalogue.py,sha256=QaHLGTzQk76B9q_6vFx1I3fBSGL8SrHni4zA0v2572s,4975
21
- oarepo_runtime/datastreams/cli.py,sha256=0EMZM3M-A8Yy0Rd9_AgSTWaPplXGHq2Ta41d_XZAVNQ,1936
21
+ oarepo_runtime/datastreams/cli.py,sha256=irtL-1ZKlLapiD_Cevh9rcuPg96Rj4PKZgAe_l5XZBs,2075
22
22
  oarepo_runtime/datastreams/config.py,sha256=ALq7otBFMHjT3GV59KpkEV-8ZborWrYLXyB3v5-nFGE,1083
23
- oarepo_runtime/datastreams/datastreams.py,sha256=c6dDkKdhK82n0q3RyXMpB9tFDADl9SGUriGNquoO8BE,6390
23
+ oarepo_runtime/datastreams/datastreams.py,sha256=slEM2GSM4g1WQ-6VwbwkO6GRjMfOp4rON9N2U2YjR4E,6512
24
24
  oarepo_runtime/datastreams/errors.py,sha256=KxtFD2jX8pIoCNYFvh937otySVYjTVCrPSS13AZnVus,690
25
- oarepo_runtime/datastreams/fixtures.py,sha256=hgu0OOFbx5jmZzv_fhLpM6bSoc9HnGdX09_jVTX7laU,5344
25
+ oarepo_runtime/datastreams/fixtures.py,sha256=hkgu2oy6gZN40CrgiGZKoNghMX1znSxvVMrKSPvB-Ds,5426
26
26
  oarepo_runtime/datastreams/transformers.py,sha256=4COh2cza_n2GKnTM2yJkj9-8KkPK2E1fcyRoUH4S2OY,1204
27
27
  oarepo_runtime/datastreams/readers/__init__.py,sha256=UyKJbymJyfk7rdAAyNI-t2fDKQNz69_5B7KI8RJ2cWE,858
28
28
  oarepo_runtime/datastreams/readers/excel.py,sha256=QP_1a75jlW1udNgBx8FIdWkaoWiTrQ2ysjbi8H1wPmw,3287
@@ -30,7 +30,7 @@ oarepo_runtime/datastreams/readers/json.py,sha256=ZZfD71ymnoaAYgsQ67wLdtWUx7rpDE
30
30
  oarepo_runtime/datastreams/readers/service.py,sha256=NrlUqjGCtqYekEYVGauYgcNyidorSgX6O6jt3gnWcfs,947
31
31
  oarepo_runtime/datastreams/readers/yaml.py,sha256=15P4faTmtBBpzg8RBJ42pQOP4iWdrrvyZNsEtdQc1UY,332
32
32
  oarepo_runtime/datastreams/writers/__init__.py,sha256=8HIRwHxacUxvluqKxog8pUE1iKMwSqeI9wtlSyfx00E,1366
33
- oarepo_runtime/datastreams/writers/service.py,sha256=JLtaLy8qP9Wi8mdoyh9hnWH4RwCGMjY54FXLjBseza0,2688
33
+ oarepo_runtime/datastreams/writers/service.py,sha256=r9ybLer6sHVH5M0wlSPzP9Bpw6QhTiZBjRiKEECwel8,2930
34
34
  oarepo_runtime/datastreams/writers/yaml.py,sha256=B4lv-85UYB9K-3B35O1_vsRhH8AdhYfL8IgB3SS1LFw,1312
35
35
  oarepo_runtime/expansions/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
36
36
  oarepo_runtime/expansions/expandable_fields.py,sha256=7DWKFL6ml8J7zGI6wm9LO7Xd6R0LSylsuq4lyRumNHQ,745
@@ -70,9 +70,9 @@ oarepo_runtime/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hS
70
70
  oarepo_runtime/utils/path.py,sha256=V1NVyk3m12_YLbj7QHYvUpE1wScO78bYsX1LOLeXDkI,3108
71
71
  oarepo_runtime/validation/__init__.py,sha256=lU7DgZq8pGD5Pa-QqL9gvLsib3IYtM-Y56k-NwHrPG0,166
72
72
  oarepo_runtime/validation/dates.py,sha256=fahqKGDdIYWux5ZeoljrEe8VD2fDZR9VpfvYmTYAmpw,1050
73
- oarepo_runtime-1.3.10.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
74
- oarepo_runtime-1.3.10.dist-info/METADATA,sha256=8fC5WbN7Eml64_fTFi0N4Yz4C7x_lAItHlwJjHzbgT4,2552
75
- oarepo_runtime-1.3.10.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
76
- oarepo_runtime-1.3.10.dist-info/entry_points.txt,sha256=C32W4eT-8OypMCfwOO5WREioVKSneDfY51D78Uvdbp0,231
77
- oarepo_runtime-1.3.10.dist-info/top_level.txt,sha256=Vdo5ohKvEHniyXfcy3hv92nVSYIngDYGQtinWviujlw,15
78
- oarepo_runtime-1.3.10.dist-info/RECORD,,
73
+ oarepo_runtime-1.3.13.dist-info/LICENSE,sha256=h2uWz0OaB3EN-J1ImdGJZzc7yvfQjvHVYdUhQ-H7ypY,1064
74
+ oarepo_runtime-1.3.13.dist-info/METADATA,sha256=lPPpdGdmHUNNJjHa0mjEDKPZG3cr-B6Zl9kLbnkgCAw,2552
75
+ oarepo_runtime-1.3.13.dist-info/WHEEL,sha256=pkctZYzUS4AYVn6dJ-7367OJZivF2e8RA9b_ZBjif18,92
76
+ oarepo_runtime-1.3.13.dist-info/entry_points.txt,sha256=C32W4eT-8OypMCfwOO5WREioVKSneDfY51D78Uvdbp0,231
77
+ oarepo_runtime-1.3.13.dist-info/top_level.txt,sha256=Vdo5ohKvEHniyXfcy3hv92nVSYIngDYGQtinWviujlw,15
78
+ oarepo_runtime-1.3.13.dist-info/RECORD,,