From 8ecee3d03b9347d8eb8b3dc269b70d670c56d996 Mon Sep 17 00:00:00 2001 From: Damien Goutte-Gattat Date: Sun, 15 Mar 2026 17:14:20 +0000 Subject: [PATCH 1/2] Replace `use_base` option by a generic `use_variant` option. This commit generalizes the `use_base: True` option by replacing it by a new `use_variant` option, which takes the name of the ontology variant to use as an argument. For any given import IMP, setting `use_variant` to `FOO` instructs the ODK to download the IMP ontology from `http://purl.obolibrary.org/obo/IMP/IMP-FOO.owl`. This option is intended to make it easier to import arbitrary ontology variants without having to always specify their full URL using `mirror_from`. The old `use_base: True` option is exactly equivalent to `use_variant: base`, and whenever the old option is encountered in a configuration file, it is automatically interpreted as such. closes INCATools/ontology-development-kit#1321 --- src/incatools/odk/config.py | 12 +++++++++++- src/incatools/odk/model.py | 4 ++-- .../odk/templates/src/ontology/Makefile.jinja2 | 2 +- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/incatools/odk/config.py b/src/incatools/odk/config.py index edb6737..76eb1ae 100644 --- a/src/incatools/odk/config.py +++ b/src/incatools/odk/config.py @@ -193,7 +193,7 @@ def update_config_dict(obj: Dict[str, Any]) -> None: # First take care of stubs, if needed update_stubs(obj) - # Then all the other changes + # Then all the other simple changes changes = [ # old key path new key path ("reasoner", "robot.reasoner"), @@ -213,6 +213,16 @@ def update_config_dict(obj: Dict[str, Any]) -> None: else: logging.warning(f"Option {old} is deprecated") + # Then the more complex changes, that cannot be handled simply by + # renaming or moving keys around. + + # `use_base: True` ==> `use_variant: base` + if "import_group" in obj: + for imp in obj["import_group"]["products"]: + use_base = imp.pop("use_base", False) + if use_base: + imp["use_variant"] = "base" + def pop_key(obj: Dict[str, Any], path: str) -> Optional[str]: """Gets the value of a key in a nested dictionary structure. diff --git a/src/incatools/odk/model.py b/src/incatools/odk/model.py index f11456f..c2b628e 100644 --- a/src/incatools/odk/model.py +++ b/src/incatools/odk/model.py @@ -205,8 +205,8 @@ class ImportProduct(Product): for the list of allowed values and their meaning. """ - use_base: bool = False - """If true, download the -base version of the upstream source. + use_variant: Optional[str] = None + """If set, use the specified variant of the ontology. Only meaningful if ``mirror_from`` is not set, that is if the upstream source is downloaded from http://purl.obolibrary.org/obo/. diff --git a/src/incatools/odk/templates/src/ontology/Makefile.jinja2 b/src/incatools/odk/templates/src/ontology/Makefile.jinja2 index 17db330..fb42cfe 100644 --- a/src/incatools/odk/templates/src/ontology/Makefile.jinja2 +++ b/src/incatools/odk/templates/src/ontology/Makefile.jinja2 @@ -887,7 +887,7 @@ download-mirror-{{ ont.id }}: | $(TMPDIR) odk-helper download --output $(TMPDIR)/$@.owl \ --reference $(MIRRORDIR)/{{ ont.id }}.owl \ --max-retry {{ project.import_group.mirror_retry_download }} \ - {% if ont.mirror_from %}{{ ont.mirror_from }}{% elif ont.use_base %}$(OBOBASE)/{{ ont.id }}/{{ ont.id }}-base.owl{% if ont.use_gzipped %}.gz{% endif %}{% else %}$(OBOBASE)/{{ ont.id }}.owl{% if ont.use_gzipped %}.gz{% endif %}{% endif %} + {% if ont.mirror_from %}{{ ont.mirror_from }}{% elif ont.use_variant is not none %}$(OBOBASE)/{{ ont.id }}/{{ ont.id }}-{{ ont.use_variant }}.owl{% if ont.use_gzipped %}.gz{% endif %}{% else %}$(OBOBASE)/{{ ont.id }}.owl{% if ont.use_gzipped %}.gz{% endif %}{% endif %} {% if ont.mirror_type == 'custom' -%} $(MIRRORDIR)/{{ ont.id }}.owl: From b31924df4d549aba3d0a722ad4e04d8edb4456ec Mon Sep 17 00:00:00 2001 From: Damien Goutte-Gattat Date: Mon, 20 Apr 2026 11:02:31 +0100 Subject: [PATCH 2/2] Add an explicit test config for use_variant. So far the `use_variant` feature is only tested indirectly, using a config file that still uses the old `use_base: true` mechanism (and that is automatically migrated to `use_variant: base`). We add a test config that directly uses `use_variant` from the start. --- tests/configs/test-use-variant.yaml | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 tests/configs/test-use-variant.yaml diff --git a/tests/configs/test-use-variant.yaml b/tests/configs/test-use-variant.yaml new file mode 100644 index 0000000..ba47596 --- /dev/null +++ b/tests/configs/test-use-variant.yaml @@ -0,0 +1,20 @@ +id: tvariant +title: "Test Variant" +github_org: INCATools +repo: ontology-development-kit +import_group: + use_base_merging: true + exclude_iri_patterns: + - + - + slme_individuals: exclude + mirror_max_time_download: 400 + products: + - id: ro + mirror_from: https://raw.githubusercontent.com/INCATools/ontology-development-kit/master/tests/ontologies/ro.owl + - id: pato + use_variant: base + # This test cannot be easily replaced, because use_variant and custom URL dont mix + - id: pr + make_base: true + mirror_from: https://raw.githubusercontent.com/INCATools/ontology-development-kit/master/tests/ontologies/pr_slim.owl