oarepo-runtime 1.10.2__py3-none-any.whl → 2.0.0.dev3__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.
Files changed (171) hide show
  1. oarepo_runtime/__init__.py +24 -0
  2. oarepo_runtime/api.py +111 -0
  3. oarepo_runtime/cli/__init__.py +10 -21
  4. oarepo_runtime/cli/search.py +34 -0
  5. oarepo_runtime/config.py +86 -13
  6. oarepo_runtime/ext.py +64 -82
  7. oarepo_runtime/proxies.py +21 -5
  8. oarepo_runtime/records/__init__.py +11 -50
  9. oarepo_runtime/records/drafts.py +24 -18
  10. oarepo_runtime/records/mapping.py +84 -0
  11. oarepo_runtime/records/pid_providers.py +43 -7
  12. oarepo_runtime/records/systemfields/__init__.py +15 -33
  13. oarepo_runtime/records/systemfields/mapping.py +41 -24
  14. oarepo_runtime/records/systemfields/publication_status.py +59 -0
  15. oarepo_runtime/services/__init__.py +12 -0
  16. oarepo_runtime/services/config/__init__.py +15 -21
  17. oarepo_runtime/services/config/link_conditions.py +69 -75
  18. oarepo_runtime/services/config/permissions.py +62 -0
  19. oarepo_runtime/services/records/__init__.py +14 -1
  20. oarepo_runtime/services/records/links.py +21 -11
  21. oarepo_runtime/services/records/mapping.py +42 -0
  22. oarepo_runtime/services/results.py +98 -109
  23. oarepo_runtime/services/schema/__init__.py +12 -44
  24. oarepo_runtime/services/schema/i18n.py +47 -22
  25. oarepo_runtime/services/schema/i18n_ui.py +61 -24
  26. {oarepo_runtime-1.10.2.dist-info → oarepo_runtime-2.0.0.dev3.dist-info}/METADATA +9 -21
  27. oarepo_runtime-2.0.0.dev3.dist-info/RECORD +30 -0
  28. {oarepo_runtime-1.10.2.dist-info → oarepo_runtime-2.0.0.dev3.dist-info}/WHEEL +1 -2
  29. oarepo_runtime-2.0.0.dev3.dist-info/entry_points.txt +5 -0
  30. oarepo_runtime/cli/assets.py +0 -145
  31. oarepo_runtime/cli/base.py +0 -25
  32. oarepo_runtime/cli/cf.py +0 -15
  33. oarepo_runtime/cli/check.py +0 -167
  34. oarepo_runtime/cli/configuration.py +0 -51
  35. oarepo_runtime/cli/fixtures.py +0 -167
  36. oarepo_runtime/cli/index.py +0 -272
  37. oarepo_runtime/cli/permissions/__init__.py +0 -6
  38. oarepo_runtime/cli/permissions/base.py +0 -26
  39. oarepo_runtime/cli/permissions/evaluate.py +0 -63
  40. oarepo_runtime/cli/permissions/list.py +0 -239
  41. oarepo_runtime/cli/permissions/search.py +0 -121
  42. oarepo_runtime/cli/validate.py +0 -150
  43. oarepo_runtime/datastreams/__init__.py +0 -38
  44. oarepo_runtime/datastreams/asynchronous.py +0 -247
  45. oarepo_runtime/datastreams/catalogue.py +0 -150
  46. oarepo_runtime/datastreams/datastreams.py +0 -152
  47. oarepo_runtime/datastreams/errors.py +0 -54
  48. oarepo_runtime/datastreams/ext.py +0 -41
  49. oarepo_runtime/datastreams/fixtures.py +0 -265
  50. oarepo_runtime/datastreams/json.py +0 -4
  51. oarepo_runtime/datastreams/readers/__init__.py +0 -39
  52. oarepo_runtime/datastreams/readers/attachments.py +0 -51
  53. oarepo_runtime/datastreams/readers/excel.py +0 -123
  54. oarepo_runtime/datastreams/readers/json.py +0 -27
  55. oarepo_runtime/datastreams/readers/service.py +0 -54
  56. oarepo_runtime/datastreams/readers/yaml.py +0 -14
  57. oarepo_runtime/datastreams/semi_asynchronous.py +0 -91
  58. oarepo_runtime/datastreams/synchronous.py +0 -70
  59. oarepo_runtime/datastreams/transformers.py +0 -18
  60. oarepo_runtime/datastreams/types.py +0 -323
  61. oarepo_runtime/datastreams/utils.py +0 -131
  62. oarepo_runtime/datastreams/writers/__init__.py +0 -21
  63. oarepo_runtime/datastreams/writers/attachments_file.py +0 -92
  64. oarepo_runtime/datastreams/writers/attachments_service.py +0 -118
  65. oarepo_runtime/datastreams/writers/publish.py +0 -70
  66. oarepo_runtime/datastreams/writers/service.py +0 -175
  67. oarepo_runtime/datastreams/writers/utils.py +0 -30
  68. oarepo_runtime/datastreams/writers/validation_errors.py +0 -20
  69. oarepo_runtime/datastreams/writers/yaml.py +0 -56
  70. oarepo_runtime/ext_config.py +0 -67
  71. oarepo_runtime/i18n/__init__.py +0 -3
  72. oarepo_runtime/info/__init__.py +0 -0
  73. oarepo_runtime/info/check.py +0 -95
  74. oarepo_runtime/info/permissions/__init__.py +0 -0
  75. oarepo_runtime/info/permissions/debug.py +0 -191
  76. oarepo_runtime/info/views.py +0 -586
  77. oarepo_runtime/profile.py +0 -60
  78. oarepo_runtime/records/dumpers/__init__.py +0 -8
  79. oarepo_runtime/records/dumpers/edtf_interval.py +0 -38
  80. oarepo_runtime/records/dumpers/multilingual_dumper.py +0 -34
  81. oarepo_runtime/records/entity_resolvers/__init__.py +0 -13
  82. oarepo_runtime/records/entity_resolvers/proxies.py +0 -57
  83. oarepo_runtime/records/mappings/__init__.py +0 -0
  84. oarepo_runtime/records/mappings/rdm_parent_mapping.json +0 -483
  85. oarepo_runtime/records/owners/__init__.py +0 -3
  86. oarepo_runtime/records/owners/registry.py +0 -22
  87. oarepo_runtime/records/relations/__init__.py +0 -22
  88. oarepo_runtime/records/relations/base.py +0 -296
  89. oarepo_runtime/records/relations/internal.py +0 -46
  90. oarepo_runtime/records/relations/lookup.py +0 -28
  91. oarepo_runtime/records/relations/pid_relation.py +0 -102
  92. oarepo_runtime/records/systemfields/featured_file.py +0 -45
  93. oarepo_runtime/records/systemfields/has_draftcheck.py +0 -47
  94. oarepo_runtime/records/systemfields/icu.py +0 -371
  95. oarepo_runtime/records/systemfields/owner.py +0 -115
  96. oarepo_runtime/records/systemfields/record_status.py +0 -35
  97. oarepo_runtime/records/systemfields/selectors.py +0 -98
  98. oarepo_runtime/records/systemfields/synthetic.py +0 -130
  99. oarepo_runtime/resources/__init__.py +0 -4
  100. oarepo_runtime/resources/config.py +0 -12
  101. oarepo_runtime/resources/file_resource.py +0 -15
  102. oarepo_runtime/resources/json_serializer.py +0 -27
  103. oarepo_runtime/resources/localized_ui_json_serializer.py +0 -54
  104. oarepo_runtime/resources/resource.py +0 -53
  105. oarepo_runtime/resources/responses.py +0 -20
  106. oarepo_runtime/services/components.py +0 -429
  107. oarepo_runtime/services/config/draft_link.py +0 -23
  108. oarepo_runtime/services/config/permissions_presets.py +0 -174
  109. oarepo_runtime/services/config/service.py +0 -117
  110. oarepo_runtime/services/custom_fields/__init__.py +0 -80
  111. oarepo_runtime/services/custom_fields/mappings.py +0 -188
  112. oarepo_runtime/services/entity/__init__.py +0 -0
  113. oarepo_runtime/services/entity/config.py +0 -14
  114. oarepo_runtime/services/entity/schema.py +0 -9
  115. oarepo_runtime/services/entity/service.py +0 -48
  116. oarepo_runtime/services/expansions/__init__.py +0 -0
  117. oarepo_runtime/services/expansions/expandable_fields.py +0 -21
  118. oarepo_runtime/services/expansions/service.py +0 -4
  119. oarepo_runtime/services/facets/__init__.py +0 -33
  120. oarepo_runtime/services/facets/base.py +0 -12
  121. oarepo_runtime/services/facets/date.py +0 -72
  122. oarepo_runtime/services/facets/enum.py +0 -11
  123. oarepo_runtime/services/facets/facet_groups_names.py +0 -17
  124. oarepo_runtime/services/facets/max_facet.py +0 -13
  125. oarepo_runtime/services/facets/multilingual_facet.py +0 -33
  126. oarepo_runtime/services/facets/nested_facet.py +0 -32
  127. oarepo_runtime/services/facets/params.py +0 -192
  128. oarepo_runtime/services/facets/year_histogram.py +0 -200
  129. oarepo_runtime/services/files/__init__.py +0 -8
  130. oarepo_runtime/services/files/components.py +0 -62
  131. oarepo_runtime/services/files/service.py +0 -16
  132. oarepo_runtime/services/generators.py +0 -10
  133. oarepo_runtime/services/permissions/__init__.py +0 -3
  134. oarepo_runtime/services/permissions/generators.py +0 -103
  135. oarepo_runtime/services/relations/__init__.py +0 -0
  136. oarepo_runtime/services/relations/components.py +0 -15
  137. oarepo_runtime/services/relations/errors.py +0 -18
  138. oarepo_runtime/services/relations/mapping.py +0 -38
  139. oarepo_runtime/services/schema/cf.py +0 -13
  140. oarepo_runtime/services/schema/i18n_validation.py +0 -7
  141. oarepo_runtime/services/schema/marshmallow.py +0 -44
  142. oarepo_runtime/services/schema/marshmallow_to_json_schema.py +0 -72
  143. oarepo_runtime/services/schema/oneofschema.py +0 -192
  144. oarepo_runtime/services/schema/polymorphic.py +0 -21
  145. oarepo_runtime/services/schema/rdm.py +0 -75
  146. oarepo_runtime/services/schema/rdm_ui.py +0 -156
  147. oarepo_runtime/services/schema/ui.py +0 -251
  148. oarepo_runtime/services/schema/validation.py +0 -70
  149. oarepo_runtime/services/search.py +0 -282
  150. oarepo_runtime/services/service.py +0 -61
  151. oarepo_runtime/tasks.py +0 -6
  152. oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
  153. oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -85
  154. oarepo_runtime/translations/default_translations.py +0 -6
  155. oarepo_runtime/translations/en/LC_MESSAGES/messages.mo +0 -0
  156. oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -89
  157. oarepo_runtime/translations/messages.pot +0 -91
  158. oarepo_runtime/uow.py +0 -146
  159. oarepo_runtime/utils/__init__.py +0 -0
  160. oarepo_runtime/utils/functools.py +0 -37
  161. oarepo_runtime/utils/identity_utils.py +0 -35
  162. oarepo_runtime/utils/index.py +0 -11
  163. oarepo_runtime/utils/path.py +0 -97
  164. oarepo_runtime-1.10.2.dist-info/RECORD +0 -163
  165. oarepo_runtime-1.10.2.dist-info/entry_points.txt +0 -16
  166. oarepo_runtime-1.10.2.dist-info/top_level.txt +0 -2
  167. tests/marshmallow_to_json/__init__.py +0 -0
  168. tests/marshmallow_to_json/test_datacite_ui_schema.py +0 -1410
  169. tests/marshmallow_to_json/test_simple_schema.py +0 -52
  170. tests/pkg_data/__init__.py +0 -0
  171. {oarepo_runtime-1.10.2.dist-info → oarepo_runtime-2.0.0.dev3.dist-info}/licenses/LICENSE +0 -0
