Skip to content

Commit

Permalink
use newer brick-tq-shacl, switch everything to use uv
Browse files Browse the repository at this point in the history
  • Loading branch information
gtfierro committed Sep 17, 2024
1 parent 1b176f2 commit 5713ad5
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 33 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ COMPILED_MODELS := $(patsubst models/%.ttl,models/compiled/%.ttl,$(MODEL_SOURCES
# 'tools/compile.py' ensures the compile script is present, but should be a prerequisite only if you want to track changes on it.
# 'ontologies/*.ttl' captures changes in any .ttl file in the ontologies directory.
models/compiled/%.ttl: models/%.ttl tools/compile.py
python tools/compile.py -r -i -o $@ $<
uv run python tools/compile.py -r -i -o $@ $<
#ontologies/223p.ttl

# The compile-models target will "make" all of the COMPILED_MODELS.
compile-models: $(COMPILED_MODELS)

install-kernel:
python -m ipykernel install --user --name=python3
uv run python -m ipykernel install --user --name=python3

# Rule to clean up the compiled models.
clean:
Expand Down
13 changes: 7 additions & 6 deletions build_examples.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -x

# run the tools/make_model_formats.py script on the models directory
python tools/make_model_formats.py models
uv run python tools/make_model_formats.py models

# for each filename in the examples/ directory, look for a corresponding .ttl file in the
# models directory. If it exists, run the tools/make_count_table.py script as
Expand All @@ -24,14 +24,15 @@ for filename in examples/*.md; do
md_filename="examples/$(basename "${filename%.md}.md")"
echo " Writing to $md_filename"

python tools/make_count_table.py "$ttl_filename" "$md_filename"
python tools/make-notebook.py "$ttl_filename" "$md_filename"
python tools/mark-out-of-date.py "$ttl_filename" "$md_filename"
uv run python tools/make_count_table.py "$ttl_filename" "$md_filename"
uv run python tools/make-notebook.py "$ttl_filename" "$md_filename"
uv run python tools/mark-out-of-date.py "$ttl_filename" "$md_filename"
done

# build queries
python tools/generate-queries.py
uv run python tools/generate-queries.py

# for each filename in the models/ directory, run tools/compile.py -o models/compiled/<filename>.ttl
mkdir -p models/compiled
make compile-models
make -j 4 compile-models
jb build .
29 changes: 9 additions & 20 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,19 @@
name = "models-open223-info"
version = "0.1.0"
description = "Add your description here"
authors = [
{ name = "Gabe Fierro", email = "[email protected]" }
]
readme = "README.md"
requires-python = ">=3.9"
dependencies = [
"jupyter-book>=0.15.1",
"toml>=0.10.2",
"sphinxcontrib-mermaid>=0.9.2",
"rdflib>=7.0.0",
"pyontoenv==0.1.9a3",
"brickschema==0.7.4a9",
"brick-tq-shacl==0.3.4a1",
"jupyter-book>=1.0.2",
"jupyterlab>=4.2.5",
"nbformat>=5.10.4",
"jupyterlab>=4.2.4",
"buildingmotif[topquadrant] @ git+https://github.com/NREL/buildingmotif.git@develop"
"pyontoenv>=0.1.9",
"rdflib>=7.0.0",
"sphinxcontrib-mermaid>=0.9.2",
"toml>=0.10.2",
]
readme = "README.md"
requires-python = ">= 3.11"

[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"

[tool.rye]
managed = true
dev-dependencies = []

[tool.hatch.metadata]
allow-direct-references = true
12 changes: 7 additions & 5 deletions tools/compile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@
import string
import random
import argparse
import brickschema
from brickschema import topquadrant_shacl
import rdflib
#import brickschema
#from brickschema import topquadrant_shacl
from brick_tq_shacl.topquadrant_shacl import infer, validate
import rdflib

graph = brickschema.Graph()
graph = rdflib.Graph()

if __name__ == "__main__":
parser = argparse.ArgumentParser(
Expand Down Expand Up @@ -41,9 +43,9 @@
graph.remove((None, rdflib.OWL.imports, None))
s223.remove((None, rdflib.OWL.imports, None))
#topquadrant_shacl._MAX_EXTERNAL_LOOPS = 2
graph = topquadrant_shacl.infer(graph, s223)
graph = infer(graph, s223)
#graph.expand(profile="shacl", backend="topquadrant")
valid, _, report = topquadrant_shacl.validate(graph, s223)
valid, _, report = validate(graph, s223)
if not valid:
print(report)
raise Exception("Validation failed: {}".format(report))
Expand Down

0 comments on commit 5713ad5

Please sign in to comment.