Skip to content
Snippets Groups Projects
Verified Commit 448faa36 authored by Daniel Hornung's avatar Daniel Hornung
Browse files

ENH: jsex has new parameter `use_rt_pool`

parent 8bbb9e0a
No related branches found
No related tags found
3 merge requests!100WIP: Filling XLSX: Seems to be working.,!94ENH: add framework for converting json schema into table templates,!93Filling XLSX: Everything except multiple choice.
...@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ...@@ -8,6 +8,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added ### ### Added ###
- Json schema exporter has new parameter `use_rt_pool`.
### Changed ### ### Changed ###
### Deprecated ### ### Deprecated ###
......
...@@ -29,6 +29,7 @@ from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union ...@@ -29,6 +29,7 @@ from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
import linkahead as db import linkahead as db
from linkahead.common.datatype import get_list_datatype, is_list_datatype from linkahead.common.datatype import get_list_datatype, is_list_datatype
from .models.data_model import DataModel
class JsonSchemaExporter: class JsonSchemaExporter:
...@@ -45,6 +46,7 @@ class JsonSchemaExporter: ...@@ -45,6 +46,7 @@ class JsonSchemaExporter:
do_not_create: List[str] = None, do_not_create: List[str] = None,
do_not_retrieve: List[str] = None, do_not_retrieve: List[str] = None,
no_remote: bool = False, no_remote: bool = False,
use_rt_pool: DataModel = None,
multiple_choice: List[str] = None, multiple_choice: List[str] = None,
wrap_files_in_objects: bool = False, wrap_files_in_objects: bool = False,
): ):
...@@ -73,16 +75,21 @@ class JsonSchemaExporter: ...@@ -73,16 +75,21 @@ class JsonSchemaExporter:
description of the corresponding schema entry. If set to false, an description of the corresponding schema entry. If set to false, an
additional `unit` key is added to the schema itself which is purely additional `unit` key is added to the schema itself which is purely
annotational and ignored, e.g., in validation. Default is True. annotational and ignored, e.g., in validation. Default is True.
do_not_create : list[str] do_not_create : list[str], optional
A list of reference Property names, for which there should be no option A list of reference Property names, for which there should be no option
to create them. Instead, only the choice of existing elements should to create them. Instead, only the choice of existing elements should
be given. be given.
do_not_retrieve : list[str] do_not_retrieve : list[str], optional
A list of RedcordType names, for which no Records shall be retrieved. Instead, only an A list of RedcordType names, for which no Records shall be retrieved. Instead, only an
object description should be given. If this list overlaps with the `do_not_create` object description should be given. If this list overlaps with the `do_not_create`
parameter, the behavior is undefined. parameter, the behavior is undefined.
no_remote : bool no_remote : bool, optional
If True, do not attempt to connect to a LinkAhead server at all. Default is False. If True, do not attempt to connect to a LinkAhead server at all. Default is False. Note
that the exporter may fail if this option is activated and the data model is not
self-sufficient.
use_rt_pool : DataModel, optional
If given, do not attempt to retrieve RecordType information remotely but from this parameter
instead.
multiple_choice : list[str], optional multiple_choice : list[str], optional
A list of reference Property names which shall be denoted as multiple choice properties. A list of reference Property names which shall be denoted as multiple choice properties.
This means that each option in this property may be selected at most once. This is not This means that each option in this property may be selected at most once. This is not
...@@ -118,6 +125,7 @@ class JsonSchemaExporter: ...@@ -118,6 +125,7 @@ class JsonSchemaExporter:
self._do_not_create = do_not_create self._do_not_create = do_not_create
self._do_not_retrieve = do_not_retrieve self._do_not_retrieve = do_not_retrieve
self._no_remote = no_remote self._no_remote = no_remote
self._use_rt_pool = use_rt_pool
self._multiple_choice = multiple_choice self._multiple_choice = multiple_choice
self._wrap_files_in_objects = wrap_files_in_objects self._wrap_files_in_objects = wrap_files_in_objects
...@@ -256,7 +264,9 @@ class JsonSchemaExporter: ...@@ -256,7 +264,9 @@ class JsonSchemaExporter:
# Only a simple list of values # Only a simple list of values
json_prop["enum"] = values json_prop["enum"] = values
else: else:
if self._no_remote: if self._use_rt_pool:
rt = self._use_rt_pool.get_deep(prop_name)
elif self._no_remote:
rt = prop.datatype rt = prop.datatype
else: else:
rt = db.execute_query(f"FIND RECORDTYPE WITH name='{prop_name}'", rt = db.execute_query(f"FIND RECORDTYPE WITH name='{prop_name}'",
...@@ -479,6 +489,7 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T ...@@ -479,6 +489,7 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T
do_not_create: List[str] = None, do_not_create: List[str] = None,
do_not_retrieve: List[str] = None, do_not_retrieve: List[str] = None,
no_remote: bool = False, no_remote: bool = False,
use_rt_pool: DataModel = None,
multiple_choice: List[str] = None, multiple_choice: List[str] = None,
rjsf: bool = False, rjsf: bool = False,
wrap_files_in_objects: bool = False wrap_files_in_objects: bool = False
...@@ -524,6 +535,9 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T ...@@ -524,6 +535,9 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T
parameter, the behavior is undefined. parameter, the behavior is undefined.
no_remote : bool, optional no_remote : bool, optional
If True, do not attempt to connect to a LinkAhead server at all. Default is False. If True, do not attempt to connect to a LinkAhead server at all. Default is False.
use_rt_pool : DataModel, optional
If given, do not attempt to retrieve RecordType information remotely but from this parameter
instead.
multiple_choice : list[str], optional multiple_choice : list[str], optional
A list of reference Property names which shall be denoted as multiple choice properties. A list of reference Property names which shall be denoted as multiple choice properties.
This means that each option in this property may be selected at most once. This is not This means that each option in this property may be selected at most once. This is not
...@@ -560,6 +574,7 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T ...@@ -560,6 +574,7 @@ def recordtype_to_json_schema(rt: db.RecordType, additional_properties: bool = T
do_not_create=do_not_create, do_not_create=do_not_create,
do_not_retrieve=do_not_retrieve, do_not_retrieve=do_not_retrieve,
no_remote=no_remote, no_remote=no_remote,
use_rt_pool=use_rt_pool,
multiple_choice=multiple_choice, multiple_choice=multiple_choice,
wrap_files_in_objects=wrap_files_in_objects wrap_files_in_objects=wrap_files_in_objects
) )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment