-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
124 additions
and
84 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,60 +1,95 @@ | ||
{ | ||
"$schema": "http://json-schema.org/draft-07/schema", | ||
"title": "Test", | ||
"type": "object", | ||
"properties": { | ||
"name": { | ||
"title": "name", | ||
"description": "The name of the test.", | ||
"term": "schema:hello", | ||
"type": "string" | ||
}, | ||
"number": { | ||
"title": "number", | ||
"term": "schema:one", | ||
"type": "number" | ||
}, | ||
"test2": { | ||
"term": "schema:something", | ||
"type": "array", | ||
"items": { | ||
"$ref": "#/definitions/Test2" | ||
} | ||
}, | ||
"ontology": { | ||
"title": "ontology", | ||
"$ref": "#/definitions/Ontology" | ||
} | ||
}, | ||
"definitions": { | ||
"Ontology": { | ||
"title": "Ontology", | ||
"type": "string", | ||
"enum": [ | ||
"https://www.evidenceontology.org/term/", | ||
"https://amigo.geneontology.org/amigo/term/", | ||
"http://semanticscience.org/resource/" | ||
] | ||
}, | ||
"Test2": { | ||
"title": "Test2", | ||
"type": "object", | ||
"properties": { | ||
"names": { | ||
"title": "names", | ||
"term": "schema:hello", | ||
"type": "array", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"number": { | ||
"title": "number", | ||
"term": "schema:one", | ||
"type": "number", | ||
"minimum": 0.0 | ||
## This is a generated file. Do not modify it manually! | ||
|
||
from __future__ import annotations | ||
from dataclasses import dataclass, field | ||
from dataclasses_json import config, dataclass_json | ||
from typing import List, Optional | ||
from enum import Enum | ||
from uuid import uuid4 | ||
from datetime import date, datetime | ||
|
||
|
||
@dataclass_json | ||
@dataclass | ||
class Test: | ||
name: str | ||
number: float = 1.0 | ||
test2: List[Test2] = field(default_factory=list) | ||
ontology: Optional[Ontology] = None | ||
|
||
# JSON-LD fields | ||
id: str = field( | ||
metadata=config(field_name="@id"), | ||
default_factory=lambda: "tst:Test/" + str(uuid4()) | ||
) | ||
__type__: list[str] = field( | ||
metadata=config(field_name="@type"), | ||
default_factory = lambda: [ | ||
"tst:Test", | ||
], | ||
) | ||
__context__: dict[str, str | dict] = field( | ||
metadata=config(field_name="@context"), | ||
default_factory = lambda: { | ||
"tst": "https://www.github.com/my/repo/", | ||
"schema": "http://schema.org/", | ||
"name": { | ||
"@id": "schema:hello", | ||
"@type": "@id", | ||
}, | ||
"number": "schema:one", | ||
"test2": "schema:something", | ||
} | ||
} | ||
} | ||
} | ||
} | ||
) | ||
|
||
|
||
def add_to_test2( | ||
self, | ||
names: List[str]= [], | ||
number: Optional[float]= None, | ||
**kwargs, | ||
): | ||
params = { | ||
"names": names, | ||
"number": number | ||
} | ||
|
||
self.test2.append( | ||
Test2(**params) | ||
) | ||
|
||
return self.test2[-1] | ||
|
||
|
||
@dataclass_json | ||
@dataclass | ||
class Test2: | ||
names: List[str] = field(default_factory=list) | ||
number: Optional[float] = None | ||
|
||
# JSON-LD fields | ||
id: str = field( | ||
metadata=config(field_name="@id"), | ||
default_factory=lambda: "tst:Test2/" + str(uuid4()) | ||
) | ||
__type__: list[str] = field( | ||
metadata=config(field_name="@type"), | ||
default_factory = lambda: [ | ||
"tst:Test2", | ||
], | ||
) | ||
__context__: dict[str, str | dict] = field( | ||
metadata=config(field_name="@context"), | ||
default_factory = lambda: { | ||
"tst": "https://www.github.com/my/repo/", | ||
"schema": "http://schema.org/", | ||
"names": "schema:hello", | ||
"number": "schema:one", | ||
} | ||
) | ||
|
||
|
||
class Ontology(Enum): | ||
ECO = "https://www.evidenceontology.org/term/" | ||
GO = "https://amigo.geneontology.org/amigo/term/" | ||
SIO = "http://semanticscience.org/resource/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters