|
11 | 11 | import yaml
|
12 | 12 |
|
13 | 13 | from pipeline.translator import LinkMLClassBuilder, LinkMLSlotBuilder, LinkMLEnumBuilder
|
14 |
| -from pipeline.utils import clone_sources, SchemaLoader, InstanceLoader, get_short_name |
| 14 | +from pipeline.utils import clone_sources, SchemaLoader, InstanceLoader, get_short_name, get_short_namespace |
15 | 15 |
|
16 | 16 |
|
17 | 17 | terms_as_enums = True
|
|
43 | 43 |
|
44 | 44 | for schema_version in schema_loader.get_schema_versions():
|
45 | 45 | imports = []
|
| 46 | + short_namespace = get_short_namespace(schema_loader.get_namespaces_version(schema_version)['props']) |
46 | 47 |
|
47 | 48 | # Step 3 - find all involved schemas for the current version
|
48 | 49 | schemas_file_paths = schema_loader.find_schemas(schema_version)
|
|
98 | 99 | ).build()
|
99 | 100 | linkml_classes[module].append(linkml_class)
|
100 | 101 | enum_schema = {
|
101 |
| - "id": f"https://openminds.ebrains.eu/schemas/latest/enums?format=linkml", |
| 102 | + "id": f"{short_namespace}/schemas/latest/enums?format=linkml", |
102 | 103 | "name": "openMINDS-enums",
|
103 | 104 | "title": f'OpenMINDS instance library as LinkML enums, version "{schema_version}"',
|
104 | 105 | "description": f'Enums for the LinkML representation of openMINDS metadata framework, version "{schema_version}"',
|
105 | 106 | "license": "https://spdx.org/licenses/MIT.html",
|
106 | 107 | "prefixes": {
|
107 | 108 | "linkml": "https://w3id.org/linkml/",
|
108 | 109 | "schema": "http://schema.org/",
|
109 |
| - "omi": "https://openminds.ebrains.eu", |
| 110 | + "omi": f"{short_namespace}", |
110 | 111 | },
|
111 | 112 | "default_prefix": "omi",
|
112 | 113 | "imports": ["linkml:types"] + linkml_enum_imports,
|
|
122 | 123 | )
|
123 | 124 | os.makedirs(os.path.dirname(target_file), exist_ok=True)
|
124 | 125 | module_schema = {
|
125 |
| - "id": f"https://openminds.ebrains.eu/schemas/latest/{module_name}?format=linkml", |
| 126 | + "id": f"{short_namespace}/schemas/latest/{module_name}?format=linkml", |
126 | 127 | "name": f"openMINDS-{module_name}",
|
127 | 128 | "title": f'OpenMINDS {module_name} module, version "{schema_version}"',
|
128 | 129 | "description": f'Schemas for the {module_name} module of the openMINDS metadata framework, version "{schema_version}"',
|
|
131 | 132 | "prefixes": {
|
132 | 133 | "linkml": "https://w3id.org/linkml/",
|
133 | 134 | "schema": "http://schema.org/",
|
134 |
| - "omi": "https://openminds.ebrains.eu", |
| 135 | + "omi": f"{short_namespace}", |
135 | 136 | },
|
136 | 137 | "default_prefix": "omi",
|
137 | 138 | "classes": class_list,
|
|
142 | 143 |
|
143 | 144 | # Step 6 - write slots file
|
144 | 145 | slots_schema = {
|
145 |
| - "id": f"https://openminds.ebrains.eu/schemas/latest/slots?format=linkml", |
| 146 | + "id": f"{short_namespace}/schemas/latest/slots?format=linkml", |
146 | 147 | "name": "openMINDS-slots",
|
147 | 148 | "title": f'OpenMINDS properties as LinkML slots, version "{schema_version}"',
|
148 | 149 | "description": f'Slots for the LinkML representation of the openMINDS metadata framework, version "{schema_version}"',
|
149 | 150 | "license": "https://spdx.org/licenses/MIT.html",
|
150 | 151 | "prefixes": {
|
151 | 152 | "linkml": "https://w3id.org/linkml/",
|
152 | 153 | "schema": "http://schema.org/",
|
153 |
| - "omi": "https://openminds.ebrains.eu", |
| 154 | + "omi": f"{short_namespace}", |
154 | 155 | },
|
155 | 156 | "default_prefix": "omi",
|
156 | 157 | "imports": ["linkml:types"],
|
|
164 | 165 |
|
165 | 166 | # Step 7 - write types file
|
166 | 167 | types_metadata = {
|
167 |
| - "id": f"https://openminds.ebrains.eu/schemas/latest/types/?format=linkml", |
| 168 | + "id": f"{short_namespace}/schemas/latest/types/?format=linkml", |
168 | 169 | "name": "openMINDS-types",
|
169 | 170 | "title": f'Types for OpenMINDS version "{schema_version}"',
|
170 | 171 | "description": f'Types for the LinkML representation of the openMINDS metadata framework, version "{schema_version}"',
|
|
173 | 174 | "prefixes": {
|
174 | 175 | "linkml": "https://w3id.org/linkml/",
|
175 | 176 | "schema": "http://schema.org/",
|
176 |
| - "omi": "https://openminds.ebrains.eu", |
| 177 | + "omi": f"{short_namespace}", |
177 | 178 | },
|
178 | 179 | "default_prefix": "omi",
|
179 | 180 | "types": {
|
|
200 | 201 |
|
201 | 202 | # Step 7 - create overall schema file
|
202 | 203 | schema_metadata = {
|
203 |
| - "id": f"https://openminds.ebrains.eu/schemas/latest/?format=linkml", |
| 204 | + "id": f"{short_namespace}/schemas/latest/?format=linkml", |
204 | 205 | "name": "openMINDS",
|
205 | 206 | "title": f'OpenMINDS version "{schema_version}"',
|
206 | 207 | "description": f'The complete collection of schemas for all metadata models of the openMINDS metadata framework, version "{schema_version}"',
|
|
209 | 210 | "prefixes": {
|
210 | 211 | "linkml": "https://w3id.org/linkml/",
|
211 | 212 | "schema": "http://schema.org/",
|
212 |
| - "omi": "https://openminds.ebrains.eu", |
| 213 | + "omi": f"{short_namespace}", |
213 | 214 | },
|
214 | 215 | "default_prefix": "omi",
|
215 | 216 | }
|
|
0 commit comments