Skip to content

Commit ca8ff6a

Browse files
authored
Merge pull request #575 from NCATSTranslator/metakg-updates
Add MetaEdge changes to 2.0 migration guide
2 parents 8f96ad2 + f3840d6 commit ca8ff6a

1 file changed

Lines changed: 35 additions & 26 deletions

File tree

‎ImplementationGuidance/MigrationGuides/MigrationAndImplementationGuide2-0.md‎

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This guide lays out the format and functionality changes for queries and responses in TRAPI 2.0.0 (compared to 1.6.0-beta).
44

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).
66

77

88
## Changes
@@ -12,7 +12,7 @@ TRAPI 2.0 includes many breaking changes, new/reintroduced functionality, and fo
1212

1313
#### BEFORE
1414

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).
1616

1717
<details><summary>A QEdge in 1.6.0-beta with all of these constraints would look like this (click to expand)
1818
</summary>
@@ -57,22 +57,22 @@ In 1.6.0-beta, you could include `attribute_constraints` and `qualifier_constrai
5757
```
5858

5959
</p>
60-
</details>
60+
</details>
6161

6262
#### AFTER
6363

6464
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:
6565

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".
6969
* `agent_type`: see above (KL)
7070
* 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`).
7272
* `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.
7474

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.
7676

7777
<details><summary>The same QEdge in 2.0 would look like this (click to expand)</summary>
7878
<p>
@@ -108,7 +108,7 @@ In 2.0, there is instead one property on a QEdge, `constraints`, that holds all
108108
```
109109

110110
</p>
111-
</details>
111+
</details>
112112

113113
<br>
114114

@@ -152,16 +152,16 @@ In 2.0, there is instead one property on a QEdge, `constraints`, that holds all
152152
```
153153

154154
</p>
155-
</details>
155+
</details>
156156

157157

158158
### 2. New Query/Response Parameters
159159

160160
#### BEFORE
161161

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`.
163163

164-
A query with them would look like this:
164+
A query with them would look like this:
165165

166166
```json
167167
{
@@ -175,7 +175,7 @@ A query with them would look like this:
175175

176176
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.
177177

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.
179179

180180
`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`.
181181

@@ -196,9 +196,9 @@ A query with the same parameters (plus timeout and custom data-tier) would look
196196

197197
### 3. Binding Structure Changes (Node/Edge/Path)
198198

199-
#### BEFORE
199+
#### BEFORE
200200

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:
202202

203203
```json
204204
...
@@ -259,7 +259,7 @@ Details:
259259
```
260260

261261
</p>
262-
</details>
262+
</details>
263263

264264
<details><summary>Example result with node/path bindings</summary>
265265
<p>
@@ -296,7 +296,7 @@ Details:
296296
```
297297

298298
</p>
299-
</details>
299+
</details>
300300

301301
#### AFTER
302302

@@ -316,7 +316,7 @@ In 2.0, the format is simplified:
316316
```
317317

318318
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)
320320
* `ids` arrays are `minItems: 1` (this property is still required)
321321
* `attributes` were removed from NodeBinding/EdgeBinding (were never used, empty arrays bloated responses)
322322
* `query_id` was removed from NodeBinding (obsolete with the current subclassing behavior)
@@ -380,9 +380,9 @@ Changes:
380380
</details>
381381

382382

383-
### 4. KL/AT turned into top-level Edge properties, now required
383+
### 4. KL/AT turned into top-level Edge properties, now required
384384

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.
386386

387387
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.
388388

@@ -402,7 +402,7 @@ Example snippet of an `Edge` in 2.0, showing the top-level KL/AT:
402402

403403
### 5. Add `COLLATE` option to `QNode.set_interpretation`
404404

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!).
406406

407407
When `COLLATE` is set, `QNode.member_ids` must not be used.
408408

@@ -421,12 +421,12 @@ Drug A -interacts_with→ Gene B -causes→ Diabetes
421421
↘interacts_with→ Gene C -causes↗
422422
```
423423

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.
425425

426426

427427
### 6. `null` is no longer a valid value in queries and responses
428428

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.
430430

431431
Examples:
432432
* `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
440440

441441
### 8. `AuxiliaryGraph.attributes` was removed
442442

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.
444444

445445

446446
### 9. Properties changed to not-required:
@@ -457,14 +457,23 @@ These properties were changed to not required:
457457

458458
Analysis allows edge_bindings and path_bindings to be present together (for experimental use only, small change introduced when simplifying schema classes).
459459

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.
460469

461470
## Full Examples
462471

463472
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:
464473
* COLLATE was set on the intermediate QNode
465474
* new parameters were added (timeout, custom tiers)
466475

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.
468477

469478
[1.6.0-beta Response](../DataExamples/1-6_example_response.json)
470479

0 commit comments

Comments
 (0)