Skip to content

Commit aff9e65

Browse files
committed
Regroup all ROBOT-related options in a dedicated robot section.
This is proof-of-concept reorganisation of the configuration schema to test the whole idea that we can make relatively big changes to the schema while preserving compatibility with existing files. We create a new subsection in the top-level `project` dictionary, called `robot`, intended to host all ROBOT-related options. That is, the following options and group, that are currently directly under the top-level object: obo_format_options: ... robot_relax_options: ... robot_reduce_options: ... robot_plugins: plugins: - name: my_plugin robot_report: release_reports: True fail_on: ERROR ... are now renamed and regrouped into a single `robot` section: robot: obo_format_options: ... relax_options: ... reduce_options: ... plugins: - name: my_plugin report: release_reports: True fail_on: ERROR ...
1 parent fe644e1 commit aff9e65

4 files changed

Lines changed: 85 additions & 77 deletions

File tree

odk/odk.py

Lines changed: 34 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -596,13 +596,29 @@ class RobotPlugin(JsonSchemaMixin):
596596

597597
@dataclass_json
598598
@dataclass
599-
class PluginsGroup(JsonSchemaMixin):
599+
class RobotOptionsGroup(JsonSchemaMixin):
600600
"""
601-
A configuration section to list extra ROBOT plugins not provided by the ODK
601+
A configuration section for additional options specific to ROBOT.
602602
"""
603603

604+
reasoner : str = "ELK"
605+
"""Reasoner to use in robot commands that need one."""
606+
607+
obo_format_options : str = ""
608+
"""Additional options to pass to robot convert when exporting to OBO. Default is '--clean-obo "strict drop-untranslatable-axioms"'."""
609+
610+
relax_options : str = "--include-subclass-of true"
611+
"""Additional options to pass to robot relax command."""
612+
613+
reduce_options : str = "--include-subproperties true"
614+
"""Additional options to pass to robot reduce command."""
615+
604616
plugins : Optional[List[RobotPlugin]] = None
605-
"""The list of plugins to use"""
617+
"""List of ROBOT plugins used by this project."""
618+
619+
report : Dict[str, Any] = field(default_factory=lambda: ReportConfig().to_dict())
620+
"""Settings for ROBOT report, ROBOT verify and additional reports that are generated."""
621+
606622

607623

608624
@dataclass_json
@@ -664,9 +680,6 @@ class OntologyProject(JsonSchemaMixin):
664680
export_project_yaml: bool = False
665681
"""Flag to set if you want a full project.yaml to be exported, including all the default options."""
666682

667-
reasoner : str = "ELK"
668-
"""Name of reasoner to use in ontology pipeline, see robot reason docs for allowed values"""
669-
670683
exclude_tautologies : str = "structural"
671684
"""Remove tautologies such as A SubClassOf: owl:Thing or owl:Nothing SubclassOf: A. For more information see http://robot.obolibrary.org/reason#excluding-tautologies"""
672685

@@ -771,15 +784,6 @@ class OntologyProject(JsonSchemaMixin):
771784
travis_emails : Optional[List[Email]] = None ## ['obo-ci-reports-all@groups.io']
772785
"""Emails to use in travis configurations. """
773786

774-
obo_format_options : str = ""
775-
"""Additional args to pass to robot when saving to obo. The default is '--clean-obo "strict drop-untranslatable-axioms"'."""
776-
777-
robot_relax_options : str = "--include-subclass-of true"
778-
"""Additional options to pass to robot's relax command."""
779-
780-
robot_reduce_options : str = "--include-subproperties true"
781-
"""Additional options to pass to robot's reduce command."""
782-
783787
catalog_file : str = "catalog-v001.xml"
784788
"""Name of the catalog file to be used by the build."""
785789

@@ -798,17 +802,14 @@ class OntologyProject(JsonSchemaMixin):
798802
contributors : Optional[List[Person]] = None
799803
"""List of ontology contributors (currently setting this has no effect)"""
800804

801-
robot_report : Dict[str, Any] = field(default_factory=lambda: ReportConfig().to_dict())
802-
"""Block that includes settings for ROBOT report, ROBOT verify and additional reports that are generated"""
803-
804805
ensure_valid_rdfxml : bool = True
805806
"""When enabled, ensure that any RDF/XML product file is valid"""
806807

