You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+40Lines changed: 40 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,37 @@ Models based on Pydantic provide deserialize with basic validation, serialize, a
6
6
7
7
Allows for easy FastAPI standup.
8
8
9
+
## TRAPI versions
10
+
11
+
`translator_tom` provides models for multiple TRAPI versions. When importing directly from `translator_tom`, you automatically import models for the latest version.
12
+
13
+
```python
14
+
from translator_tom import Response # TRAPI 2.0 (latest)
15
+
from translator_tom.model_dicts import ResponseDict # TRAPI 2.0 (latest)
16
+
```
17
+
18
+
To pin a specific version, import it from its version subpackage:
19
+
20
+
```python
21
+
from translator_tom.v2_0 import Response # TRAPI 2.0
22
+
from translator_tom.v1_6 import Response # TRAPI 1.6
23
+
from translator_tom.v1_6.model_dicts import ResponseDict
24
+
```
25
+
26
+
Each version has the same general API: models, model_dicts, diff, semantic validation (WIP). Some items are version-agnostic (Biolink, CURIEs, `TOMBase`, etc.) and shared between the two (`translator_tom.utils`).
27
+
28
+
### Converting TRAPI versions
29
+
30
+
The TRAPI 2.0 package provides a utility for converting 1.6 models to 2.0 models:
31
+
32
+
```python
33
+
from translator_tom import up_version
34
+
35
+
my_v1_response =...# Some TRAPI 1.6 response
36
+
37
+
my_v2_response = up_version(my_v1_response)
38
+
```
39
+
9
40
## Model Usage
10
41
11
42
The main ways you interact with a Model are as follows:
@@ -344,6 +375,15 @@ This returns a list of warnings and errors with clear descriptions and tuples de
344
375
> [!WARNING]
345
376
> This feature is WIP and does not do every bit of semantic validation you might expect.
346
377
378
+
## Scripts
379
+
380
+
TOM provides some module-level scripts, for your convenience:
381
+
382
+
-`tom-parse`: Parse a given JSON into a given TOM model to check that it parses.
383
+
-`tom-validate`: Run semantic validation (WIP) against a given JSON/TOM model.
384
+
-`tom-up-version`: Upgrade a TRAPI 1.6 JSON to TRAPI 2.0.
385
+
-`tom-diff`: Diff two JSONs of a given TOM model.
386
+
347
387
## Design Decisions
348
388
349
389
There are a view caveats to using TOM, listed below:
0 commit comments