Skip to content

Commit 1adb09d

Browse files
authored
closes #63 (#64)
1 parent 641dbb7 commit 1adb09d

12 files changed

Lines changed: 5044 additions & 1289 deletions

File tree

README.md

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ And you can skip the backup (simply edit in place):
2828
python -m opencloning_linkml.migrations.migrate file.json --no-backup
2929
```
3030

31-
32-
3331
## Developer Documentation
3432

3533
The python package can be installed from PyPI:
@@ -45,6 +43,23 @@ Use the `make` command to generate project artefacts:
4543
* `make deploy`: deploys site
4644
</details>
4745

46+
### Creating a migration
47+
48+
To add a migration from version `X.Y.Z` to a new version `A.B.C`, follow these steps:
49+
50+
1. **Archive the current model**: Save a copy of the current Pydantic model to `src/opencloning_linkml/migrations/model_archive/vA_B_C.py`. This file should contain the complete model classes for version `A.B.C` (typically copied from `src/opencloning_linkml/datamodel/_models.py` after generating the new version).
51+
52+
2. **Create the transformation file**: Create a new file `src/opencloning_linkml/migrations/transformations/vX_Y_Z_to_vA_B_C.py` with a migration function
53+
54+
3. **Register the migration**: Add the migration to `src/opencloning_linkml/migrations/__init__.py`:
55+
- Import the migration function: `from .transformations.vX_Y_Z_to_vA_B_C import migrate_X_Y_Z_to_A_B_C`
56+
- Add it to the `load_migrations()` return dictionary: `("X.Y.Z", "A.B.C"): migrate_X_Y_Z_to_A_B_C`
57+
58+
4. **Add a test**: Add a test to `tests/test_migration.py` to ensure the migration works as expected.
59+
60+
**Example**: See `v0_2_8_to_v0_2_9.py` for a simple transformation example, or `v0_2_9_to_v_0_4_0.py` for a more complex migration with ID remapping and structural changes.
61+
62+
4863
## Credits
4964

5065
This project was made with
1 Byte
Binary file not shown.

project/jsonld/opencloning_linkml.context.jsonld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"comments": {
33
"description": "Auto generated by LinkML jsonld context generator",
4-
"generation_date": "2025-10-20T16:29:26",
4+
"generation_date": "2025-11-17T18:53:28",
55
"source": "opencloning_linkml.yaml"
66
},
77
"@context": {

project/jsonld/opencloning_linkml.jsonld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3542,9 +3542,9 @@
35423542
],
35433543
"metamodel_version": "1.7.0",
35443544
"source_file": "opencloning_linkml.yaml",
3545-
"source_file_date": "2025-10-20T16:11:45",
3545+
"source_file_date": "2025-11-17T18:34:01",
35463546
"source_file_size": 26051,
3547-
"generation_date": "2025-10-20T16:29:26",
3547+
"generation_date": "2025-11-17T18:53:29",
35483548
"@type": "SchemaDefinition",
35493549
"@context": [
35503550
"project/jsonld/opencloning_linkml.context.jsonld",

project/owl/opencloning_linkml.owl.ttl

Lines changed: 453 additions & 453 deletions
Large diffs are not rendered by default.

project/python/opencloning_linkml.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Auto generated from opencloning_linkml.yaml by pythongen.py version: 0.0.1
2-
# Generation date: 2025-10-20T16:29:27
2+
# Generation date: 2025-11-17T18:53:30
33
# Schema: OpenCloning_LinkML
44
#
55
# id: https://opencloning.github.io/OpenCloning_LinkML

project/shacl/opencloning_linkml.shacl.ttl

Lines changed: 830 additions & 830 deletions
Large diffs are not rendered by default.

src/opencloning_linkml/migrations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,13 @@ def load_migrations() -> MigrationDict:
1919
from .transformations.v0_2_6_1_to_v_0_2_8 import migrate_0_2_6_1_to_0_2_8 # noqa: F401
2020
from .transformations.v0_2_8_to_v0_2_9 import migrate_0_2_8_to_0_2_9 # noqa: F401
2121
from .transformations.v0_2_9_to_v_0_4_0 import migrate_0_2_9_to_0_4_0 # noqa: F401
22+
from .transformations.v0_4_0_to_v0_4_6 import migrate_0_4_0_to_0_4_6 # noqa: F401
2223

2324
return {
2425
("0.2.6.1", "0.2.8"): migrate_0_2_6_1_to_0_2_8,
2526
("0.2.8", "0.2.9"): migrate_0_2_8_to_0_2_9,
2627
("0.2.9", "0.4.0"): migrate_0_2_9_to_0_4_0,
28+
("0.4.0", "0.4.6"): migrate_0_4_0_to_0_4_6,
2729
}
2830

2931

0 commit comments

Comments
 (0)