Skip to content

Commit

Permalink
Merge pull request #6 from mahdanoura/20240424
Browse files Browse the repository at this point in the history
project structure modified, makefile errors for running the project
  • Loading branch information
mahdanoura authored May 21, 2024
2 parents 5d07154 + 741126e commit af49951
Show file tree
Hide file tree
Showing 203 changed files with 20,523 additions and 834 deletions.
27 changes: 0 additions & 27 deletions .cruft.json

This file was deleted.

27 changes: 0 additions & 27 deletions .env.public

This file was deleted.

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__pycache__/
*.py[cod]
*$py.class

.idea/
# C extensions
*.so

Expand Down
147 changes: 39 additions & 108 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,22 @@ SHELL := bash
.SUFFIXES:
.SECONDARY:

# environment variables
.EXPORT_ALL_VARIABLES:
ifdef LINKML_ENVIRONMENT_FILENAME
include ${LINKML_ENVIRONMENT_FILENAME}
else
include .env.public
endif

RUN = poetry run
LINKML_SCHEMA_NAME=thing_description_schema
SCHEMA_NAME = $(LINKML_SCHEMA_NAME)
SOURCE_SCHEMA_PATH = $(LINKML_SCHEMA_SOURCE_PATH)
SOURCE_SCHEMA_PATH = resources/thing_description_schema.yaml
SOURCE_SCHEMA_DIR = $(dir $(SOURCE_SCHEMA_PATH))
SRC = src
DEST = project
PYMODEL = $(SRC)/$(SCHEMA_NAME)/datamodel
DOCDIR = docs
DEST = resources/gens
PYMODEL= $(DEST)/datamodel
DOCDIR = $(DEST)/docs
EXAMPLEDIR = examples
SHEET_MODULE = personinfo_enums
SHEET_ID = $(LINKML_SCHEMA_GOOGLE_SHEET_ID)
SHEET_TABS = $(LINKML_SCHEMA_GOOGLE_SHEET_TABS)
SHEET_MODULE_PATH = $(SOURCE_SCHEMA_DIR)/$(SHEET_MODULE).yaml
TEMPLATE_DIR = resources/templates
LINKML_GENERATORS_CONFIG_YAML= --config-file src/linkml/config.yaml


$(DEST):
mkdir -p $@

CONFIG_YAML =
ifdef LINKML_GENERATORS_CONFIG_YAML
Expand All @@ -35,106 +30,73 @@ endif

GEN_DOC_ARGS =
ifdef LINKML_GENERATORS_DOC_ARGS
GEN_DOC_ARGS = ${LINKML_GENERATORS_DOC_ARGS}
GEN_DOC_ARGS = ${GEN_DOC_ARGS}
endif

GEN_OWL_ARGS =
ifdef LINKML_GENERATORS_OWL_ARGS
GEN_OWL_ARGS = ${LINKML_GENERATORS_OWL_ARGS}
endif

GEN_JAVA_ARGS =
ifdef LINKML_GENERATORS_JAVA_ARGS
GEN_JAVA_ARGS = ${LINKML_GENERATORS_JAVA_ARGS}
GEN_OWL_ARGS = ${GEN_OWL_ARGS}
endif

GEN_TS_ARGS =
ifdef LINKML_GENERATORS_TYPESCRIPT_ARGS
GEN_TS_ARGS = ${LINKML_GENERATORS_TYPESCRIPT_ARGS}
GEN_TS_ARGS = ${GEN_TS_ARGS}
endif

.PHONY: all clean setup gen-project gen-examples gendoc

# basename of a YAML file in model/
.PHONY: all clean setup gen-project gen-examples gendoc git-init-add git-init git-add git-commit git-status

# note: "help" MUST be the first target in the file,
# when the user types "make" they should get help info
help: status
@echo ""
@echo "make setup -- initial setup (run this first)"
@echo "make site -- makes site locally"
@echo "make install -- install dependencies"
@echo "make test -- runs tests"
@echo "make lint -- perform linting"
@echo "make testdoc -- builds docs and runs local test server"
@echo "make deploy -- deploys site"
@echo "make update -- updates linkml version"
@echo "make help -- show this help"
@echo ""


status: check-config
@echo "Project: $(SCHEMA_NAME)"
@echo "Source: $(SOURCE_SCHEMA_PATH)"

# generate products and add everything to github
setup: check-config git-init install gen-project gen-examples gendoc git-add git-commit
setup: check-config install gen-project gen-examples gendoc


check-config:
ifndef LINKML_SCHEMA_NAME
$(error **Project not configured**:\n\n)
else
$(info Ok)
endif


# install any dependencies required for building
install:
poetry install
.PHONY: install

# ---
# Project Synchronization
# ---
#
# check we are up to date
check: cruft-check
cruft-check:
cruft check
cruft-diff:
cruft diff

update: update-template update-linkml
update-template:
cruft update

# todo: consider pinning to template

update: update-linkml

update-linkml:
poetry add -D linkml@latest

# EXPERIMENTAL
create-data-harmonizer:
npm init data-harmonizer $(SOURCE_SCHEMA_PATH)

all: site
site: gen-project gendoc
%.yaml: gen-project
deploy: all mkd-gh-deploy

compile-sheets:
$(RUN) sheets2linkml --gsheet-id $(SHEET_ID) $(SHEET_TABS) > $(SHEET_MODULE_PATH).tmp && mv $(SHEET_MODULE_PATH).tmp $(SHEET_MODULE_PATH)

