Skip to content

Commit 3f4ad42

Browse files
authored
Merge pull request #202 from buildingSMART/IVS-319-basic-API-docs
Basic API docs (IVS-319)
2 parents 169ece5 + 378aea6 commit 3f4ad42

File tree

167 files changed

+148157
-1071
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

167 files changed

+148157
-1071
lines changed

.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ DJANGO_SECRET_KEY = django-insecure-um7-^+&jbk_=80*xcc9uf4nh$4koida7)ja&6!vb*$8@
1414
DJANGO_ALLOWED_HOSTS = localhost
1515
DJANGO_TRUSTED_ORIGINS = http://localhost:3000 http://localhost http://localhost:8000
1616
DJANGO_LOG_LEVEL = INFO
17+
GHERKIN_LOG_FOLDER = /gherkin_logs
1718
DJANGO_GUNICORN_WORKERS = 3
1819
DJANGO_GUNICORN_THREADS_PER_WORKER = 4
1920

@@ -31,6 +32,7 @@ CELERY_TASK_SOFT_TIME_LIMIT = 3600
3132
CELERY_TASK_TIME_LIMIT = 4000
3233
TASK_TIMEOUT_LIMIT = 3600
3334
DJANGO_DB_USER_CONTEXT = SYSTEM
35+
DJANGO_DB_BULK_CREATE_BATCH_SIZE = 1000
3436
CELERY_CONCURRENCY = 4
3537

3638
# Email
@@ -46,4 +48,4 @@ B2C_CLIENT_ID = <B2C_CLIENT_ID>
4648
B2C_CLIENT_SECRET = <B2C_CLIENT_SECRET>
4749
B2C_AUTHORITY = <B2C_AUTHORITY>
4850
B2C_USER_FLOW = <B2C_USER_FLOW>
49-
USE_WHITELIST = False
51+
USE_WHITELIST = False

.github/workflows/ci_cd.yml

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ on:
1010
- development
1111
paths-ignore:
1212
- 'README.md'
13-
- '.github/**'
1413
pull_request:
1514
branches:
1615
- development
@@ -58,6 +57,8 @@ jobs:
5857

5958
- name: Fetch submodules
6059
run: |
60+
git clean -fdx -e ${{ vars.ENV_FILE }} -e 'redeploy.*.sh' -e 'docker/'
61+
git submodule foreach --recursive 'git clean -fdx'
6162
cd backend
6263
cd apps
6364
git submodule update --init --recursive
@@ -79,7 +80,16 @@ jobs:
7980
source venv/bin/activate
8081
pip install --upgrade pip
8182
pip install -r requirements.txt
82-
pip install ifcopenshell # TEMP workaround
83+
84+
- name: Install ifcopenshell package (temp)
85+
run: |
86+
cd backend
87+
source venv/bin/activate
88+
# use version of ifcopenshell with desired schema parsing
89+
# TODO: revert to pyPI when schema parsing is published in the future
90+
wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.8.3-260bc80-linux64.zip"
91+
mkdir -p venv/lib/python3.11/site-packages
92+
unzip -d venv/lib/python3.11/site-packages /tmp/ifcopenshell_python.zip
8393
8494
- name: Check Django config
8595
run: |
@@ -91,7 +101,12 @@ jobs:
91101
run: |
92102
cd backend
93103
source venv/bin/activate
94-
python3 manage.py test
104+
MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps/ifc_validation_models --settings apps.ifc_validation_models.test_settings --debug-mode --verbosity 3
105+
MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_header_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
106+
MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_header_syntax_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
107+
MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_syntax_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
108+
MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_schema_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
109+
MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests.tests_bsdd_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
95110
96111
deploy:
97112

@@ -125,10 +140,11 @@ jobs:
125140
sshpass ssh -o StrictHostKeyChecking=no ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }} bash <<'ENDSSH'
126141
cd ${{ vars.REPO_CLONE_PATH }}
127142
git checkout -q ${{ vars.BRANCH_NAME }} && git pull
143+
git clean -fdx -e ${{ vars.ENV_FILE }} -e 'redeploy.*.sh' -e 'docker/'
144+
git submodule foreach --recursive 'git clean -fdx'
128145
sudo make fetch-modules
129146
cd ${{ vars.REPO_CLONE_PATH }}/backend/apps/ifc_validation/checks/ifc_gherkin_rules && git checkout -q ${{ vars.BRANCH_NAME }} && git pull
130147
cd ./ifc_validation_models && git checkout -q ${{ vars.BRANCH_NAME }} && git pull
131-
cd ${{ vars.REPO_CLONE_PATH }}/backend/apps/ifc_validation/checks/step_file_parser && git checkout -q master && git pull
132148
cd ${{ vars.REPO_CLONE_PATH }}/backend/apps/ifc_validation_models && git checkout -q ${{ vars.BRANCH_NAME }} && git pull
133149
cd ${{ vars.REPO_CLONE_PATH }}
134150
./check-submodules.sh

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
.env.*
99
redeploy.*
1010
.VERSION
11+
tmp*
12+
django_static
13+
local
1114