@@ -1,191 +0,0 @@
1
- """Instrumentors for debugging permissions."""
2
-
3
- import contextvars
4
- import inspect
5
- import json
6
- import sys
7
-
8
- from invenio_records_permissions.generators import ConditionalGenerator, Generator
9
-
10
-
11
- def generator_to_debug_dict(self: Generator):
12
- ret = {
13
- "name": self.__class__.__name__,
14
- }
15
- ret = {}
16
- for fld in self.__dict__:
17
- if fld.startswith("__"):
18
- continue
19
- if fld in ("then_", "else_"):
20
- continue
21
- value = self.__dict__[fld]
22
- if not isinstance(value, (str, int, float, bool)):
23
- value = str(value)
24
- ret[fld] = value
25
-
26
- return {self.__class__.__name__: ret}
27
-
28
-
29
- def conditional_generator_to_debug_dict(self: ConditionalGenerator):
30
- ret = generator_to_debug_dict(self)
31
- r = ret[self.__class__.__name__]
32
- if self.then_:
33
- r["then"] = [x.to_debug_dict() for x in self.then_]
34
- if self.else_:
35
- r["else"] = [x.to_debug_dict() for x in self.else_]
36
- return ret
37
-
38
-
39
- def get_all_generators():
40
- generator_classes = set()
41
- queue = [Generator]
42
- while queue:
43
- gen = queue.pop()
44
- generator_classes.add(gen)
45
- for cls in gen.__subclasses__():
46
- if cls in generator_classes:
47
- continue
48
- queue.append(cls)
49
- return generator_classes
50
-
51
-
52
- debugging_level = contextvars.ContextVar("debugging_level", default=0)
53
-
54
-
55
- def debug_needs_output(clz, method_name):
56
- method = getattr(clz, method_name)
57
-
58
- def wrapper(self, *args, **kwargs):
59
- dd = json.dumps(self.to_debug_dict())
60
- print(f"{' ' * debugging_level.get()}{dd}.{method_name} ->", file=sys.stderr)
61
- reset = debugging_level.set(debugging_level.get() + 1)
62
- ret = method(self, *args, **kwargs)
63
- debugging_level.reset(reset)
64
- if "debug_identity" in kwargs:
65
- matched_needs = set(ret) & set(kwargs["debug_identity"].provides)
66
- print(
67
- f"{' ' * debugging_level.get()} -> match: {matched_needs}",
68
- file=sys.stderr,
69
- )
70
- else:
71
- print(f"{' ' * debugging_level.get()} -> {ret}", file=sys.stderr)
72
- return ret
73
-
74
- return wrapper
75
-
76
-
77
- def debug_search_output(clz, method_name, print_search):
78
- method = getattr(clz, method_name)
79
-
80
- def wrapper(self, *args, **kwargs):
81
- dd = json.dumps(self.to_debug_dict())
82
- if print_search:
83
- print(f"{' ' * debugging_level.get()}{dd}.{method_name}:", file=sys.stderr)
84
- reset = debugging_level.set(debugging_level.get() + 2)
85
- ret = method(self, *args, **kwargs)
86
- debugging_level.reset(reset)
87
- if isinstance(ret, list):
88
- r = merge_communities([x.to_dict() for x in ret])
89
- elif ret:
90
- r = merge_communities(ret.to_dict())
91
- else:
92
- r = None
93
- if print_search:
94
- print(
95
- f"{' ' * debugging_level.get()}{dd}.{method_name} -> {r}",
96
- file=sys.stderr,
97
- )
98
- return ret
99
-
100
- wrapper.__module__ = clz.__module__
101
- wrapper.__qualname__ = f"{clz.__qualname__}.{method_name}"
102
- wrapper.__name__ = method_name
103
- return wrapper
104
-
105
-
106
- def merge_communities(x):
107
- if isinstance(x, list):
108
- return [merge_communities(y) for y in x]
109
- if isinstance(x, dict):
110
- ret = {k: merge_communities(v) for k, v in x.items()}
111
- if "parent.communities.default" in ret:
112
- ret["parent.communities.default"] = "#communities#"
113
- if "parent.communities.ids" in ret:
114
- ret["parent.communities.ids"] = "#communities#"
115
- return ret
116
- return x
117
-
118
-
119
- def get_opensearch_caller():
120
- # Get the current call stack
121
- stack = inspect.stack()
122
- # Extract function names from the stack frames
123
- function_names = []
124
- state = "skipping_to_opensearch"
125
- for frame in stack:
126
- module_name = frame.frame.f_globals["__name__"]
127
- if state == "skipping_to_opensearch":
128
- if module_name.startswith("opensearch_dsl.") or module_name.startswith(
129
- "oarepo_runtime.info"
130
- ):
131
- state = "found_opensearch"
132
- if state == "found_opensearch":
133
- if not module_name.startswith(
134
- "opensearch_dsl."
135
- ) and not module_name.startswith("oarepo_runtime.info"):
136
- state = "outside_opensearch"
137
- if state == "outside_opensearch":
138
- if frame.function == "<lambda>":
139
- continue
140
- if "self" in frame.frame.f_locals:
141
- self_instance = frame.frame.f_locals["self"]
142
- class_name = self_instance.__class__.__name__
143
- function_names.append(
144
- f"{class_name}.{frame.function} @ {frame.filename}:{frame.lineno}"
145
- )
146
- else:
147
- function_names.append(
148
- f"{frame.function} @ {frame.filename}:{frame.lineno}"
149
- )
150
- del frame
151
-
152
- return function_names
153
-
154
-
155
- def add_debugging(print_needs=True, print_excludes=True, print_search=True):
156
- for generator in get_all_generators():
157
- if issubclass(generator, ConditionalGenerator):
158
- generator.to_debug_dict = conditional_generator_to_debug_dict
159
- else:
160
- generator.to_debug_dict = generator_to_debug_dict
161
- if print_needs and not hasattr(generator.needs, "__is_debug_instrumented__"):
162
- generator.needs = debug_needs_output(generator, "needs")
163
- generator.needs.__is_debug_instrumented__ = True
164
- if print_excludes and not hasattr(
165
- generator.excludes, "__is_debug_instrumented__"
166
- ):
167
- generator.excludes = debug_needs_output(generator, "excludes")
168
- generator.excludes.__is_debug_instrumented__ = True
169
-
170
- if hasattr(generator, "query_filters"):
171
- if not hasattr(generator.query_filters, "__is_debug_instrumented__"):
172
- generator.query_filters = debug_search_output(
173
- generator, "query_filters", print_search
174
- )
175
- generator.query_filters.__is_debug_instrumented__ = True
176
- if hasattr(generator, "query_filter"):
177
- if not hasattr(generator.query_filter, "__is_debug_instrumented__"):
178
- generator.query_filter = debug_search_output(
179
- generator, "query_filter", print_search
180
- )
181
- generator.query_filter.__is_debug_instrumented__ = True
182
- # try to add _name to queries
183
- from opensearch_dsl.query import Query
184
-
185
- previous_init = Query.__init__
186
-
187
- def new_init(self, *args, **kwargs):
188
- previous_init(self, *args, **kwargs)
189
- self._params["_name"] = get_opensearch_caller()[0]
190
-
191
- Query.__init__ = new_init