# In future this will be done by conversion
gen-examples:
cp src/data/examples/* $(EXAMPLEDIR)

# generates all project files
gen-project: $(DEST)
$(RUN) gen-project ${CONFIG_YAML} -d $(DEST) $(SOURCE_SCHEMA_PATH) --exclude excel && mv $(DEST)/*.py $(PYMODEL)

gen-project: $(PYMODEL)
$(RUN) gen-project ${CONFIG_YAML} -d $(DEST) $(SOURCE_SCHEMA_PATH) && mv $(DEST)/*.py $(PYMODEL)


# non-empty arg triggers owl (workaround https://github.com/linkml/linkml/issues/1453)
ifneq ($(strip ${GEN_OWL_ARGS}),)
mkdir -p ${DEST}/owl || true
$(RUN) gen-owl ${GEN_OWL_ARGS} $(SOURCE_SCHEMA_PATH) >${DEST}/owl/${SCHEMA_NAME}.owl.ttl
endif
# non-empty arg triggers java
ifneq ($(strip ${GEN_JAVA_ARGS}),)
$(RUN) gen-java ${GEN_JAVA_ARGS} --output-directory ${DEST}/java/ $(SOURCE_SCHEMA_PATH)
endif
# non-empty arg triggers typescript

ifneq ($(strip ${GEN_TS_ARGS}),)
mkdir -p ${DEST}/typescript || true
$(RUN) gen-typescript ${GEN_TS_ARGS} $(SOURCE_SCHEMA_PATH) >${DEST}/typescript/${SCHEMA_NAME}.ts
Expand All @@ -148,16 +110,6 @@ test-schema:
test-python:
$(RUN) python -m unittest discover

lint:
$(RUN) linkml-lint $(SOURCE_SCHEMA_PATH)

check-config:
ifndef LINKML_SCHEMA_NAME
$(error **Project not configured**:\n\n - See '.env.public'\n\n)
else
$(info Ok)
endif

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

Expand All @@ -180,46 +132,25 @@ examples/output: src/thing_description_schema/schema/thing_description_schema.ya
--output-directory $@ \
--schema $< > $@/README.md

# Test documentation locally
serve: mkd-serve

# Python datamodel
$(PYMODEL):
mkdir -p $@


$(DOCDIR):
mkdir -p $@

gendoc: $(DOCDIR)
cp -rf $(SRC)/docs/* $(DOCDIR) ; \
mkdir -p $(DOCDIR)
cp -rf $(SRC)/docs/* $(DOCDIR)
$(RUN) gen-doc ${GEN_DOC_ARGS} -d $(DOCDIR) $(SOURCE_SCHEMA_PATH)

testdoc: gendoc serve

serve: mkd-serve

MKDOCS = $(RUN) mkdocs
mkd-%:
$(MKDOCS) $*

git-init-add: git-init git-add git-commit git-status
git-init:
git init
git-add: .cruft.json
git add .
git-commit:
git commit -m 'chore: make setup was run' -a
git-status:
git status

# only necessary if setting up via cookiecutter
.cruft.json:
echo "creating a stub for .cruft.json. IMPORTANT: setup via cruft not cookiecutter recommended!" ; \
touch $@
mkd-gh-deploy:
$(RUN) mkdocs gh-deploy


clean:
rm -rf $(DEST)
rm -rf tmp
rm -fr docs/*
rm -fr $(PYMODEL)/*

include project.Makefile
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ For more information please refer to the [WoT github repo](https://github.com/w3
* [src/](src/) - source files
* [thing_description_schema](src/thing_description_schema)
* [schema](src/thing_description_schema/schema) -- LinkML schema
* [datamodel](src/thing_description_schema/datamodel) -- generated
* [datamodel](resources/gens/datamodel) -- generated
Python datamodel
* [tests/](tests/) - Python tests

Expand Down
5 changes: 0 additions & 5 deletions examples/README.md

This file was deleted.

7 changes: 0 additions & 7 deletions examples/Thing-001.yaml

This file was deleted.

Empty file added main.py
Empty file.
13 changes: 5 additions & 8 deletions mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
site_name: "thing-description-schema"
docs_dir: resources/gens/docs

theme:
name: material
# palette:
Expand All @@ -14,12 +16,7 @@ nav:
# - Home: home.md
- Index: index.md
- About: about.md
site_url: https://mahdanoura.github.io/thing-description-schema
repo_url: https://github.com/mahdanoura/thing-description-schema
site_url: https://github.io/w3c/wot-thing-description-toolchain-tmp
repo_url: https://github.com/w3c/wot-thing-description-toolchain-tmp


# Uncomment this block to enable use of Google Analytics.
# Replace the property value with your own ID.
# extra:
# analytics:
# provider: google
# property: G-XXXXXXXXXX
1 change: 0 additions & 1 deletion project.Makefile

This file was deleted.

3 changes: 3 additions & 0 deletions resources/gens/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# linkml_model

Do not edit the files in here - these are autogenerated from the LinkML schema. See the Makefile for details.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Auto generated from thing_description_schema.yaml by pythongen.py version: 0.0.1
# Generation date: 2024-05-15T15:38:14
# Generation date: 2024-05-21T15:16:14
# Schema: thing-description-schema
#
# id: td
# description: LinkML schema for modelling the W3C Web of Things Thing Description information model. This schema is used to generate
# description: LinkML schema for modelling the Web of Things Thing Description information model. This schema is used to generate
# JSON Schema, SHACL shapes, and RDF.
# license: MIT

Expand Down
Loading

0 comments on commit af49951

Please sign in to comment.