1215
### VisualStudioCode ###
1316
.vscode/*

.gitmodules

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@
22
path = backend/apps/ifc_validation/checks/ifc_gherkin_rules
33
url = https://github.com/buildingSMART/ifc-gherkin-rules
44
branch = development
5-
[submodule "backend/apps/ifc_validation/checks/step_file_parser"]
6-
path = backend/apps/ifc_validation/checks/step_file_parser
7-
url = https://github.com/IfcOpenShell/step-file-parser
8-
branch = master
95
[submodule "backend/apps/ifc_validation_models"]
106
path = backend/apps/ifc_validation_models
117
url = https://github.com/buildingSMART/ifc-validation-data-model
128
branch = development
9+
[submodule "backend/apps/ifc_validation/checks/signatures/store"]
10+
path = backend/apps/ifc_validation/checks/signatures/store
11+
url = https://github.com/buildingsmart-certificates/validation-service-vendor-certificates

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,4 +71,6 @@ clean-all:
7171

7272
fetch-modules:
7373
git submodule update --init --recursive
74-
git submodule update --remote
74+
git submodule foreach git clean -f .
75+
git submodule foreach git reset --hard
76+
git submodule update --remote --recursive

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
# Application Structure
77

8-
The application consists of three main submodules, each hosted in separate GitHub repositories. Docker Compose is configured to automatically bind the correct submodule versions for local deployment.
8+
The application consists of two main submodules, each hosted in separate GitHub repositories. Docker Compose is configured to automatically bind the correct submodule versions for local deployment.
99

1010
### Submodules
1111

1212
Documentation of the seperate functionalities can be found within each submodule.
1313

14-
1. **File Parser**: A module within IfcOpenShell, dedicated to parsing files. https://github.com/IfcOpenShell/step-file-parser
15-
2. **Gherkin Rules**: Contains the rules for validation. It can be run independently by cloning the repository and executing:
14+
1. **Gherkin Rules**: Contains the rules for validation. It can be run independently by cloning the repository and executing:
1615
https://github.com/buildingSMART/ifc-gherkin-rules
1716

1817
```
@@ -27,7 +26,7 @@ https://github.com/buildingSMART/ifc-gherkin-rules
2726
python test/test_main.py path_to_separate_file.py # For a separate file
2827
``````
2928

30-
3. **Shared DataModel**: This module includes Django data models shared between the main repository and the Gherkin repository, serving as a submodule for both.
29+
2. **Shared DataModel**: This module includes Django data models shared between the main repository and the Gherkin repository, serving as a submodule for both.
3130
https://github.com/buildingSMART/ifc-validation-data-model
3231

3332
## Running Validation Checks
@@ -144,7 +143,7 @@ flower - Celery flower dashboard
144143

145144
```shell
146145
cd backend
147-
make install
146+
make install (or make install-macos/install-macos-m1)
148147
make start-django
149148
```
150149

backend/.env

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
DEBUG = True
1111
ENV = Development
1212
PUBLIC_URL = http://localhost:3000
13+
GHERKIN_LOG_FOLDER=.dev/gherkin_logs
1314

1415
# Django
1516
MEDIA_ROOT = .dev/files_storage
@@ -34,6 +35,7 @@ CELERY_TASK_SOFT_TIME_LIMIT = 3600
3435
CELERY_TASK_TIME_LIMIT = 4000
3536
TASK_TIMEOUT_LIMIT = 3600
3637
DJANGO_DB_USER_CONTEXT = SYSTEM
38+
DJANGO_DB_BULK_CREATE_BATCH_SIZE = 1000
3739

3840
# Email
3941
MAILGUN_API_URL = <MG_API_URL>
@@ -48,4 +50,4 @@ B2C_CLIENT_ID = <B2C_CLIENT_ID>
4850
B2C_CLIENT_SECRET = <B2C_CLIENT_SECRET>
4951
B2C_AUTHORITY = <B2C_AUTHORITY>
5052
B2C_USER_FLOW = <B2C_USER_FLOW>
51-
USE_WHITELIST = False
53+
USE_WHITELIST = False

backend/Makefile

Lines changed: 55 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
.ONESHELL:
22

33
VIRTUAL_ENV = .dev/venv
4+
PYTHON = $(VIRTUAL_ENV)/bin/python
5+
PIP = $(VIRTUAL_ENV)/bin/pip
46

57
none:
68
@echo "MAKE: Enter at least one target (venv, install, install-dev, start-backend, start-worker, clean)"
@@ -10,53 +12,74 @@ venv:
1012
test -d $(VIRTUAL_ENV) || python3.11 -m venv $(VIRTUAL_ENV)
1113

1214
install: venv
13-
. $(VIRTUAL_ENV)/bin/activate && \
14-
pip install --upgrade pip && \
15-
pip install -r requirements.txt && \
16-
wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.7.9-c18e4ea-linux64.zip" && \
17-
mkdir -p $(VIRTUAL_ENV)/lib/python3.11/site-packages && \
18-
unzip -f -d $(VIRTUAL_ENV)/lib/python3.11/site-packages /tmp/ifcopenshell_python.zip && \
15+
$(PIP) install --upgrade pip
16+
$(PIP) install -r requirements.txt
17+
wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.8.3-260bc80-linux64.zip"
18+
mkdir -p $(VIRTUAL_ENV)/lib/python3.11/site-packages
19+
unzip -f -d $(VIRTUAL_ENV)/lib/python3.11/site-packages /tmp/ifcopenshell_python.zip
20+
rm /tmp/ifcopenshell_python.zip
21+
22+
install-macos: venv
23+
$(PIP) install --upgrade pip
24+
$(PIP) install -r requirements.txt
25+
wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.8.3-260bc80-macos64.zip"
26+
mkdir -p $(VIRTUAL_ENV)/lib/python3.11/site-packages
27+
unzip /tmp/ifcopenshell_python.zip -d $(VIRTUAL_ENV)/lib/python3.11/site-packages
28+
rm /tmp/ifcopenshell_python.zip
29+
30+
install-macos-m1: venv
31+
$(PIP) install --upgrade pip
32+
$(PIP) install -r requirements.txt
33+
wget -O /tmp/ifcopenshell_python.zip "https://s3.amazonaws.com/ifcopenshell-builds/ifcopenshell-python-311-v0.8.3-260bc80-macosm164.zip"
34+
mkdir -p $(VIRTUAL_ENV)/lib/python3.11/site-packages
35+
unzip /tmp/ifcopenshell_python.zip -d $(VIRTUAL_ENV)/lib/python3.11/site-packages
1936
rm /tmp/ifcopenshell_python.zip
2037

2138
fetch-modules:
22-
cd ./apps && \
23-
git submodule update --init --recursive
39+
cd ./apps && git submodule update --init --recursive
2440

2541
start-django: start-backend
2642

2743
start-backend:
28-
. $(VIRTUAL_ENV)/bin/activate && \
29-
python3 manage.py makemigrations && \
30-
python3 manage.py migrate && \
31-
python3 manage.py runserver
44+
$(PYTHON) manage.py makemigrations
45+
$(PYTHON) manage.py migrate
46+
$(PYTHON) manage.py collectstatic --noinput
47+
$(PYTHON) manage.py runserver
3248

3349
start-worker:
34-
. $(VIRTUAL_ENV)/bin/activate && \
35-
celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker@%n
50+
$(PYTHON) -m celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker@%n
3651

3752
start-worker2:
38-
. $(VIRTUAL_ENV)/bin/activate && \
39-
celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker2@%n
53+
$(PYTHON) -m celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker2@%n
4054

4155
start-worker3:
42-
. $(VIRTUAL_ENV)/bin/activate && \
43-
celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker3@%n
56+
$(PYTHON) -m celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker3@%n
4457

4558
start-worker4:
46-
. $(VIRTUAL_ENV)/bin/activate && \
47-
celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker4@%n
59+
$(PYTHON) -m celery --app=core worker --loglevel=DEBUG --concurrency 2 --task-events --hostname=worker4@%n
4860

4961
start-worker-scheduler:
50-
. $(VIRTUAL_ENV)/bin/activate && \
51-
celery --app=core worker --loglevel=DEBUG --concurrency 5 --task-events --beat
62+
$(PYTHON) -m celery --app=core worker --loglevel=DEBUG --concurrency 5 --task-events --beat
63+
64+
test: test-models test-bsdd-task test-header-validation-task test-syntax-task test-syntax-header-validation-task test-schema-task
5265

5366
test-models:
54-
. $(VIRTUAL_ENV)/bin/activate && \
55-
python3 manage.py test apps/ifc_validation_models --settings apps.ifc_validation_models.test_settings --debug-mode --verbosity 3
67+
MEDIA_ROOT=./apps/ifc_validation/fixtures $(PYTHON) manage.py test apps/ifc_validation_models --settings apps.ifc_validation_models.test_settings --debug-mode --verbosity 3
68+
69+
test-bsdd-task:
70+
MEDIA_ROOT=./apps/ifc_validation/fixtures $(PYTHON) manage.py test apps.ifc_validation.tests.tests_bsdd_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
71+
72+
test-syntax-header-validation-task:
73+
MEDIA_ROOT=./apps/ifc_validation/fixtures $(PYTHON) manage.py test apps.ifc_validation.tests.tests_header_syntax_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
74+
75+
test-header-validation-task:
76+
MEDIA_ROOT=./apps/ifc_validation/fixtures $(PYTHON) manage.py test apps.ifc_validation.tests.tests_header_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
77+
78+
test-syntax-task:
79+
MEDIA_ROOT=./apps/ifc_validation/fixtures $(PYTHON) manage.py test apps.ifc_validation.tests.tests_header_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
5680

57-
test-tasks:
58-
. $(VIRTUAL_ENV)/bin/activate && \
59-
MEDIA_ROOT=./apps/ifc_validation/fixtures python3 manage.py test apps.ifc_validation.tests_tasks --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
81+
test-schema-task:
82+
MEDIA_ROOT=./apps/ifc_validation/fixtures $(PYTHON) manage.py test apps.ifc_validation.tests.tests_schema_validation_task --settings apps.ifc_validation.test_settings --debug-mode --verbosity 3
6083

6184
clean:
6285
rm -rf .dev
@@ -66,12 +89,8 @@ clean:
6689
find . -type d -name __pycache__ -prune -exec rm -rf {} \;
6790

6891
init-db:
69-
. $(VIRTUAL_ENV)/bin/activate && \
70-
PGPASSWORD=postgres psql -h localhost -U postgres --dbname postgres -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;" && \
71-
rm ./apps/ifc_validation_models/migrations/0001_initial.bak || true && \
72-
mv ./apps/ifc_validation_models/migrations/0001_initial.py ./apps/ifc_validation_models/migrations/0001_initial.bak || true && \
73-
rm ./apps/ifc_validation_models/migrations/0001_initial.bak || true && \
74-
python3 manage.py makemigrations && \
75-
python3 manage.py migrate && \
76-
DJANGO_SUPERUSER_USERNAME=root DJANGO_SUPERUSER_PASSWORD=root DJANGO_SUPERUSER_EMAIL=root@localhost python3 manage.py createsuperuser --noinput && \
77-
DJANGO_SUPERUSER_USERNAME=SYSTEM DJANGO_SUPERUSER_PASSWORD=system DJANGO_SUPERUSER_EMAIL=system@localhost python3 manage.py createsuperuser --noinput
92+
PGPASSWORD=postgres psql -h localhost -U postgres --dbname postgres -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public;"
93+
$(PYTHON) manage.py makemigrations
94+
$(PYTHON) manage.py migrate
95+
DJANGO_SUPERUSER_USERNAME=root DJANGO_SUPERUSER_PASSWORD=root DJANGO_SUPERUSER_EMAIL=root@localhost $(PYTHON) manage.py createsuperuser --noinput
96+
DJANGO_SUPERUSER_USERNAME=SYSTEM DJANGO_SUPERUSER_PASSWORD=system DJANGO_SUPERUSER_EMAIL=system@localhost $(PYTHON) manage.py createsuperuser --noinput

backend/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
1. Syntax Validation
66

77
```shell
8-
python3 apps/ifc_validation/checks/step_file_parser/main.py --json filename
8+
python3 -m ifcopenshell.simple_spf --json filename
99
```
1010

1111
2. Parse Info

0 commit comments

Comments
 (0)