Skip to content

Commit 617433b

Browse files
committed
Properly resolve nested imports in JSONSchema importer
Test were failing while importing the HCA project after updating linkml-runtime to 1.9.x because the schema for the file core ontology was trying to import this file: tests/outputs/hca/core/file/module/ontology/file_content_ontology.yaml when it was trying to import this file: tests/outputs/hca/module/ontology/file_content_ontology.yaml This was happening because it was importing "module/ontology/file_content_ontology.yaml" and expected to be importing from the root of the project. This was the behavior of linkml runtime before 1.9.x, but that changed in this PR, which was merged and released with 1.9.1: <linkml/linkml-runtime#368> The fix is to make this a relative path-- that is, the value `../../module/ontology/file_content_ontology.yaml`. Luckily, the value of the relative prefix was already in the code! It just wasn't being appended to the module path. This might have been an oversight that wasn't added since the code worked.
1 parent ab7ebbe commit 617433b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

schema_automator/importers/jsonschema_import_engine.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def import_project(self, import_directory: str, export_directory: str, match_suf
101101
if rng in schema.classes:
102102
# no need to self-import
103103
continue
104-
import_module_name = class_name_to_module_map[rng]
104+
import_module_name = rel + class_name_to_module_map[rng]
105105
if import_module_name not in schema.imports:
106106
logging.info(f"Adding import to {import_module_name} in {schema.name} for {rng}")
107107
schema.imports.append(import_module_name)

0 commit comments

Comments
 (0)