feat: output could have annotator
This commit is contained in:
parent
688aa8d053
commit
a91a4d6a55
8 changed files with 105 additions and 64 deletions
|
@ -71,6 +71,11 @@ class SpaceAnnotator: # pylint: disable=R0903
|
||||||
if extra_annotator in ANNOTATORS:
|
if extra_annotator in ANNOTATORS:
|
||||||
continue
|
continue
|
||||||
get_annotators(ANNOTATORS, extra_annotator)
|
get_annotators(ANNOTATORS, extra_annotator)
|
||||||
|
if objectspace.output:
|
||||||
|
try:
|
||||||
|
get_annotators(ANNOTATORS, f"rougail.output_{objectspace.output}", "annotator")
|
||||||
|
except ModuleNotFoundError:
|
||||||
|
pass
|
||||||
for user_data in objectspace.user_datas:
|
for user_data in objectspace.user_datas:
|
||||||
try:
|
try:
|
||||||
get_annotators(ANNOTATORS, f"rougail.user_data_{user_data}", "annotator")
|
get_annotators(ANNOTATORS, f"rougail.user_data_{user_data}", "annotator")
|
||||||
|
@ -88,6 +93,8 @@ class SpaceAnnotator: # pylint: disable=R0903
|
||||||
annotators.extend(ANNOTATORS[f"rougail.{plugin}.annotator"])
|
annotators.extend(ANNOTATORS[f"rougail.{plugin}.annotator"])
|
||||||
for user_data in objectspace.user_datas:
|
for user_data in objectspace.user_datas:
|
||||||
annotators.extend(ANNOTATORS[f"rougail.user_data_{user_data}.annotator"])
|
annotators.extend(ANNOTATORS[f"rougail.user_data_{user_data}.annotator"])
|
||||||
|
if objectspace.output:
|
||||||
|
annotators.extend(ANNOTATORS[f"rougail.output_{objectspace.output}.annotator"])
|
||||||
annotators = sorted(annotators, key=get_level)
|
annotators = sorted(annotators, key=get_level)
|
||||||
functions = {}
|
functions = {}
|
||||||
functions_files = objectspace.functions_files
|
functions_files = objectspace.functions_files
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"rougail.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval1.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
},
|
||||||
|
"rougail.dynval2.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,8 @@
|
||||||
|
{
|
||||||
|
"rougail.var": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
],
|
||||||
|
"rougail.dynval1.var": [],
|
||||||
|
"rougail.dynval2.var": []
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"rougail.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": [
|
||||||
|
"val1",
|
||||||
|
"val2"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"rougail.dynval1.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
},
|
||||||
|
"rougail.dynval2.var": {
|
||||||
|
"owner": "default",
|
||||||
|
"value": []
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1 @@
|
||||||
|
[]
|
|
@ -0,0 +1,22 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers'] = "{{ s1 }}-{{ s2 }}\n"
|
||||||
|
option_2 = StrOption(name="var", doc="A identifier variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"standard"}), informations={'type': 'string'})
|
||||||
|
option_4 = StrOption(name="var", doc="A dynamic variable", multi=True, properties=frozenset({"standard"}), informations={'type': 'string'})
|
||||||
|
option_6 = StrOption(name="var", doc="A variable dynamic", default=Calculation(func['calc_value'], Params((ParamIdentifier()))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
option_7 = StrOption(name="var_identifier", doc="identifier from first family", default=Calculation(func['calc_value'], Params((ParamIdentifier(identifier_index=0)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
option_8 = StrOption(name="var_identifiers", doc="merge identifiers", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/60_6family_dynamic_sub_dynamic_empty2/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers"), 's1': ParamIdentifier(identifier_index=0), 's2': ParamIdentifier(identifier_index=1)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
optiondescription_5 = ConvertDynOptionDescription(name="dyn_{{ identifier }}", doc="a Second dynamic variable", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_4)))), children=[option_6, option_7, option_8], properties=frozenset({"standard"}), informations={'dynamic_variable': 'rougail.dyn{{ identifier }}.var'})
|
||||||
|
optiondescription_3 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="A dynamic family", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_2)))), children=[option_4, optiondescription_5], properties=frozenset({"standard"}), informations={'dynamic_variable': 'rougail.var'})
|
||||||
|
optiondescription_1 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_2, optiondescription_3], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1])
|
|
@ -0,0 +1,33 @@
|
||||||
|
from tiramisu import *
|
||||||
|
from tiramisu.setting import ALLOWED_LEADER_PROPERTIES
|
||||||
|
from re import compile as re_compile
|
||||||
|
from rougail.tiramisu import func, dict_env, load_functions, ConvertDynOptionDescription
|
||||||
|
load_functions('../rougail-tests/funcs/test.py')
|
||||||
|
try:
|
||||||
|
groups.namespace
|
||||||
|
except:
|
||||||
|
groups.addgroup('namespace')
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("basic")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("standard")
|
||||||
|
ALLOWED_LEADER_PROPERTIES.add("advanced")
|
||||||
|
dict_env['default_1.rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers'] = "{{ s1 }}-{{ s2 }}\n"
|
||||||
|
dict_env['default_2.rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers'] = "{{ s1 }}-{{ s2 }}\n"
|
||||||
|
option_3 = StrOption(name="var", doc="A identifier variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"standard"}), informations={'type': 'string'})
|
||||||
|
option_5 = StrOption(name="var", doc="A dynamic variable", multi=True, properties=frozenset({"standard"}), informations={'type': 'string'})
|
||||||
|
option_7 = StrOption(name="var", doc="A variable dynamic", default=Calculation(func['calc_value'], Params((ParamIdentifier()))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
option_8 = StrOption(name="var_identifier", doc="identifier from first family", default=Calculation(func['calc_value'], Params((ParamIdentifier(identifier_index=0)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
option_9 = StrOption(name="var_identifiers", doc="merge identifiers", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_1.rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/60_6family_dynamic_sub_dynamic_empty2/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("1.rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers"), 's1': ParamIdentifier(identifier_index=0), 's2': ParamIdentifier(identifier_index=1)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
optiondescription_6 = ConvertDynOptionDescription(name="dyn_{{ identifier }}", doc="a Second dynamic variable", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_5)))), children=[option_7, option_8, option_9], properties=frozenset({"standard"}), informations={'dynamic_variable': 'rougail.dyn{{ identifier }}.var'})
|
||||||
|
optiondescription_4 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="A dynamic family", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_3)))), children=[option_5, optiondescription_6], properties=frozenset({"standard"}), informations={'dynamic_variable': '1.rougail.var'})
|
||||||
|
optiondescription_2 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_3, optiondescription_4], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_1 = OptionDescription(name="1", doc="1", children=[optiondescription_2], properties=frozenset({"standard"}))
|
||||||
|
option_12 = StrOption(name="var", doc="A identifier variable", multi=True, default=["val1", "val2"], default_multi="val1", properties=frozenset({"standard"}), informations={'type': 'string'})
|
||||||
|
option_14 = StrOption(name="var", doc="A dynamic variable", multi=True, properties=frozenset({"standard"}), informations={'type': 'string'})
|
||||||
|
option_16 = StrOption(name="var", doc="A variable dynamic", default=Calculation(func['calc_value'], Params((ParamIdentifier()))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
option_17 = StrOption(name="var_identifier", doc="identifier from first family", default=Calculation(func['calc_value'], Params((ParamIdentifier(identifier_index=0)))), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
option_18 = StrOption(name="var_identifiers", doc="merge identifiers", default=Calculation(func['jinja_to_function'], Params((), kwargs={'__internal_jinja': ParamValue("default_2.rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers"), '__internal_type': ParamValue("string"), '__internal_multi': ParamValue(False), '__internal_files': ParamValue(['../rougail-tests/structures/60_6family_dynamic_sub_dynamic_empty2/rougail/00-base.yml']), '__internal_attribute': ParamValue("default"), '__internal_variable': ParamValue("2.rougail.dyn{{ identifier }}.dyn_{{ identifier }}.var_identifiers"), 's1': ParamIdentifier(identifier_index=0), 's2': ParamIdentifier(identifier_index=1)})), properties=frozenset({"mandatory", "standard"}), informations={'type': 'string'})
|
||||||
|
optiondescription_15 = ConvertDynOptionDescription(name="dyn_{{ identifier }}", doc="a Second dynamic variable", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_14)))), children=[option_16, option_17, option_18], properties=frozenset({"standard"}), informations={'dynamic_variable': 'rougail.dyn{{ identifier }}.var'})
|
||||||
|
optiondescription_13 = ConvertDynOptionDescription(name="dyn{{ identifier }}", doc="A dynamic family", identifiers=Calculation(func['calc_value'], Params((ParamOption(option_12)))), children=[option_14, optiondescription_15], properties=frozenset({"standard"}), informations={'dynamic_variable': '2.rougail.var'})
|
||||||
|
optiondescription_11 = OptionDescription(name="rougail", doc="Rougail", group_type=groups.namespace, children=[option_12, optiondescription_13], properties=frozenset({"standard"}))
|
||||||
|
optiondescription_10 = OptionDescription(name="2", doc="2", children=[optiondescription_11], properties=frozenset({"standard"}))
|
||||||
|
option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[optiondescription_1, optiondescription_10])
|
|
@ -1,64 +0,0 @@
|
||||||
from pathlib import Path
|
|
||||||
from pytest import fixture, raises
|
|
||||||
from shutil import rmtree
|
|
||||||
from rougail import Rougail, RougailConfig
|
|
||||||
|
|
||||||
doc = Path('doc')
|
|
||||||
tests = Path('tests')
|
|
||||||
tmp = tests / 'tmp'
|
|
||||||
if tmp.is_dir():
|
|
||||||
rmtree(tmp)
|
|
||||||
tmp.mkdir()
|
|
||||||
RougailConfig['main_dictionaries'] = [str(tmp)]
|
|
||||||
RougailConfig['functions_files'] = [str(tests / 'eosfunc' / 'test.py')]
|
|
||||||
|
|
||||||
|
|
||||||
scripts = {}
|
|
||||||
for filename in doc.glob('*/*.md'):
|
|
||||||
filename = str(filename)
|
|
||||||
with open(filename) as fh:
|
|
||||||
yaml = False
|
|
||||||
redefine = False
|
|
||||||
new_script = ''
|
|
||||||
for line in fh.readlines():
|
|
||||||
if new_script and line == '```\n':
|
|
||||||
scripts.setdefault(filename, [])
|
|
||||||
if redefine:
|
|
||||||
scripts[filename][-1].append(new_script)
|
|
||||||
else:
|
|
||||||
scripts[filename].append([new_script])
|
|
||||||
yaml = False
|
|
||||||
redefine = False
|
|
||||||
if yaml:
|
|
||||||
if line.strip() == 'redefine: true':
|
|
||||||
redefine = True
|
|
||||||
new_script += line
|
|
||||||
if line == '```yml\n':
|
|
||||||
yaml = True
|
|
||||||
new_script = ''
|
|
||||||
scripts_list = [(filename, script) for filename, scripts_ in scripts.items() for script in scripts_]
|
|
||||||
|
|
||||||
|
|
||||||
@fixture(scope="module", params=scripts_list)
|
|
||||||
def test_dir(request):
|
|
||||||
return request.param
|
|
||||||
|
|
||||||
|
|
||||||
def test_scripts(test_dir):
|
|
||||||
if tmp.is_dir():
|
|
||||||
rmtree(tmp)
|
|
||||||
tmp.mkdir()
|
|
||||||
for idx, content in enumerate(test_dir[1]):
|
|
||||||
if not content.startswith('---'):
|
|
||||||
raise Exception(f'not a valid template in {test_dir[0]}')
|
|
||||||
filename = tmp / f'0{idx}-base.yml'
|
|
||||||
with open(filename, 'w') as fh:
|
|
||||||
fh.write(content)
|
|
||||||
rougail = Rougail()
|
|
||||||
try:
|
|
||||||
config = rougail.get_config()
|
|
||||||
config.value.dict()
|
|
||||||
except Exception as err:
|
|
||||||
#rmtree(tmp)
|
|
||||||
raise Exception(f'error in {test_dir[0]}: {err}') from err
|
|
||||||
rmtree(tmp)
|
|
Loading…
Reference in a new issue