Skip to content

Commit ad3ba7c

Browse files
committed
feat (modl): Very first initial use of LinkML! (see enola-dev#757)
1 parent 8ba11e0 commit ad3ba7c

File tree

10 files changed

+192
-15
lines changed

10 files changed

+192
-15
lines changed

.gitignore

+3-3
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,6 @@ node_modules/
3838
# Be
3939
.be/
4040

41-
# JSON Schemas are generated by tools/protoc during build
42-
*.schema.json
43-
4441
# Maven
4542
java/.mvn/wrapper/maven-wrapper.jar
4643
java/target
@@ -53,3 +50,6 @@ java/dev/enola/protobuf/
5350
java/dev/enola/thing/proto/
5451

5552
tools/version/VERSION
53+
54+
# LinkML
55+
.built

.vscode/settings.json

+4
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@
105105
"yaml.schemas": {
106106
// https://squidfunk.github.io/mkdocs-material/creating-your-site/#configuration
107107
"https://squidfunk.github.io/mkdocs-material/schema.json": "mkdocs.yaml",
108+
109+
// TODO https://github.com/linkml/linkml/issues/2179
110+
"https://raw.githubusercontent.com/linkml/linkml-model/main/linkml_model/jsonschema/meta.schema.json": "*.linkml.yaml",
111+
108112
// Keep this in sync with check-jsonschema in .pre-commit-config.yaml
109113
"docs/models/enola/schemas/Thing.schema.json": "*.thing.yaml"
110114
},

docs/concepts/other.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -91,12 +91,16 @@ Enola 🕵🏾‍♀️ may in the future have some [Personal Knowledge Managem
9191

9292
### Visualization
9393

94-
Enola 🕵🏾‍♀️ visualizes the relationships of its _Entities_ using:
94+
Enola 🕵🏾‍♀️ visualizes (TBD) the relationships of its _Entities_ using:
9595

9696
* [yEd](https://www.yworks.com) (yFiles) #commercial #sdk #freemium
9797
* [Graphviz](https://graphviz.org) #available
9898
* [Gephi](https://gephi.org), with [Gephi Lite](https://gephi.org/gephi-lite/) which uses [SigmaJS](https://www.sigmajs.org) on [Graphology](https://graphology.github.io) for JS #[FOSDEM](https://github.com/vorburger/vorburger.ch-Notes/blob/develop/conferences/FOSDEM-2024.md) #planned #ToDo
9999
* [D3js.org](https://d3js.org) also has [Graphs](https://observablehq.com/@d3/force-directed-graph-component?collection=@d3/charts) (and [d3rdf](https://github.com/Rathachai/d3rdf))
100+
* [vis.js](https://visjs.org)
101+
* [Mermaid](https://mermaid.js.org)
102+
* [PlantUML](https://plantuml.com)
103+
* [yuml](https://yuml.me)
100104

101105
Other _"Graph Explorer"_ kind of UIs that we have heard about include:
102106

docs/index.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,5 +49,5 @@ of environments by modeling concepts from private environments and writing bespo
4949
Holmes_ 🕵🏾‍♀️ detective movie with his daughter, and this is an SRE detective's tool!</sub>
5050

5151
<script type="application/ld+json">
52-
{% include "models/enola.jsonld" %}
52+
{% include "models/enola.dev.jsonld" %}
5353
</script>

models/.linkmllint.yaml

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright 2024 The Enola <https://enola.dev> Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# https://linkml.io/linkml/schemas/linter.html
18+
extends: recommended
19+
20+
rules:
21+
# TODO https://github.com/linkml/prefixmaps/issues/73
22+
canonical_prefixes:
23+
level: disabled
24+
25+
no_empty_title:
26+
# name becomes title, if no title; that's fine
27+
level: disabled

models/build.bash

+12-4
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,26 @@
1717

1818
set -euox pipefail
1919

20-
# TODO Replace this Bash script with a Bazel BUILD
20+
rm -rf docs/models/ .built/linkml/
2121

22-
# NOTE: DO *NOT* do "rm -rf docs/models/" here, because that would wipe out
23-
# the docs/models/enola/schemas/*.schema.json generated by tools/protoc/protoc.bash
22+
tools/protoc/protoc.bash
2423

2524
find models/ -type d -exec mkdir -p docs/{} \;
2625
find models/ -type f -exec ln -f {} docs/{} \;
2726
rm docs/models/{BUILD,build.bash}
2827

28+
# https://linkml.io
29+
mkdir -p .built/linkml/
30+
find docs/models/ -name "*.linkml.yaml" -print0 | xargs -n 1 -0 linkml-lint --validate --config models/.linkmllint.yaml
31+
find docs/models/ -name "*.linkml.yaml" -print0 | xargs -n 1 -0 gen-project -X prefixmap -d .built/linkml/
32+
# TODO Drop all *.linkml.* e.g. to rename file.linkml.context.jsonld to just file.linkml.context.jsonld
33+
# TODO --no-mergeimports? https://linkml.io/linkml/schemas/imports.html#making-merged-files-for-distribution ?
34+
# TODO https://linkml.io/linkml/generators/linkml.html ?
35+
mv .built/linkml docs/models/
36+
2937
./enola -vvv docgen --load=file:"docs/models/**.{ttl,owl,rdf}" --output=file://"$PWD"/docs/models/
3038

3139
# TODO Support GLOBs in rosetta like in docgen? (Low priority, because DocGen will gen. embedded JSON-LD anyway.)
32-
./enola -v rosetta --in=file:models/enola.dev.ttl --out=file:docs/models/enola.jsonld
40+
./enola -v rosetta --in=file:models/enola.dev.ttl --out=file:docs/models/enola.dev.jsonld
3341

3442
# TODO RDF* --load=file:"models/**.ttl[s?]"

models/enola.dev/enola.linkml.yaml

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright 2024 The Enola <https://enola.dev> Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
id: https://enola.dev/ontology
18+
name: Enola
19+
created_by: https://www.vorburger.ch
20+
license: ASL
21+
prefixes:
22+
enola: https://enola.dev/
23+
linkml: https://w3id.org/linkml/
24+
# TODO schema: https://schema.org/
25+
imports:
26+
- linkml:types
27+
default_range: string
28+
default_prefix: enola
29+
30+
# TODO Shouldn't (can't) [all] slot_uri be automatically inferred?!
31+
32+
types:
33+
GKG:
34+
description:
35+
ID in Google's Public Knowledge Graph (formerly AKA Freebase), see e.g.
36+
https://developers.google.com/knowledge-graph/; starts without slash, but with 'm' or 'g' following by a slash and
37+
lower case characters, numbers and underscores.
38+
uri: https://enola.dev/GKG
39+
base: string
40+
examples:
41+
- value: g/11bwcf511s
42+
description: Alphabet Inc.
43+
object: https://g.co/kg/g/11bwcf511s
44+
45+
slots:
46+
url:
47+
description:
48+
URL of this Thing (to be typed into a web browser, for a human to look at HTML). Not to be confused with each
49+
Thing's IRI Identity!
50+
# TODO range: GKG # TODO Replace *WRONG* local DataType GKG from initial testing with schema:url, once that works...
51+
52+
wikipedia:
53+
description: Wikipedia EN page ID (not URL), e.g. 'Wikipedia' (for https://en.wikipedia.org/wiki/Wikipedia)
54+
slot_uri: https://enola.dev/wikipedia
55+
pattern: "^[a-zA-Z0-9_]+$"
56+
# TODO How-to? schema:image <https://upload.wikimedia.org/wikipedia/commons/8/80/Wikipedia-logo-v2.svg>
57+
# TODO How-to? schema:url "https://en.wikipedia.org/wiki/{VALUE}"^^enola:IRITemplate
58+
# for https://docs.enola.dev/models/example.org/templates/
59+
60+
classes:
61+
Software:
62+
description:
63+
Parent (abstract) Class for 'soft ware', i.e. 'virtual computer stuff' - you can think of but cannot physically
64+
touch this.
65+
# TODO enola:wikipedia "Software". # https://en.wikipedia.org/wiki/Software
66+
67+
SoftwareWithURL:
68+
subclass_of: Software
69+
description:
70+
Parent (abstract) Class for a piece of [[Software]] which has a URL that you can type into a web browser to look
71+
at (the UI of) it.
72+
slots:
73+
- url

models/enola.dev/files.linkml.yaml

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
#
3+
# Copyright 2024 The Enola <https://enola.dev> Authors
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# https://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
id: https://enola.dev/Files
18+
name: Files
19+
created_by: https://www.vorburger.ch
20+
license: ASL
21+
prefixes:
22+
enola: https://enola.dev/
23+
linkml: https://w3id.org/linkml/
24+
xsd: http://www.w3.org/2001/XMLSchema#
25+
imports:
26+
- enola.linkml
27+
- linkml:types
28+
29+
slots:
30+
# TODO Are names adjusted in generation? https://linkml.io/linkml/schemas/linter.html#standard-naming
31+
parent_folder:
32+
description: Parent Folder which this File or Folder is in.
33+
# TODO subproperty_of: parent
34+
range: Folder
35+
36+
classes:
37+
File:
38+
description: File holds [[Data]], identified by a [[Path]] on a [[Filesystem]], with a [[MediaType]].
39+
subclass_of: SoftwareWithURL
40+
slots:
41+
- parent_folder
42+
attributes:
43+
size:
44+
description: Number of bytes of data.
45+
range: integer # TODO xsd:unsignedLong
46+
examples:
47+
- value: https://enola.dev/file/localhost/tmp/example.txt
48+
# TODO enola:iriTemplate "https://enola.dev/file/{FILESYSTEM}/{PATH}";
49+
# TODO enola:filesystem "fs:{FILESYSTEM}"^^enola:IRITemplate;
50+
# TODO enola:wikipedia "Computer_file"; # https://en.wikipedia.org/wiki/Computer_file
51+
# TODO enola:emoji "🗎".
52+
53+
Folder:
54+
description: Folder is a [[Container]] of other Folders and [[File]]s.
55+
subclass_of: SoftwareWithURL
56+
slots:
57+
- parent_folder
58+
# TODO enola:wikipedia "Directory_(computing)"; # https://en.wikipedia.org/wiki/Directory_(computing)
59+
# TODO enola:emoji "📁".

models/enola.dev/files.ttl

+5-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ enola:fileOntology a owl:Ontology;
2525
rdfs:label "An Ontology by Enola.dev about Files on Computers.".
2626

2727
enola:File a rdfs:Class;
28+
rdfs:comment "File holds [[Data]], identified by a [[Path]] on a [[Filesystem]], with a [[MediaType]].";
2829
rdfs:isDefinedBy enola:fileOntology;
2930
rdfs:subClassOf enola:SoftwareWithURL;
3031
enola:example <https://enola.dev/file/localhost/tmp/example.txt>;
@@ -36,6 +37,7 @@ enola:File a rdfs:Class;
3637
enola:emoji "🗎".
3738

3839
enola:Folder a rdfs:Class;
40+
rdfs:comment "Folder is a [[Container]] of other Folders and [[File]]s";
3941
rdfs:subClassOf enola:SoftwareWithURL;
4042
enola:wikipedia "Directory_(computing)"; # https://en.wikipedia.org/wiki/Directory_(computing)
4143
enola:emoji "📁".
@@ -61,8 +63,9 @@ enola:path a rdf:Property;
6163
rdfs:domain enola:File.
6264

6365
enola:size a rdf:Property;
64-
rdfs:range xsd:unsignedLong; # TODO Use a Datatype which permits KiB/MB etc. (from UoM?)
65-
rdfs:domain enola:File.
66+
rdfs:comment "Number of bytes of data.";
67+
rdfs:range xsd:unsignedLong; # TODO Use a Datatype which permits KiB/MB etc. (from UoM?)
68+
rdfs:domain enola:File.
6669

6770
enola:MediaType a rdfs:Datatype;
6871
rdfs:comment "Internet Media Type, also known as a MIME Type or Content Type.";

tools/test-ci/test.bash

+3-4
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,13 @@ set -euox pipefail
2222
# shellcheck source=/dev/null
2323
source tools/asdf/install.bash
2424

25-
rm -rf docs/models/
26-
27-
# TODO Run all this only when model inputs change
28-
tools/protoc/protoc.bash
25+
# Installs all Python packages already (some of which models/build needs)
26+
source tools/pre-commit/install.bash
2927

3028
# This writes into docs/models/ (which is on .gitignore), not site/ (which mkdocs cleans when it starts; à la rm -rf site/)
3129
models/build.bash
3230

31+
# Run ./test.bash after models/build.bash, because this also runs pre-commit, which validates stuff using the generated JSON Schemas
3332
./test.bash
3433

3534
# No files (which are not on .gitigore) should have been modified!

0 commit comments

Comments
 (0)