Skip to content

Commit 965c71c

Browse files
Checkpoint commit with test cases
1 parent c6943e4 commit 965c71c

File tree

17 files changed

+417
-0
lines changed

17 files changed

+417
-0
lines changed

linkml_runtime/utils/schemaview.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import pdb
23
import uuid
34
import logging
45
import collections
@@ -231,6 +232,7 @@ def imports_closure(self, imports: bool = True, traverse=True, inject_metadata=T
231232
self.schema_map[sn] = imported_schema
232233
s = self.schema_map[sn]
233234
if sn not in closure:
235+
#closure.insert(0, sn)
234236
closure.append(sn)
235237
for i in s.imports:
236238
if i not in visited:
@@ -434,6 +436,7 @@ def all_elements(self, imports=True) -> Dict[ElementName, Element]:
434436
def _get_dict(self, slot_name: str, imports=True) -> Dict:
435437
schemas = self.all_schema(imports)
436438
d = {}
439+
# pdb.set_trace()
437440
# iterate through all schemas and merge the list together
438441
for s in schemas:
439442
# get the value of element name from the schema, if empty, return empty dictionary.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
A tree of imports like:
2+
3+
```
4+
main
5+
|- linkml:types
6+
|- s1
7+
| |- s1_1
8+
| |- s1_2
9+
| |- s1_2_1
10+
| |- s1_2_1_1
11+
| |- s1_2_1_1_1
12+
| |- s1_2_1_1_2
13+
|- s2
14+
| |- s2_1
15+
| |- s2_2
16+
|- s3
17+
|- s3_1
18+
|- s3_2
19+
```
20+
21+
This is used to test SchemaView's logic for complex import hierarchies,
22+
eg.
23+
- overrides
24+
- imports closure completeness
25+
- (at some point) monotonicity
26+
- etc.
27+
28+
Currently, each schema...
29+
- Contains one `Main` class with a value whose default is overridden to indicate which module defined it, this is used to test overrides.
30+
- Contains a class like `S2` that carries the name of the module to ensure that unique classes are gotten from the whole tree
31+
- Each node in the tree outwards from `main` will carry the 'special classes' from the parents, overriding them as with `main` to
32+
get a more detailed picture of override order: eg. `s1_2_1` will also define `S1_2` and override its `ifabsent` field,
33+
which `S1_2` should override since it's the importing schema.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
id: main
2+
name: main
3+
title: main
4+
imports:
5+
- linkml:types
6+
- s1
7+
- s2
8+
- s3
9+
classes:
10+
Main:
11+
description: "The class we use to test overrides on imports!"
12+
attributes:
13+
value:
14+
range: string
15+
ifabsent: "Main"
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
id: s1
2+
name: s1
3+
title: s1
4+
imports:
5+
- linkml:types
6+
- s1_1
7+
- s1_2
8+
classes:
9+
Main:
10+
description: "The class we use to test overrides on imports!"
11+
attributes:
12+
value:
13+
range: string
14+
ifabsent: "S1"
15+
S1:
16+
description: "A class from one of the imported classes!"
17+
attributes:
18+
value:
19+
range: string
20+
ifabsent: "S1"
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
id: s1_1
2+
name: s1_1
3+
title: s1_1
4+
imports:
5+
- linkml:types
6+
classes:
7+
Main:
8+
description: "The class we use to test overrides on imports!"
9+
attributes:
10+
value:
11+
range: string
12+
ifabsent: "S1_1"
13+
S1:
14+
description: "A class from one of the imported classes!"
15+
attributes:
16+
value:
17+
range: string
18+
ifabsent: "S1_1"
19+
S1_1:
20+
description: "A class from one of the imported classes!"
21+
attributes:
22+
value:
23+
range: string
24+
ifabsent: "S1_1"
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
id: s1_2
2+
name: s1_2
3+
title: s1_2
4+
imports:
5+
- linkml:types
6+
- s1_2_1
7+
classes:
8+
Main:
9+
description: "The class we use to test overrides on imports!"
10+
attributes:
11+
value:
12+
range: string
13+
ifabsent: "S1_2"
14+
S1:
15+
description: "A class from one of the imported classes!"
16+
attributes:
17+
value:
18+
range: string
19+
ifabsent: "S1_2"
20+
S1_2:
21+
description: "A class from one of the imported classes!"
22+
attributes:
23+
value:
24+
range: string
25+
ifabsent: "S1_2"
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
id: s1_2_1
2+
name: s1_2_1
3+
title: s1_2_1
4+
imports:
5+
- linkml:types
6+
- s1_2_1_1
7+
classes:
8+
Main:
9+
description: "The class we use to test overrides on imports!"
10+
attributes:
11+
value:
12+
range: string
13+
ifabsent: "S1_2_1"
14+
S1:
15+
description: "A class from one of the imported classes!"
16+
attributes:
17+
value:
18+
range: string
19+
ifabsent: "S1_2_1"
20+
S1_2:
21+
description: "A class from one of the imported classes!"
22+
attributes:
23+
value:
24+
range: string
25+
ifabsent: "S1_2_1"
26+
S1_2_1:
27+
description: "A class from one of the imported classes!"
28+
attributes:
29+
value:
30+
range: string
31+
ifabsent: "S1_2_1"
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
id: s1_2_1_1
2+
name: s1_2_1_1
3+
title: s1_2_1_1
4+
imports:
5+
- linkml:types
6+
- s1_2_1_1_1
7+
- s1_2_1_1_2
8+
classes:
9+
Main:
10+
description: "The class we use to test overrides on imports!"
11+
attributes:
12+
value:
13+
range: string
14+
ifabsent: "S1_2_1_1"
15+
S1:
16+
description: "A class from one of the imported classes!"
17+
attributes:
18+
value:
19+
range: string
20+
ifabsent: "S1_2_1_1"
21+
S1_2:
22+
description: "A class from one of the imported classes!"
23+
attributes:
24+
value:
25+
range: string
26+
ifabsent: "S1_2_1_1"
27+
S1_2_1:
28+
description: "A class from one of the imported classes!"
29+
attributes:
30+
value:
31+
range: string
32+
ifabsent: "S1_2_1_1"
33+
S1_2_1_1:
34+
description: "A class from one of the imported classes!"
35+
attributes:
36+
value:
37+
range: string
38+
ifabsent: "S1_2_1_1"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
id: s1_2_1_1_1
2+
name: s1_2_1_1_1
3+
title: s1_2_1_1_1
4+
imports:
5+
- linkml:types
6+
classes:
7+
Main:
8+
description: "The class we use to test overrides on imports!"
9+
attributes:
10+
value:
11+
range: string
12+
ifabsent: "S1_2_1_1_1"
13+
S1:
14+
description: "A class from one of the imported classes!"
15+
attributes:
16+
value:
17+
range: string
18+
ifabsent: "S1_2_1_1_1"
19+
S1_2:
20+
description: "A class from one of the imported classes!"
21+
attributes:
22+
value:
23+
range: string
24+
ifabsent: "S1_2_1_1_1"
25+
S1_2_1:
26+
description: "A class from one of the imported classes!"
27+
attributes:
28+
value:
29+
range: string
30+
ifabsent: "S1_2_1_1_1"
31+
S1_2_1_1:
32+
description: "A class from one of the imported classes!"
33+
attributes:
34+
value:
35+
range: string
36+
ifabsent: "S1_2_1_1_1"
37+
S1_2_1_1_1:
38+
description: "A class from one of the imported classes!"
39+
attributes:
40+
value:
41+
range: string
42+
ifabsent: "S1_2_1_1_1"
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
id: s1_2_1_1_2
2+
name: s1_2_1_1_2
3+
title: s1_2_1_1_2
4+
imports:
5+
- linkml:types
6+
classes:
7+
Main:
8+
description: "The class we use to test overrides on imports!"
9+
attributes:
10+
value:
11+
range: string
12+
ifabsent: "S1_2_1_1_2"
13+
S1:
14+
description: "A class from one of the imported classes!"
15+
attributes:
16+
value:
17+
range: string
18+
ifabsent: "S1_2_1_1_2"
19+
S1_2:
20+
description: "A class from one of the imported classes!"
21+
attributes:
22+
value:
23+
range: string
24+
ifabsent: "S1_2_1_1_2"
25+
S1_2_1:
26+
description: "A class from one of the imported classes!"
27+
attributes:
28+
value:
29+
range: string
30+
ifabsent: "S1_2_1_1_2"
31+
S1_2_1_1:
32+
description: "A class from one of the imported classes!"
33+
attributes:
34+
value:
35+
range: string
36+
ifabsent: "S1_2_1_1_2"
37+
S1_2_1_1_2:
38+
description: "A class from one of the imported classes!"
39+
attributes:
40+
value:
41+
range: string
42+
ifabsent: "S1_2_1_1_2"

0 commit comments

Comments
 (0)