807808
extra_rdfxml_checks : bool = False
808809
"""When enabled, RDF/XML product files are checked against additional parsers"""
809810

810-
robot_plugins : Optional[PluginsGroup] = None
811-
"""Block that includes information on the extra ROBOT plugins used by this project"""
811+
robot : RobotOptionsGroup = field(default_factory=lambda: RobotOptionsGroup())
812+
"""Block for ROBOT-related options"""
812813

813814
# product groups
814815
import_group : Optional[ImportGroup] = None
@@ -855,10 +856,10 @@ def fill_missing(self):
855856
if self.components is not None:
856857
self.components.fill_missing(self)
857858

858-
if not '--clean-obo' in self.obo_format_options:
859-
if len(self.obo_format_options) > 0:
860-
self.obo_format_options += ' '
861-
self.obo_format_options += '--clean-obo "strict drop-untranslatable-axioms"'
859+
if not '--clean-obo' in self.robot.obo_format_options:
860+
if len(self.robot.obo_format_options) > 0:
861+
self.robot.obo_format_options += ' '
862+
self.robot.obo_format_options += '--clean-obo "strict drop-untranslatable-axioms"'
862863

863864
@dataclass
864865
class ExecutionContext(JsonSchemaMixin):
@@ -938,7 +939,13 @@ def update_config_dict(obj):
938939
"""
939940
changes = [
940941
# old key path new key path
941-
('example.old.key', 'example.new.key')
942+
('reasoner', 'robot.reasoner'),
943+
('obo_format_options', 'robot.obo_format_options'),
944+
('relax_options', 'robot.relax_options'),
945+
('reduce_options', 'robot.reduce_options'),
946+
('robot_plugins.plugins', 'robot.plugins'),
947+
('robot_plugins', None),
948+
('robot_report', 'robot.report'),
942949
]
943950
for old, new in changes:
944951
v = pop_key(obj, old)
@@ -1435,7 +1442,7 @@ def update(templatedir):
14351442
policies.append(('.github/workflows/' + workflow + '.yml', ALWAYS))
14361443
if project.documentation is not None and 'docs' in project.workflows:
14371444
policies.append(('.github/workflows/docs.yml', ALWAYS))
1438-
if not project.robot_report.get('custom_profile', False):
1445+
if not project.robot.report.get('custom_profile', False):
14391446
policies.append(('src/ontology/profile.txt', NEVER))
14401447

14411448
# Proceed with template instantiation, using the policies
@@ -1523,7 +1530,7 @@ def seed(config, clean, outdir, templatedir, dependencies, title, user, source,
15231530
logging.info("No templates folder in /tools/; assume not in docker context")
15241531
templatedir = "./template"
15251532
policies = []
1526-
if not project.robot_report.get('custom_profile', False):
1533+
if not project.robot.report.get('custom_profile', False):
15271534
policies.append(('src/ontology/profile.txt', NEVER))
15281535
tgts += install_template_files(mg, templatedir, outdir, policies)
15291536

template/_dynamic_documentation.jinja2

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -802,19 +802,20 @@ We can define custom checks using [SPARQL](https://www.w3.org/TR/rdf-sparql-quer
802802

803803
1. Add the SPARQL query in `src/sparql`. The name of the file should end with `-violation.sparql`. Please give a name that helps to understand which violation the query wants to check.
804804
2. Add the name of the new file to odk configuration file `src/ontology/uberon-odk.yaml`:
805-
1. Include the name of the file (without the `-violation.sparql` part) to the list inside the key `custom_sparql_checks` that is inside `robot_report` key.
806-
1. If the `robot_report` or `custom_sparql_checks` keys are not available, please add this code block to the end of the file.
805+
1. Include the name of the file (without the `-violation.sparql` part) to the list inside the key `custom_sparql_checks` that is inside `robot.report` key.
806+
1. If the `robot.report` or `custom_sparql_checks` keys are not available, please add this code block to the end of the file.
807807

808808
``` yaml
809-
robot_report:
810-
release_reports: False
811-
fail_on: ERROR
812-
use_labels: False
813-
custom_profile: True
814-
report_on:
815-
- edit
816-
custom_sparql_checks:
817-
- name-of-the-file-check
809+
robot:
810+
report:
811+
release_reports: False
812+
fail_on: ERROR
813+
use_labels: False
814+
custom_profile: True
815+
report_on:
816+
- edit
817+
custom_sparql_checks:
818+
- name-of-the-file-check
818819
```
819820
3. Update the repository so your new SPARQL check will be included in the QC.
820821

template/_dynamic_sparql.jinja2

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ WHERE {
1717
{#
1818
SPARQL QUERY QC checks
1919
-#}
20-
{% if project.robot_report.custom_sparql_checks is not defined or 'owldef-self-reference' in project.robot_report.custom_sparql_checks -%}
20+
{% if project.robot.report.custom_sparql_checks is not defined or 'owldef-self-reference' in project.robot.report.custom_sparql_checks -%}
2121
^^^ src/sparql/owldef-self-reference-violation.sparql
2222
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
2323
PREFIX oio: <http://www.geneontology.org/formats/oboInOwl#>
@@ -31,7 +31,7 @@ SELECT ?term WHERE {
3131
FILTER(isIRI(?term) && ({% if project.namespaces %}{% for ns in project.namespaces %}STRSTARTS(str(?term), "{{ ns }}"){% if not loop.last %} || {% endif %}{% endfor %}{% else %}STRSTARTS(str(?term), "{{ project.uribase }}/{{ project.id.upper() }}_"){% endif %}))
3232
}
3333
{% endif -%}
34-
{% if project.robot_report.custom_sparql_checks is not defined or 'redundant-subClassOf' in project.robot_report.custom_sparql_checks -%}
34+
{% if project.robot.report.custom_sparql_checks is not defined or 'redundant-subClassOf' in project.robot.report.custom_sparql_checks -%}
3535
^^^ src/sparql/redundant-subClassOf-violation.sparql
3636
PREFIX oio: <http://www.geneontology.org/formats/oboInOwl#>
3737
PREFIX owl: <http://www.w3.org/2002/07/owl#>
@@ -48,7 +48,7 @@ SELECT ?term ?xl ?y ?yl ?z ?zl WHERE {
4848
FILTER(isIRI(?term) && ({% if project.namespaces %}{% for ns in project.namespaces %}STRSTARTS(str(?term), "{{ ns }}"){% if not loop.last %} || {% endif %}{% endfor %}{% else %}STRSTARTS(str(?term), "{{ project.uribase }}/{{ project.id.upper() }}_"){% endif %}))
4949
}
5050
{% endif -%}
51-
{% if project.robot_report.custom_sparql_checks is not defined or 'taxon-range' in project.robot_report.custom_sparql_checks -%}
51+
{% if project.robot.report.custom_sparql_checks is not defined or 'taxon-range' in project.robot.report.custom_sparql_checks -%}
5252
^^^ src/sparql/taxon-range-violation.sparql
5353
PREFIX never_in_taxon: <http://purl.obolibrary.org/obo/RO_0002161>
5454
PREFIX present_in_taxon: <http://purl.obolibrary.org/obo/RO_0002175>
@@ -61,7 +61,7 @@ WHERE {
6161
FILTER(isIRI(?term) && ({% if project.namespaces %}{% for ns in project.namespaces %}STRSTARTS(str(?term), "{{ ns }}"){% if not loop.last %} || {% endif %}{% endfor %}{% else %}STRSTARTS(str(?term), "{{ project.uribase }}/{{ project.id.upper() }}_"){% endif %}))
6262
}
6363
{% endif -%}
64-
{% if project.robot_report.custom_sparql_checks is not defined or 'iri-range' in project.robot_report.custom_sparql_checks -%}
64+
{% if project.robot.report.custom_sparql_checks is not defined or 'iri-range' in project.robot.report.custom_sparql_checks -%}
6565
^^^ src/sparql/iri-range-violation.sparql
6666
PREFIX never_in_taxon: <http://purl.obolibrary.org/obo/RO_0002161>
6767
PREFIX present_in_taxon: <http://purl.obolibrary.org/obo/RO_0002175>
@@ -82,7 +82,7 @@ WHERE {
8282
FILTER (!isIRI(?value))
8383
}
8484
{% endif -%}
85-
{% if project.robot_report.custom_sparql_checks is not defined or 'iri-range-advanced' in project.robot_report.custom_sparql_checks -%}
85+
{% if project.robot.report.custom_sparql_checks is not defined or 'iri-range-advanced' in project.robot.report.custom_sparql_checks -%}
8686
^^^ src/sparql/iri-range-advanced-violation.sparql
8787
PREFIX never_in_taxon: <http://purl.obolibrary.org/obo/RO_0002161>
8888
PREFIX present_in_taxon: <http://purl.obolibrary.org/obo/RO_0002175>
@@ -105,7 +105,7 @@ WHERE {
105105
FILTER (!isIRI(?value))
106106
}
107107
{% endif -%}
108-
{% if project.robot_report.custom_sparql_checks is not defined or 'label-with-iri' in project.robot_report.custom_sparql_checks -%}
108+
{% if project.robot.report.custom_sparql_checks is not defined or 'label-with-iri' in project.robot.report.custom_sparql_checks -%}
109109
^^^ src/sparql/label-with-iri-violation.sparql
110110
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
111111

@@ -116,7 +116,7 @@ WHERE {
116116
FILTER(isIRI(?term) && ({% if project.namespaces %}{% for ns in project.namespaces %}STRSTARTS(str(?term), "{{ ns }}"){% if not loop.last %} || {% endif %}{% endfor %}{% else %}STRSTARTS(str(?term), "{{ project.uribase }}/{{ project.id.upper() }}_"){% endif %}))
117117
}
118118
{% endif -%}
119-
{% if project.robot_report.custom_sparql_checks is not defined or 'multiple-replaced_by' in project.robot_report.custom_sparql_checks -%}
119+
{% if project.robot.report.custom_sparql_checks is not defined or 'multiple-replaced_by' in project.robot.report.custom_sparql_checks -%}
120120
^^^ src/sparql/multiple-replaced_by-violation.sparql
121121
PREFIX replaced_by: <http://purl.obolibrary.org/obo/IAO_0100001>
122122

@@ -130,7 +130,7 @@ SELECT DISTINCT ?entity ?property ?value WHERE {
130130
BIND(CONCAT(str(?value1), CONCAT("|", str(?value2))) as ?value)
131131
}
132132
{% endif -%}
133-
{% if project.robot_report.custom_sparql_checks is not defined or 'term-tracker-uri' in project.robot_report.custom_sparql_checks -%}
133+
{% if project.robot.report.custom_sparql_checks is not defined or 'term-tracker-uri' in project.robot.report.custom_sparql_checks -%}
134134
^^^ src/sparql/term-tracker-uri-violation.sparql
135135
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
136136
PREFIX term_tracker_item: <http://purl.obolibrary.org/obo/IAO_0000233>
@@ -141,7 +141,7 @@ SELECT ?term ?term_tracker ?term_tracker_type WHERE {
141141
BIND(DATATYPE(?term_tracker) as ?term_tracker_type)
142142
}
143143
{% endif -%}
144-
{% if project.robot_report.custom_sparql_checks is not defined or 'illegal-date' in project.robot_report.custom_sparql_checks -%}
144+
{% if project.robot.report.custom_sparql_checks is not defined or 'illegal-date' in project.robot.report.custom_sparql_checks -%}
145145
^^^ src/sparql/illegal-date-violation.sparql
146146
PREFIX dct: <http://purl.org/dc/terms/>
147147
PREFIX xsd: <http://www.w3.org/2001/XMLSchema#>
@@ -155,7 +155,7 @@ SELECT DISTINCT ?term ?property ?value WHERE
155155
FILTER (datatype(?value) != xsd:dateTime || !regex(str(?value), '^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z'))
156156
}
157157
{% endif -%}
158-
{% if project.robot_report.custom_sparql_checks is not defined or 'dc-properties' in project.robot_report.custom_sparql_checks -%}
158+
{% if project.robot.report.custom_sparql_checks is not defined or 'dc-properties' in project.robot.report.custom_sparql_checks -%}
159159
^^^ src/sparql/dc-properties-violation.sparql
160160
# The purpose of this violation is to make sure people update
161161
# from using the deprecated DC Elements 1.1 namespace (http://purl.org/dc/elements/1.1/)

0 commit comments

Comments
 (0)