Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: project structure #12

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
6715a8e
refactor: src layout + split app files from docker
cmdoret Feb 20, 2025
13a59ac
feat: pyproject file
cmdoret Feb 20, 2025
b287f0c
refactor: drop shapes file
cmdoret Feb 20, 2025
bda986e
refactor: standard project structure for example files and tools
cmdoret Feb 20, 2025
221e95e
docs: fill metadata in pyproject.toml
cmdoret Feb 20, 2025
7417137
chore(docker): add dockerignore
cmdoret Feb 21, 2025
0346954
feat(docker): multi-stage build with shapes download
cmdoret Feb 21, 2025
46e2a88
chore: include example env file
cmdoret Feb 21, 2025
91a9aff
refactor: flatten source tree
cmdoret Feb 21, 2025
f145bc8
fix: specify src layout in pyproject.toml
cmdoret Feb 21, 2025
0930fae
chore: add makefile
cmdoret Feb 21, 2025
c6a77ea
docs: udpate makefile helm message
cmdoret Feb 21, 2025
1c836b6
feat(docker): make shapes download optional
cmdoret Feb 21, 2025
1d21f6c
chore(docker): no exit on unbound variable
cmdoret Feb 21, 2025
9112b55
fix: pyproject syntax
cmdoret Feb 21, 2025
2b60096
fix: missing deps in pyproject
cmdoret Feb 21, 2025
522fcb4
fix(docker): downloaded file paths
cmdoret Feb 21, 2025
5a8a176
fix(compose): relative mount point
cmdoret Feb 21, 2025
ce3bb87
fix(docker): update uvicorn module path in entrypoint
cmdoret Feb 21, 2025
dd1ac7e
fix: saner default shapes path in webserver
cmdoret Feb 21, 2025
17e4384
style: ruff format
cmdoret Feb 21, 2025
56eea12
chore(make): format recipe
cmdoret Feb 21, 2025
4aa7b3d
chore(make): add install recipe
cmdoret Feb 21, 2025
17f134b
fix: matching default value for SHAPES_PATH between env file and dock…
cmdoret Feb 21, 2025
29240e2
docs(readme): update usage instructions
cmdoret Feb 21, 2025
d68cef9
chore(make): add placeholder test recipe
cmdoret Feb 21, 2025
445d405
chore(make): add lint recipe
cmdoret Feb 21, 2025
c45ba6f
style: remove unused imports
cmdoret Feb 21, 2025
d7eca88
refactor: .docker/ -> tools/docker
cmdoret Feb 21, 2025
0e8a867
refactor: examples/bench -> examples/{notebooks,data}
cmdoret Feb 21, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.env
4 changes: 4 additions & 0 deletions .example.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
WEBAPP_PORT=8501
API_PORT=15400
SHAPES_PATH=/shacl/data/shapes.ttl
SHAPES_URL='https://github.com/sdsc-ordes/imaging-plaza-ontology/releases/download/v0.8/ImagingOntologyCombined.ttl.gz'
30 changes: 0 additions & 30 deletions Dockerfile

This file was deleted.

54 changes: 54 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
VERSION = latest
IMAGE = ghcr.io/sdsc-ordes/shacl-api
CONTAINER_RUNTIME ?= docker

.PHONY: docker-build
docker-build: ## Build Docker images
@echo "🐋 Building docker image"

$(CONTAINER_RUNTIME) build \
-f tools/docker/Dockerfile \
-t $(IMAGE):$(VERSION) \
--build-arg VERSION=$(VERSION) \
--target api .

$(CONTAINER_RUNTIME) build \
-f tools/docker/Dockerfile \
-t $(IMAGE):$(VERSION)-webapp \
--build-arg VERSION=$(VERSION) \
--target webapp .

.PHONY: docker-push
docker-push: docker-build ## Push Docker images
@echo "🐋 Pushing docker image"
$(CONTAINER_RUNTIME) push $(IMAGE):$(VERSION)
$(CONTAINER_RUNTIME) push $(IMAGE):$(VERSION)-webapp

docker-compose-up: ## Run the Docker Compose stack
@echo "🐋 Running docker-compose"
$(CONTAINER_RUNTIME) compose \
-f tools/docker/compose.yml \
up --build

.PHONY: format
format: install ## Format python code
ruff format src

.PHONY: lint
lint: install ## Lint python code
ruff check src

.PHONY: install
install: ## Setup project for development
pip install -e '.[webapp,test,dev]'


.PHONY: test
test: install ## Run unit tests
pytest

.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'

.DEFAULT_GOAL := help
33 changes: 13 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,40 +1,33 @@
# shaclAPI

Web server wrapping the TopBraid Shacl API tool.
Implementated for Imaging Plaza.
Web server for RDF data validation, wrapping the TopBraid Shacl API tool.
Based on https://github.com/SDSC-ORD/shacl

## How to use it?


### With docker

## How to use docker?
We provide a helper make recipe to build two docker images, a small "headless" version with only the REST server, and a larger image that bundles the REST server and a streamlit web application. These two images are differentiated by their tag: `<version>` vs `<version>-webapp`.

```
docker build -t sdsc-ordes/shacl-api:latest .
make docker-build
```

```
docker run -it --rm -p 8000:15400 -p 8501:8501 sdsc-ordes/shacl-api:latest
docker run -it --rm -p 7200:15400 -p 3000:8501 sdsc-ordes/shacl-api:latest
```
The docker images can be run as follows:

```
docker-compose up # add -d for detached
# Only REST API
docker run -it --rm -p 8000:15400 sdsc-ordes/shacl-api:latest
# REST API + web server
docker run -it --rm -p 8000:15400 -p 8501:8501 sdsc-ordes/shacl-api:latest-webapp
```

## LOGS

```
if [ $1 == validate ] ; then
set -- shaclvalidate.sh "$@"
elif [ $1 == infer ] ; then
set -- shaclinfer.sh "$@"
```
## With docker compose

For development, it may be more convenient to use our docker compose stack.

```
root@cbb169b97823:/# shaclvalidate.sh
Missing -datafile, e.g.: -datafile myfile.ttl
root@cbb169b97823:/# shaclinfer.sh
Missing -datafile, e.g.: -datafile myfile.ttl
make docker-compose-up
```
4 changes: 0 additions & 4 deletions app/entrypoint.sh

This file was deleted.

170 changes: 0 additions & 170 deletions app/main.py

This file was deleted.

Loading