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
{{ message }}
Repository navigation
Commit ca8ff6a
Browse filesBrowse the repository at this point in the historyBrowse files
Copy file name to clipboardExpand all lines: ImplementationGuidance/MigrationGuides/MigrationAndImplementationGuide2-0.md
+35-26Lines changed: 35 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
This guide lays out the format and functionality changes for queries and responses in TRAPI 2.0.0 (compared to 1.6.0-beta).
4
4
5
-
TRAPI 2.0 includes many breaking changes, new/reintroduced functionality, and format changes designed to slim down TRAPI messages. This guide provides before-after examples to illustrate the more complex changes and a list for the other important changes (mainly formatting).
5
+
TRAPI 2.0 includes many breaking changes, new/reintroduced functionality, and format changes designed to slim down TRAPI messages. This guide provides before-after examples to illustrate the more complex changes and a list for the other important changes (mainly formatting).
6
6
7
7
8
8
## Changes
@@ -12,7 +12,7 @@ TRAPI 2.0 includes many breaking changes, new/reintroduced functionality, and fo
12
12
13
13
#### BEFORE
14
14
15
-
In 1.6.0-beta, you could include `attribute_constraints` and `qualifier_constraints` on QEdges. If you wanted to only include or exclude specific knowledge_level/agent_type (KL/AT) values, you'd use `attribute_constraints` because KL/AT are stored in Edge `attributes`. If you wanted to only include or exclude specific sources (infores), you may have used `attribute_constraints`. BUT this format no longer makes sense after we moved source info out of Edge `attributes` into its own top-level property `sources` several versions ago (1.4.0-beta).
15
+
In 1.6.0-beta, you could include `attribute_constraints` and `qualifier_constraints` on QEdges. If you wanted to only include or exclude specific knowledge_level/agent_type (KL/AT) values, you'd use `attribute_constraints` because KL/AT are stored in Edge `attributes`. If you wanted to only include or exclude specific sources (infores), you may have used `attribute_constraints`. BUT this format no longer makes sense after we moved source info out of Edge `attributes` into its own top-level property `sources` several versions ago (1.4.0-beta).
16
16
17
17
<details><summary>A QEdge in 1.6.0-beta with all of these constraints would look like this (click to expand)
18
18
</summary>
@@ -57,22 +57,22 @@ In 1.6.0-beta, you could include `attribute_constraints` and `qualifier_constrai
57
57
```
58
58
59
59
</p>
60
-
</details>
60
+
</details>
61
61
62
62
#### AFTER
63
63
64
64
In 2.0, there is instead one property on a QEdge, `constraints`, that holds all the types of constraints, organized by key. There are 5 keys currently specified:
65
65
66
-
*`knowledge_level`: we moved KL/AT out of Edge `attributes` and into its own top-level properties on an Edge (see #4), so they need corresponding separate constraints. This constraint is an object with two keys: `behavior` (`ALLOW` or `DENY`) and `values` (an array of strings).
67
-
*`ALLOW` means "ANY (at least 1) of the `values` MUST be in the matched Edge's corresponding property".
68
-
*`DENY` means "ALL of the `values` MUST NOT be in the matched Edge's corresponding property".
66
+
*`knowledge_level`: we moved KL/AT out of Edge `attributes` and into its own top-level properties on an Edge (see #4), so they need corresponding separate constraints. This constraint is an object with two keys: `behavior` (`ALLOW` or `DENY`) and `values` (an array of strings).
67
+
*`ALLOW` means "ANY (at least 1) of the `values` MUST be in the matched Edge's corresponding property".
68
+
*`DENY` means "ALL of the `values` MUST NOT be in the matched Edge's corresponding property".
69
69
*`agent_type`: see above (KL)
70
70
* FYI: if a specified value has descendants (ex: `automated_agent`), the tool MUST treat those descendants (ex: `text_mining_agent`, etc.) as if they were included in the `values` array (i.e. "hierarchy expansion").
71
-
*`sources`: this constrains the Edge `sources`. It has the same keys as KL/AT (`behavior`, `values`) plus the optional `primary_only` (if true, the constraint ONLY applies to the `primary_knowledge_source`).
71
+
*`sources`: this constrains the Edge `sources`. It has the same keys as KL/AT (`behavior`, `values`) plus the optional `primary_only` (if true, the constraint ONLY applies to the `primary_knowledge_source`).
72
72
*`attributes`: minItems 1 and `name` no longer required, otherwise the same as previous `attribute_constraints`
73
-
*`qualifiers`: simplified format to an array of objects but preserved previous behavior. Each object represents a qualifier-set, and multiple objects/sets have an `OR` relationship. Within an object, the keys are the "qualifier-type-ids" and their values are the "qualifier values". Multiple key/value pairs in one object/set have an `AND` relationship.
73
+
*`qualifiers`: simplified format to an array of objects but preserved previous behavior. Each object represents a qualifier-set, and multiple objects/sets have an `OR` relationship. Within an object, the keys are the "qualifier-type-ids" and their values are the "qualifier values". Multiple key/value pairs in one object/set have an `AND` relationship.
74
74
75
-
**NOTE on SUBCLASSING**: we haven't decided yet how QEdge constraints work with subclassing. For now, QEdge constraints should only apply to the bound Edges (constructed in subclassing cases), NOT to the bound Edge's support_graph edges. QNode constraints also has this ambiguity/confusion with subclassing.
75
+
**NOTE on SUBCLASSING**: we haven't decided yet how QEdge constraints work with subclassing. For now, QEdge constraints should only apply to the bound Edges (constructed in subclassing cases), NOT to the bound Edge's support_graph edges. QNode constraints also has this ambiguity/confusion with subclassing.
76
76
77
77
<details><summary>The same QEdge in 2.0 would look like this (click to expand)</summary>
78
78
<p>
@@ -108,7 +108,7 @@ In 2.0, there is instead one property on a QEdge, `constraints`, that holds all
108
108
```
109
109
110
110
</p>
111
-
</details>
111
+
</details>
112
112
113
113
<br>
114
114
@@ -152,16 +152,16 @@ In 2.0, there is instead one property on a QEdge, `constraints`, that holds all
152
152
```
153
153
154
154
</p>
155
-
</details>
155
+
</details>
156
156
157
157
158
158
### 2. New Query/Response Parameters
159
159
160
160
#### BEFORE
161
161
162
-
In 1.6.0-beta, `log_level` and `bypass_cache` were top-level properties in `Query` and `AsyncQuery`.
162
+
In 1.6.0-beta, `log_level` and `bypass_cache` were top-level properties in `Query` and `AsyncQuery`.
163
163
164
-
A query with them would look like this:
164
+
A query with them would look like this:
165
165
166
166
```json
167
167
{
@@ -175,7 +175,7 @@ A query with them would look like this:
175
175
176
176
In 2.0, these are moved under a new top-level property `parameters` (their behavior is otherwise kept the same). `parameters` also includes a new parameter/property `timeout`, so a client can state how long they will wait for a response.
177
177
178
-
Tools can also use the new `parameters` property to hold undefined query-time parameters that affect overall behavior of the server in query execution, like specifying data-tier in the Translator ecosystem.
178
+
Tools can also use the new `parameters` property to hold undefined query-time parameters that affect overall behavior of the server in query execution, like specifying data-tier in the Translator ecosystem.
179
179
180
180
`parameters` has also been added to `Response`; the server receiving a Query/AsyncQuery with `parameters` MUST echo them in its Response. If there is a conflict between the `parameters` and the server's capabilities, the server SHOULD return HTTP `409`.
181
181
@@ -196,9 +196,9 @@ A query with the same parameters (plus timeout and custom data-tier) would look
196
196
197
197
### 3. Binding Structure Changes (Node/Edge/Path)
198
198
199
-
#### BEFORE
199
+
#### BEFORE
200
200
201
-
In 1.6.0-beta, the 3 kinds of bindings have this format:
201
+
In 1.6.0-beta, the 3 kinds of bindings have this format:
202
202
203
203
```json
204
204
...
@@ -259,7 +259,7 @@ Details:
259
259
```
260
260
261
261
</p>
262
-
</details>
262
+
</details>
263
263
264
264
<details><summary>Example result with node/path bindings</summary>
265
265
<p>
@@ -296,7 +296,7 @@ Details:
296
296
```
297
297
298
298
</p>
299
-
</details>
299
+
</details>
300
300
301
301
#### AFTER
302
302
@@ -316,7 +316,7 @@ In 2.0, the format is simplified:
316
316
```
317
317
318
318
Changes:
319
-
*`<node/edge/path>_bindings` are now `minProperties: 1` (i.e. when these fields are present, they MUST contain data)
319
+
*`<node/edge/path>_bindings` are now `minProperties: 1` (i.e. when these fields are present, they MUST contain data)
320
320
*`ids` arrays are `minItems: 1` (this property is still required)
321
321
*`attributes` were removed from NodeBinding/EdgeBinding (were never used, empty arrays bloated responses)
322
322
*`query_id` was removed from NodeBinding (obsolete with the current subclassing behavior)
@@ -380,9 +380,9 @@ Changes:
380
380
</details>
381
381
382
382
383
-
### 4. KL/AT turned into top-level Edge properties, now required
383
+
### 4. KL/AT turned into top-level Edge properties, now required
384
384
385
-
In 1.6.0-beta, `knowledge_level` and `agent_type` are stored in `Edge.attributes`, which is not a required property. However, for several years the Translator Consortium has actually required KL/AT on Edges.
385
+
In 1.6.0-beta, `knowledge_level` and `agent_type` are stored in `Edge.attributes`, which is not a required property. However, for several years the Translator Consortium has actually required KL/AT on Edges.
386
386
387
387
In 2.0, they are now top-level properties that are required on an `Edge`. The way to constrain them in queries has also changed (own keys under `QEdge.constraints`) - see #1 for details.
388
388
@@ -402,7 +402,7 @@ Example snippet of an `Edge` in 2.0, showing the top-level KL/AT:
402
402
403
403
### 5. Add `COLLATE` option to `QNode.set_interpretation`
404
404
405
-
In 2.0, `COLLATE` is an option that is only allowed on QNodes with no `ids` set and indicates that multiple matching nodes MUST be collated into a single Result, rather than put into separate Results. This restores some of the `QNode.is_set` behavior that was removed in 1.5.0 (don't confuse with **Node**.is_set!).
405
+
In 2.0, `COLLATE` is an option that is only allowed on QNodes with no `ids` set and indicates that multiple matching nodes MUST be collated into a single Result, rather than put into separate Results. This restores some of the `QNode.is_set` behavior that was removed in 1.5.0 (don't confuse with **Node**.is_set!).
406
406
407
407
When `COLLATE` is set, `QNode.member_ids` must not be used.
408
408
@@ -421,12 +421,12 @@ Drug A -interacts_with→ Gene B -causes→ Diabetes
421
421
↘interacts_with→ Gene C -causes↗
422
422
```
423
423
424
-
The `node_bindings.[Gene QNode].ids` would include Genes A, B, and C. The edge_bindings would be collated accordingly.
424
+
The `node_bindings.[Gene QNode].ids` would include Genes A, B, and C. The edge_bindings would be collated accordingly.
425
425
426
426
427
427
### 6. `null` is no longer a valid value in queries and responses
428
428
429
-
To convey "no data", instead omit the field or use an empty array/object if the schema allows (doesn't set `minProperties`/`minItems`). However, unless the field's description explicitly states that the empty array/object MUST be used, we strongly encourage omitting fields to reduce needless bloat.
429
+
To convey "no data", instead omit the field or use an empty array/object if the schema allows (doesn't set `minProperties`/`minItems`). However, unless the field's description explicitly states that the empty array/object MUST be used, we strongly encourage omitting fields to reduce needless bloat.
430
430
431
431
Examples:
432
432
*`Message.knowledge_graph` MUST be omitted, not be set to `null`, when there is no data (ex: a query, or a response with no data found).
@@ -440,7 +440,7 @@ For many array and object properties, `minItems`/`minProperties` was set to 1. T
440
440
441
441
### 8. `AuxiliaryGraph.attributes` was removed
442
442
443
-
It was previously required, but never used and its empty arrays bloated responses. Additional undefined properties are still allowed in `AuxiliaryGraph` objects.
443
+
It was previously required, but never used and its empty arrays bloated responses. Additional undefined properties are still allowed in `AuxiliaryGraph` objects.
444
444
445
445
446
446
### 9. Properties changed to not-required:
@@ -457,14 +457,23 @@ These properties were changed to not required:
457
457
458
458
Analysis allows edge_bindings and path_bindings to be present together (for experimental use only, small change introduced when simplifying schema classes).
459
459
460
+
### 11. MetaEdges can now advertise KL/AT and sources
461
+
462
+
Three properties were added to `MetaEdge`:
463
+
*`knowledge_levels`: Should contain all relevant knowledge_level values that the meta edge covers
464
+
*`agent_types`: Should contain all relevant agent_type values that the meta edge covers
465
+
*`sources`: Should contain all the source inforeses that contribute to this meta edge, regardless of role.
466
+
May omit aggregator resource_ids created by the service producing the meta knowledge graph.
467
+
468
+
These properties allow a service to advertise filterable values for the new `QEdge` KL/AT and source filtering.
460
469
461
470
## Full Examples
462
471
463
472
This is an example of a 1.6.0-beta Response "transformed" into 2.0 (includes query_graph/parameters). Note that the 2.0 query/response has 2 functional differences:
464
473
* COLLATE was set on the intermediate QNode
465
474
* new parameters were added (timeout, custom tiers)
466
475
467
-
These examples show the main changes 1-5 (#1: all types of constraints, #5: COLLATE in 2.0 only) and the other changes 1,2, and 4.
476
+
These examples show the main changes 1-5 (#1: all types of constraints, #5: COLLATE in 2.0 only) and the other changes 1,2, and 4.
0 commit comments