Skip to content

Commit

Permalink
Merge pull request #165 from opentargets/ds_consolidating_repo
Browse files Browse the repository at this point in the history
refactor: re-organizing the repo
  • Loading branch information
ireneisdoomed authored Apr 11, 2023
2 parents 0135623 + ef5a0ed commit 537e2ca
Show file tree
Hide file tree
Showing 14 changed files with 551 additions and 476 deletions.
22 changes: 22 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-merge-conflict
- id: check-json
- id: check-yaml
- id: pretty-format-json
args:
- --autofix
- --no-ensure-ascii
- --no-sort-keys

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.22.0
hooks:
- id: check-metaschema
name: "Validating schema definition against draft schemas"
files: ^schemas/.*json$
types: [json]
11 changes: 3 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
language: python
python:
- "3.6"
- "3.8"
install:
- pip install git+https://github.com/Julian/jsonschema.git@v3.0.2#egg=jsonschema
- pip install git+https://github.com/python-jsonschema/check-jsonschema.git@0.20.0#egg=check-jsonschema
- wget -O draft7.json http://json-schema.org/draft-07/schema
- wget -O draft4.json http://json-schema.org/draft-04/schema
script:
- jsonschema -i opentargets_chemical_probe.json draft7.json
- jsonschema -i opentargets_target_safety.json draft7.json
- jsonschema -i opentargets_tep.json draft7.json
- jsonschema -i opentargets.json draft7.json
- jsonschema -i OT_network_schema.json draft4.json
- for f in $(ls schemas/*json); do check-jsonschema --schemafile draft7.json $f ;done
168 changes: 0 additions & 168 deletions OT_network_schema.json

This file was deleted.

22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/opentargets/json_schema/master.svg)](https://results.pre-commit.ci/latest/github/opentargets/json_schema/master)

# Schemas of the OpenTargets Platform data models

This repository contains schema definitions of some of the data models the OpenTargets Platform deals with.
Either as an input or generates as an output.

**Folders**:

- `/schemas/` - List of schemas in JSON format.
- `/pydantic_models/` - Definitions of the data models using Python's [Pydantic](https://docs.pydantic.dev/) tool. [jsontopydantic](https://jsontopydantic.com/) is helpful for the purpose of defining a JSON schema as a Pydantic model. While it may require some customization, it streamlines the majority of the Pydantic boilerplate.

## Available schemas

- `TEP.json`: Description of [Target Enabling Packages](https://platform-docs.opentargets.org/target/chemical-probes-and-teps#target-enabling-packages).
- `chemical_probes.json`: Description of the [chemical probes](https://platform-docs.opentargets.org/target/chemical-probes-and-teps#chemical-probes) data model.
- `disease_target_evidence.json`: Description of disease-target evidence input. Separate schemas are defined for each data sources.
- `target_safety.json`: Description of [target safety](https://platform-docs.opentargets.org/target/safety).
- `molecular_interactions.json`: Definition of the [molecular interactions](https://platform-docs.opentargets.org/target/molecular-interactions) input.
- `molecular_interactions-output.json`: Definition for the molecular interactions dataset generated by the Platform ETL.

##
109 changes: 0 additions & 109 deletions opentargets_chemical_probe.json

This file was deleted.

4 changes: 2 additions & 2 deletions pydantic_models/chemical_probes.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,6 @@ def validator(item):
return False

return True

print(validator(ex))
print(ChemicalProbes.schema_json(indent=2))
print(ChemicalProbes.schema_json(indent=2))
6 changes: 3 additions & 3 deletions pydantic_models/target_safety_liabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Study(BaseModel):

description: Optional[str] = Field(description='Description of the study.')
name: Optional[str] = Field(description='Name of the study.', examples='ACEA_ER_80hr')
type: Optional[str] = Field(description='Conceptual biological and/or chemical features of the study.', examples='cell-based')
type: Optional[str] = Field(description='Conceptual biological and/or chemical features of the study.', examples='cell-based')
class Config:
extra = Extra.forbid
anystr_strip_whitespace = True
Expand Down Expand Up @@ -86,6 +86,6 @@ def validator(item):
return False

return True

print(validator(ex))
print(TargetSafety.schema_json(indent=2))
print(TargetSafety.schema_json(indent=2))
Loading

0 comments on commit 537e2ca

Please sign in to comment.