oarepo-runtime 1.10.3__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.
- oarepo_runtime/__init__.py +24 -0
- oarepo_runtime/api.py +111 -0
- oarepo_runtime/cli/__init__.py +10 -21
- oarepo_runtime/cli/search.py +34 -0
- oarepo_runtime/config.py +86 -13
- oarepo_runtime/ext.py +64 -82
- oarepo_runtime/proxies.py +21 -5
- oarepo_runtime/records/__init__.py +11 -50
- oarepo_runtime/records/drafts.py +24 -18
- oarepo_runtime/records/mapping.py +84 -0
- oarepo_runtime/records/pid_providers.py +43 -7
- oarepo_runtime/records/systemfields/__init__.py +15 -33
- oarepo_runtime/records/systemfields/mapping.py +41 -24
- oarepo_runtime/records/systemfields/publication_status.py +59 -0
- oarepo_runtime/services/__init__.py +12 -0
- oarepo_runtime/services/config/__init__.py +15 -21
- oarepo_runtime/services/config/link_conditions.py +69 -75
- oarepo_runtime/services/config/permissions.py +62 -0
- oarepo_runtime/services/records/__init__.py +14 -1
- oarepo_runtime/services/records/links.py +21 -11
- oarepo_runtime/services/records/mapping.py +42 -0
- oarepo_runtime/services/results.py +98 -109
- oarepo_runtime/services/schema/__init__.py +12 -44
- oarepo_runtime/services/schema/i18n.py +47 -22
- oarepo_runtime/services/schema/i18n_ui.py +61 -24
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-2.0.0.dev3.dist-info}/METADATA +9 -21
- oarepo_runtime-2.0.0.dev3.dist-info/RECORD +30 -0
- {oarepo_runtime-1.10.3.dist-info → oarepo_runtime-2.0.0.dev3.dist-info}/WHEEL +1 -2
- oarepo_runtime-2.0.0.dev3.dist-info/entry_points.txt +5 -0
- oarepo_runtime/cli/assets.py +0 -145
- oarepo_runtime/cli/base.py +0 -25
- oarepo_runtime/cli/cf.py +0 -15
- oarepo_runtime/cli/check.py +0 -167
- oarepo_runtime/cli/configuration.py +0 -51
- oarepo_runtime/cli/fixtures.py +0 -167
- oarepo_runtime/cli/index.py +0 -272
- oarepo_runtime/cli/permissions/__init__.py +0 -6
- oarepo_runtime/cli/permissions/base.py +0 -26
- oarepo_runtime/cli/permissions/evaluate.py +0 -63
- oarepo_runtime/cli/permissions/list.py +0 -239
- oarepo_runtime/cli/permissions/search.py +0 -121
- oarepo_runtime/cli/validate.py +0 -150
- oarepo_runtime/datastreams/__init__.py +0 -38
- oarepo_runtime/datastreams/asynchronous.py +0 -247
- oarepo_runtime/datastreams/catalogue.py +0 -150
- oarepo_runtime/datastreams/datastreams.py +0 -152
- oarepo_runtime/datastreams/errors.py +0 -54
- oarepo_runtime/datastreams/ext.py +0 -41
- oarepo_runtime/datastreams/fixtures.py +0 -265
- oarepo_runtime/datastreams/json.py +0 -4
- oarepo_runtime/datastreams/readers/__init__.py +0 -39
- oarepo_runtime/datastreams/readers/attachments.py +0 -51
- oarepo_runtime/datastreams/readers/excel.py +0 -123
- oarepo_runtime/datastreams/readers/json.py +0 -27
- oarepo_runtime/datastreams/readers/service.py +0 -54
- oarepo_runtime/datastreams/readers/yaml.py +0 -14
- oarepo_runtime/datastreams/semi_asynchronous.py +0 -91
- oarepo_runtime/datastreams/synchronous.py +0 -70
- oarepo_runtime/datastreams/transformers.py +0 -18
- oarepo_runtime/datastreams/types.py +0 -323
- oarepo_runtime/datastreams/utils.py +0 -131
- oarepo_runtime/datastreams/writers/__init__.py +0 -21
- oarepo_runtime/datastreams/writers/attachments_file.py +0 -92
- oarepo_runtime/datastreams/writers/attachments_service.py +0 -118
- oarepo_runtime/datastreams/writers/publish.py +0 -70
- oarepo_runtime/datastreams/writers/service.py +0 -175
- oarepo_runtime/datastreams/writers/utils.py +0 -30
- oarepo_runtime/datastreams/writers/validation_errors.py +0 -20
- oarepo_runtime/datastreams/writers/yaml.py +0 -56
- oarepo_runtime/ext_config.py +0 -67
- oarepo_runtime/i18n/__init__.py +0 -3
- oarepo_runtime/info/__init__.py +0 -0
- oarepo_runtime/info/check.py +0 -95
- oarepo_runtime/info/permissions/__init__.py +0 -0
- oarepo_runtime/info/permissions/debug.py +0 -191
- oarepo_runtime/info/views.py +0 -586
- oarepo_runtime/profile.py +0 -60
- oarepo_runtime/records/dumpers/__init__.py +0 -8
- oarepo_runtime/records/dumpers/edtf_interval.py +0 -38
- oarepo_runtime/records/dumpers/multilingual_dumper.py +0 -34
- oarepo_runtime/records/entity_resolvers/__init__.py +0 -13
- oarepo_runtime/records/entity_resolvers/proxies.py +0 -57
- oarepo_runtime/records/mappings/__init__.py +0 -0
- oarepo_runtime/records/mappings/rdm_parent_mapping.json +0 -483
- oarepo_runtime/records/owners/__init__.py +0 -3
- oarepo_runtime/records/owners/registry.py +0 -22
- oarepo_runtime/records/relations/__init__.py +0 -22
- oarepo_runtime/records/relations/base.py +0 -296
- oarepo_runtime/records/relations/internal.py +0 -46
- oarepo_runtime/records/relations/lookup.py +0 -28
- oarepo_runtime/records/relations/pid_relation.py +0 -102
- oarepo_runtime/records/systemfields/featured_file.py +0 -45
- oarepo_runtime/records/systemfields/has_draftcheck.py +0 -47
- oarepo_runtime/records/systemfields/icu.py +0 -371
- oarepo_runtime/records/systemfields/owner.py +0 -115
- oarepo_runtime/records/systemfields/record_status.py +0 -35
- oarepo_runtime/records/systemfields/selectors.py +0 -98
- oarepo_runtime/records/systemfields/synthetic.py +0 -130
- oarepo_runtime/resources/__init__.py +0 -4
- oarepo_runtime/resources/config.py +0 -12
- oarepo_runtime/resources/file_resource.py +0 -15
- oarepo_runtime/resources/json_serializer.py +0 -27
- oarepo_runtime/resources/localized_ui_json_serializer.py +0 -54
- oarepo_runtime/resources/resource.py +0 -53
- oarepo_runtime/resources/responses.py +0 -20
- oarepo_runtime/services/components.py +0 -429
- oarepo_runtime/services/config/draft_link.py +0 -23
- oarepo_runtime/services/config/permissions_presets.py +0 -174
- oarepo_runtime/services/config/service.py +0 -117
- oarepo_runtime/services/custom_fields/__init__.py +0 -80
- oarepo_runtime/services/custom_fields/mappings.py +0 -188
- oarepo_runtime/services/entity/__init__.py +0 -0
- oarepo_runtime/services/entity/config.py +0 -14
- oarepo_runtime/services/entity/schema.py +0 -9
- oarepo_runtime/services/entity/service.py +0 -48
- oarepo_runtime/services/expansions/__init__.py +0 -0
- oarepo_runtime/services/expansions/expandable_fields.py +0 -21
- oarepo_runtime/services/expansions/service.py +0 -4
- oarepo_runtime/services/facets/__init__.py +0 -33
- oarepo_runtime/services/facets/base.py +0 -12
- oarepo_runtime/services/facets/date.py +0 -72
- oarepo_runtime/services/facets/enum.py +0 -11
- oarepo_runtime/services/facets/facet_groups_names.py +0 -17
- oarepo_runtime/services/facets/max_facet.py +0 -13
- oarepo_runtime/services/facets/multilingual_facet.py +0 -33
- oarepo_runtime/services/facets/nested_facet.py +0 -32
- oarepo_runtime/services/facets/params.py +0 -192
- oarepo_runtime/services/facets/year_histogram.py +0 -200
- oarepo_runtime/services/files/__init__.py +0 -8
- oarepo_runtime/services/files/components.py +0 -62
- oarepo_runtime/services/files/service.py +0 -16
- oarepo_runtime/services/generators.py +0 -10
- oarepo_runtime/services/permissions/__init__.py +0 -3
- oarepo_runtime/services/permissions/generators.py +0 -103
- oarepo_runtime/services/relations/__init__.py +0 -0
- oarepo_runtime/services/relations/components.py +0 -15
- oarepo_runtime/services/relations/errors.py +0 -18
- oarepo_runtime/services/relations/mapping.py +0 -38
- oarepo_runtime/services/schema/cf.py +0 -13
- oarepo_runtime/services/schema/i18n_validation.py +0 -7
- oarepo_runtime/services/schema/marshmallow.py +0 -44
- oarepo_runtime/services/schema/marshmallow_to_json_schema.py +0 -72
- oarepo_runtime/services/schema/oneofschema.py +0 -192
- oarepo_runtime/services/schema/polymorphic.py +0 -21
- oarepo_runtime/services/schema/rdm.py +0 -146
- oarepo_runtime/services/schema/rdm_ui.py +0 -156
- oarepo_runtime/services/schema/ui.py +0 -251
- oarepo_runtime/services/schema/validation.py +0 -70
- oarepo_runtime/services/search.py +0 -282
- oarepo_runtime/services/service.py +0 -61
- oarepo_runtime/tasks.py +0 -6
- oarepo_runtime/translations/cs/LC_MESSAGES/messages.mo +0 -0
- oarepo_runtime/translations/cs/LC_MESSAGES/messages.po +0 -95
- oarepo_runtime/translations/default_translations.py +0 -6
- oarepo_runtime/translations/en/LC_MESSAGES/messages.mo +0 -0
- oarepo_runtime/translations/en/LC_MESSAGES/messages.po +0 -97
- oarepo_runtime/translations/messages.pot +0 -100
- oarepo_runtime/uow.py +0 -146
- oarepo_runtime/utils/__init__.py +0 -0
- oarepo_runtime/utils/functools.py +0 -37
- oarepo_runtime/utils/identity_utils.py +0 -35
- oarepo_runtime/utils/index.py +0 -11
- oarepo_runtime/utils/path.py +0 -97
- oarepo_runtime-1.10.3.dist-info/RECORD +0 -163
- oarepo_runtime-1.10.3.dist-info/entry_points.txt +0 -16
- oarepo_runtime-1.10.3.dist-info/top_level.txt +0 -2
- tests/marshmallow_to_json/__init__.py +0 -0
- tests/marshmallow_to_json/test_datacite_ui_schema.py +0 -1410
- tests/marshmallow_to_json/test_simple_schema.py +0 -52
- tests/pkg_data/__init__.py +0 -0
- {oarepo_runtime-1.10.3.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
|