Skip to content

Commit

Permalink
Improve tests
Browse files Browse the repository at this point in the history
- Fix EMDataset-001.yaml so it validates
- (Breaking) Replace `type` with `instrument_type` or `molecular_type`.
  Otherwise it breaks python tests.
- (Breaking) Remove multivalued from institution
- Fix datetime range


Running `rm -r examples/output;  make test-examples` still fails
  • Loading branch information
sbliven committed Aug 22, 2024
1 parent 3719334 commit 0b2ab23
Show file tree
Hide file tree
Showing 19 changed files with 1,173 additions and 1,068 deletions.
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,8 @@ ifneq ($(strip ${GEN_TS_ARGS}),)
$(RUN) gen-typescript ${GEN_TS_ARGS} $(SOURCE_SCHEMA_PATH) >${DEST}/typescript/${SCHEMA_NAME}.ts
endif

test: test-schema test-python test-examples
test: test-validate test-examples test-python
.PHONY: test test-validate test-examples test-python

test-schema:
$(RUN) gen-project ${CONFIG_YAML} -d tmp $(SOURCE_SCHEMA_PATH)
Expand All @@ -151,6 +152,9 @@ else
$(info Ok)
endif

test-validate:
$(RUN) linkml-validate -s $(SOURCE_SCHEMA_PATH) src/data/examples/*.yaml

convert-examples-to-%:
$(patsubst %, $(RUN) linkml-convert % -s $(SOURCE_SCHEMA_PATH) -C Person, $(shell ${SHELL} find src/data/examples -name "*.yaml"))

Expand All @@ -169,7 +173,7 @@ examples/output: src/oscem_schemas/schema/oscem_schemas.yaml
--output-formats json \
--output-formats yaml \
--counter-example-input-directory src/data/examples/invalid \
--input-directory src/data/examples/valid \
--input-directory src/data/examples \
--output-directory $@ \
--schema $< > $@/README.md

Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,16 @@ Schema for the Open Standards Community for Electron Microscopy (OSC-EM)
## Developer Documentation

<details>
Use the `make` command to generate project artefacts:
Use the `make` command to generate project artifacts:

* `make setup`: one-time setup
* `make all`: make everything
* `make deploy`: deploys site
* `make lint`: check syntax
* `make test`: run tests
* `make serve`: run docs locally on http://127.0.0.1:8000/oscem-schemas/
* `make clean` : remove generated files

</details>

## Credits
Expand Down
Binary file modified project/excel/oscem_schemas.xlsx
Binary file not shown.
18 changes: 11 additions & 7 deletions project/graphql/oscem_schemas.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type Acquisition
dosePerMovie: Float!
energyFilter: EnergyFilter
imageSize: ImageSize
datetime: Datetime!
datetime: Any!
exposureTime: Float
cryogen: String
framesPerMovie: Integer
Expand All @@ -30,11 +30,15 @@ type Acquisition
gainrefFlipRotate: String
}

type Any
{
}

type Author
{
firstName: String
workStatus: Boolean
institution: [Institution]!
institution: Institution!
orcid: String!
country: String!
role: String
Expand All @@ -54,7 +58,7 @@ type BoundingBox2D
type ChromaticAberrationCorrector
{
used: Boolean!
type: String!
instrumentType: String!
}

type EMDataset
Expand Down Expand Up @@ -131,7 +135,7 @@ type Ligand
type Molecule
{
nameMol: String!
type: String!
molecularType: String!
molecularClass: MoleculeClassEnum!
sequence: String!
naturalSource: String!
Expand All @@ -143,7 +147,7 @@ type Molecule

type OverallMolecule
{
type: String!
molecularType: String!
nameSample: String!
source: String!
molecularWeight: Float
Expand All @@ -161,7 +165,7 @@ type Person
type Phaseplate
{
used: Boolean!
type: String!
instrumentType: String!
}

type QuantityValue
Expand Down Expand Up @@ -216,7 +220,7 @@ type Specimen
type SphericalAberrationCorrector
{
used: Boolean!
type: String!
instrumentType: String!
}

type TiltAngle
Expand Down
14 changes: 10 additions & 4 deletions project/jsonld/oscem_schemas.context.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"comments": {
"description": "Auto generated by LinkML jsonld context generator",
"generation_date": "2024-08-22T23:22:33",
"generation_date": "2024-08-23T00:59:03",
"source": "oscem_schemas.yaml"
},
"@context": {
Expand Down Expand Up @@ -89,7 +89,7 @@
"@id": "https://w3id.org/osc-em/instrument/cs"
},
"datetime": {
"@type": "xsd:dateTime",
"@type": "@id",
"@id": "acquisition:datetime"
},
"detector": {
Expand Down Expand Up @@ -219,8 +219,8 @@
"@type": "@id",
"@id": "instrument"
},
"type": {
"@id": "sample:/type"
"instrument_type": {
"@id": "acquisition:instrument_type"
},
"ligands": {
"@type": "@id",
Expand Down Expand Up @@ -261,6 +261,9 @@
},
"@id": "sample:/molecular_class"
},
"molecular_type": {
"@id": "sample:/molecular_type"
},
"molecular_weight": {
"@type": "xsd:float",
"@id": "sample:/molecular_weight"
Expand Down Expand Up @@ -442,6 +445,9 @@
"Acquisition": {
"@id": "acquisition:Acquisition"
},
"Any": {
"@id": "linkml:Any"
},
"Author": {
"@id": "https://w3id.org/osc-em/organizational/Author"
},
Expand Down
72 changes: 51 additions & 21 deletions project/jsonld/oscem_schemas.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,18 @@
"domain_of": [
"Acquisition"
],
"range": "datetime",
"range": "Any",
"inlined": true,
"any_of": [
{
"range": "datetime",
"@type": "AnonymousSlotExpression"
},
{
"range": "date",
"@type": "AnonymousSlotExpression"
}
],
"@type": "SlotDefinition"
},
{
Expand Down Expand Up @@ -803,8 +814,7 @@
"definition_uri": "https://w3id.org/osc-em/acquisitioninstrument_type",
"description": "Details of a given specialist instrument",
"from_schema": "https://w3id.org/osc-em/acquisition",
"slot_uri": "https://w3id.org/osc-em/acquisitiontype",
"alias": "type",
"slot_uri": "https://w3id.org/osc-em/acquisitioninstrument_type",
"owner": "ChromaticAberrationCorrector",
"domain_of": [
"Phaseplate",
Expand Down Expand Up @@ -1093,7 +1103,7 @@
{
"name": "institution",
"definition_uri": "https://w3id.org/osc-em/organizational/institution",
"description": "institution",
"description": "author's institution",
"from_schema": "https://w3id.org/osc-em/organizational",
"mappings": [
"http://schema.org/Organization"
Expand All @@ -1104,7 +1114,6 @@
"Author"
],
"range": "Institution",
"multivalued": true,
"inlined": true,
"@type": "SlotDefinition"
},
Expand Down Expand Up @@ -1285,8 +1294,7 @@
"description": "Description of the overall supramolecular type, i.e., a complex",
"title": "Type",
"from_schema": "https://w3id.org/osc-em/sample",
"slot_uri": "https://w3id.org/osc-em/sample/type",
"alias": "type",
"slot_uri": "https://w3id.org/osc-em/sample/molecular_type",
"owner": "Molecule",
"domain_of": [
"OverallMolecule",
Expand Down Expand Up @@ -2160,8 +2168,19 @@
],
"is_usage_slot": true,
"usage_slot_name": "datetime",
"range": "datetime",
"range": "Any",
"required": true,
"inlined": true,
"any_of": [
{
"range": "datetime",
"@type": "AnonymousSlotExpression"
},
{
"range": "date",
"@type": "AnonymousSlotExpression"
}
],
"@type": "SlotDefinition"
},
{
Expand Down Expand Up @@ -2266,8 +2285,8 @@
"from_schema": "https://w3id.org/osc-em/acquisition",
"is_a": "instrument_type",
"domain": "Phaseplate",
"slot_uri": "https://w3id.org/osc-em/acquisitiontype",
"alias": "type",
"slot_uri": "https://w3id.org/osc-em/acquisitioninstrument_type",
"alias": "instrument_type",
"owner": "Phaseplate",
"domain_of": [
"Phaseplate"
Expand Down Expand Up @@ -2304,8 +2323,8 @@
"from_schema": "https://w3id.org/osc-em/acquisition",
"is_a": "instrument_type",
"domain": "SphericalAberrationCorrector",
"slot_uri": "https://w3id.org/osc-em/acquisitiontype",
"alias": "type",
"slot_uri": "https://w3id.org/osc-em/acquisitioninstrument_type",
"alias": "instrument_type",
"owner": "SphericalAberrationCorrector",
"domain_of": [
"SphericalAberrationCorrector"
Expand Down Expand Up @@ -2342,8 +2361,8 @@
"from_schema": "https://w3id.org/osc-em/acquisition",
"is_a": "instrument_type",
"domain": "ChromaticAberrationCorrector",
"slot_uri": "https://w3id.org/osc-em/acquisitiontype",
"alias": "type",
"slot_uri": "https://w3id.org/osc-em/acquisitioninstrument_type",
"alias": "instrument_type",
"owner": "ChromaticAberrationCorrector",
"domain_of": [
"ChromaticAberrationCorrector"
Expand Down Expand Up @@ -2558,7 +2577,7 @@
{
"name": "Author_institution",
"definition_uri": "https://w3id.org/osc-em/organizational/institution",
"description": "institution",
"description": "author's institution",
"from_schema": "https://w3id.org/osc-em/organizational",
"mappings": [
"http://schema.org/Organization"
Expand All @@ -2575,7 +2594,6 @@
"usage_slot_name": "institution",
"range": "Institution",
"required": true,
"multivalued": true,
"inlined": true,
"@type": "SlotDefinition"
},
Expand Down Expand Up @@ -2627,8 +2645,8 @@
"from_schema": "https://w3id.org/osc-em/sample",
"is_a": "molecular_type",
"domain": "OverallMolecule",
"slot_uri": "https://w3id.org/osc-em/sample/type",
"alias": "type",
"slot_uri": "https://w3id.org/osc-em/sample/molecular_type",
"alias": "molecular_type",
"owner": "OverallMolecule",
"domain_of": [
"OverallMolecule"
Expand Down Expand Up @@ -2726,8 +2744,8 @@
"from_schema": "https://w3id.org/osc-em/sample",
"is_a": "molecular_type",
"domain": "Molecule",
"slot_uri": "https://w3id.org/osc-em/sample/type",
"alias": "type",
"slot_uri": "https://w3id.org/osc-em/sample/molecular_type",
"alias": "molecular_type",
"owner": "Molecule",
"domain_of": [
"Molecule"
Expand Down Expand Up @@ -3761,6 +3779,18 @@
"class_uri": "https://w3id.org/osc-em/tomography/TiltAngle",
"@type": "ClassDefinition"
},
{
"name": "Any",
"definition_uri": "https://w3id.org/osc-em/types/Any",
"description": "Any type, used as the base for type-narrowing.\n\nSee https://linkml.io/linkml/schemas/advanced.html",
"from_schema": "https://w3id.org/osc-em/types",
"mappings": [
"linkml:Any"
],
"slot_usage": {},
"class_uri": "https://w3id.org/linkml/Any",
"@type": "ClassDefinition"
},
{
"name": "Range",
"definition_uri": "https://w3id.org/osc-em/types/Range",
Expand Down Expand Up @@ -3822,7 +3852,7 @@
"source_file": "oscem_schemas.yaml",
"source_file_date": "2024-08-22T23:20:17",
"source_file_size": 1401,
"generation_date": "2024-08-22T23:22:33",
"generation_date": "2024-08-23T00:59:03",
"@type": "SchemaDefinition",
"@context": [
"project/jsonld/oscem_schemas.context.jsonld",
Expand Down
Loading

0 comments on commit 0b2ab23

Please sign in to comment.