generated from linkml/linkml-template
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from linkml/refactored-to-poetry
Refactored to use poetry. Updated registry entries
- Loading branch information
Showing
31 changed files
with
483 additions
and
2,773 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,191 @@ | ||
# All artifacts of the build should be preserved | ||
MAKEFLAGS += --warn-undefined-variables | ||
SHELL := bash | ||
.SHELLFLAGS := -eu -o pipefail -c | ||
.DEFAULT_GOAL := help | ||
.DELETE_ON_ERROR: | ||
.SUFFIXES: | ||
.SECONDARY: | ||
|
||
# ---------------------------------------- | ||
# Model documentation and schema directory | ||
# ---------------------------------------- | ||
SRC_DIR = src | ||
PKG_DIR = linkml_registry | ||
SCHEMA_DIR = $(SRC_DIR)/schema | ||
MODEL_DOCS_DIR = $(SRC_DIR)/docs | ||
SOURCE_FILES := $(shell find $(SCHEMA_DIR) -name '*.yaml') | ||
SRC = $(SCHEMA_DIR)/registry.yaml | ||
SCHEMA_NAMES = $(patsubst $(SCHEMA_DIR)/%.yaml, %, $(SOURCE_FILES)) | ||
|
||
SCHEMA_NAME = registry | ||
SCHEMA_SRC = $(SCHEMA_DIR)/$(SCHEMA_NAME).yaml | ||
PKG_TGTS = python jsonld_context json_schema | ||
TGTS = docs python $(PKG_TGTS) | ||
|
||
# Targets by PKG_TGT | ||
PKG_T_GRAPHQL = $(PKG_DIR)/graphql | ||
PKG_T_JSON = $(PKG_DIR)/json | ||
PKG_T_JSONLD_CONTEXT = $(PKG_DIR)/jsonld | ||
PKG_T_JSON_SCHEMA = $(PKG_DIR)/jsonschema | ||
PKG_T_OWL = $(PKG_DIR)/owl | ||
PKG_T_RDF = $(PKG_DIR)/rdf | ||
PKG_T_SHEX = $(PKG_DIR)/shex | ||
PKG_T_SQLDDL = $(PKG_DIR)/sqlddl | ||
PKG_T_DOCS = $(MODEL_DOCS_DIR) | ||
PKG_T_PYTHON = $(PKG_DIR) | ||
PKG_T_MODEL = $(PKG_DIR)/model | ||
PKG_T_SCHEMA = $(PKG_T_MODEL)/schema | ||
|
||
# Global generation options | ||
GEN_OPTS = --log_level WARNING | ||
ENV = export PIPENV_VENV_IN_PROJECT=true && export PIPENV_PIPFILE=make-venv/Pipfile && export PIPENV_IGNORE_VIRTUALENVS=1 | ||
RUN = pipenv run | ||
|
||
# ---------------------------------------- | ||
# TOP LEVEL TARGETS | ||
# ---------------------------------------- | ||
all: install gen | ||
index: models.yaml all | ||
|
||
# --------------------------------------- | ||
# We don't want to pollute the python environment with linkml tool specific packages. For this reason, | ||
# we install an isolated instance of linkml in the pipenv-linkml directory | ||
# --------------------------------------- | ||
install: make-venv/env.lock | ||
|
||
make-venv/env.lock: | ||
$(ENV) && pipenv install | ||
touch make-venv/env.lock | ||
|
||
uninstall: | ||
rm -f make-venv/env.lock | ||
$(ENV) && pipenv --rm | ||
|
||
# --------------------------------------- | ||
# Test runner | ||
# ---------------------------------------- | ||
test: | ||
pipenv install --dev | ||
pipenv run python -m unittest discover -p 'test_*.py' | ||
|
||
# --------------------------------------- | ||
# GEN: run generator for each target | ||
# --------------------------------------- | ||
#gen: $(patsubst %,gen-%,$(TGTS)) | ||
|
||
gen: | ||
$(RUN) gen-project -d . $(SRC) | ||
|
||
markdown: | ||
$(RUN) gen-markdown -d target/docs/ -I index.md $(SRC) && \ | ||
cp src/docs/*.md target/docs/ | ||
|
||
linkml_registry/registry.py: registry.py | ||
cp $< $@ | ||
|
||
|
||
|
||
# test docs locally. | ||
docserve: | ||
$(RUN) mkdocs serve | ||
gh-deploy: | ||
$(RUN) mkdocs gh-deploy | ||
|
||
models.yaml src/docs/registry.md: src/data/models.yaml | ||
pipenv run python -m linkml_registry.cli eval -i $< --use-github-api -m src/docs/registry.md -o models.yaml | ||
RUN = poetry run | ||
# get values from about.yaml file | ||
SCHEMA_NAME = $(shell ${SHELL} ./utils/get-value.sh name) | ||
SOURCE_SCHEMA_PATH = $(shell ${SHELL} ./utils/get-value.sh source_schema_path) | ||
SOURCE_SCHEMA_DIR = $(dir $(SOURCE_SCHEMA_PATH)) | ||
SRC = src | ||
DEST = project | ||
PYMODEL = $(SRC)/$(SCHEMA_NAME)/datamodel | ||
DOCDIR = docs | ||
EXAMPLEDIR = examples | ||
SHEET_MODULE = personinfo_enums | ||
SHEET_ID = $(shell ${SHELL} ./utils/get-value.sh google_sheet_id) | ||
SHEET_TABS = $(shell ${SHELL} ./utils/get-value.sh google_sheet_tabs) | ||
SHEET_MODULE_PATH = $(SOURCE_SCHEMA_DIR)/$(SHEET_MODULE).yaml | ||
|
||
# environment variables | ||
include config.env | ||
|
||
GEN_PARGS = | ||
ifdef LINKML_GENERATORS_PROJECT_ARGS | ||
GEN_PARGS = ${LINKML_GENERATORS_PROJECT_ARGS} | ||
endif | ||
|
||
GEN_DARGS = | ||
ifdef LINKML_GENERATORS_MARKDOWN_ARGS | ||
GEN_DARGS = ${LINKML_GENERATORS_MARKDOWN_ARGS} | ||
endif | ||
|
||
|
||
# basename of a YAML file in model/ | ||
.PHONY: all clean | ||
|
||
# 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: install gen-project gen-examples gendoc git-init-add | ||
|
||
# install any dependencies required for building | ||
install: | ||
git init | ||
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-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: $(PYMODEL) | ||
$(RUN) gen-project ${GEN_PARGS} -d $(DEST) $(SOURCE_SCHEMA_PATH) && mv $(DEST)/*.py $(PYMODEL) | ||
|
||
|
||
test: test-schema test-python test-examples | ||
|
||
test-schema: | ||
$(RUN) gen-project ${GEN_PARGS} -d tmp $(SOURCE_SCHEMA_PATH) | ||
|
||
test-python: | ||
$(RUN) python -m unittest discover | ||
|
||
lint: | ||
$(RUN) linkml-lint $(SOURCE_SCHEMA_PATH) | ||
|
||
check-config: | ||
@(grep my-datamodel about.yaml > /dev/null && printf "\n**Project not configured**:\n\n - Remember to edit 'about.yaml'\n\n" || exit 0) | ||
|
||
convert-examples-to-%: | ||
$(patsubst %, $(RUN) linkml-convert % -s $(SOURCE_SCHEMA_PATH) -C Person, $(shell ${SHELL} find src/data/examples -name "*.yaml")) | ||
|
||
examples/%.yaml: src/data/examples/%.yaml | ||
$(RUN) linkml-convert -s $(SOURCE_SCHEMA_PATH) -C Person $< -o $@ | ||
examples/%.json: src/data/examples/%.yaml | ||
$(RUN) linkml-convert -s $(SOURCE_SCHEMA_PATH) -C Person $< -o $@ | ||
examples/%.ttl: src/data/examples/%.yaml | ||
$(RUN) linkml-convert -P EXAMPLE=http://example.org/ -s $(SOURCE_SCHEMA_PATH) -C Person $< -o $@ | ||
|
||
test-examples: examples/output | ||
|
||
examples/output: src/linkml_common/schema/linkml_common.yaml | ||
mkdir -p $@ | ||
$(RUN) linkml-run-examples \ | ||
--output-formats json \ | ||
--output-formats yaml \ | ||
--counter-example-input-directory src/data/examples/invalid \ | ||
--input-directory src/data/examples/valid \ | ||
--output-directory $@ \ | ||
--schema $< > $@/README.md | ||
.PHONY: examples/output | ||
|
||
# Test documentation locally | ||
serve: mkd-serve | ||
|
||
# Python datamodel | ||
$(PYMODEL): | ||
mkdir -p $@ | ||
|
||
|
||
$(DOCDIR): | ||
mkdir -p $@ | ||
|
||
gendoc: $(DOCDIR) | ||
cp $(SRC)/docs/*md $(DOCDIR) ; \ | ||
$(RUN) gen-doc ${GEN_DARGS} -d $(DOCDIR) $(SOURCE_SCHEMA_PATH) | ||
|
||
testdoc: gendoc serve | ||
|
||
MKDOCS = $(RUN) mkdocs | ||
mkd-%: | ||
$(MKDOCS) $* | ||
|
||
PROJECT_FOLDERS = sqlschema shex shacl protobuf prefixmap owl jsonschema jsonld graphql excel | ||
git-init-add: git-init git-add git-commit git-status | ||
git-init: | ||
git init | ||
git-add: .cruft.json | ||
git add .gitignore .github .cruft.json Makefile LICENSE *.md examples utils about.yaml mkdocs.yml poetry.lock project.Makefile pyproject.toml src/linkml_common/schema/*yaml src/*/datamodel/*py src/data src/docs tests src/*/_version.py | ||
git add $(patsubst %, project/%, $(PROJECT_FOLDERS)) | ||
git-commit: | ||
git commit -m 'chore: initial commit' -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 $@ | ||
|
||
clean: | ||
rm -rf $(DEST) | ||
rm -rf tmp | ||
rm -fr docs/* | ||
rm -fr $(PYMODEL)/* | ||
|
||
include project.Makefile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.