Skip to content

Commit

Permalink
First version moved to bzkf org
Browse files Browse the repository at this point in the history
  • Loading branch information
chgl committed Nov 19, 2024
1 parent 606ebf1 commit ffb9381
Show file tree
Hide file tree
Showing 34 changed files with 1,897 additions and 1 deletion.
33 changes: 33 additions & 0 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: benchmark

on:
workflow_dispatch: {}

permissions: read-all

jobs:
benchmark:
runs-on: ubuntu-24.04
env:
SYNTHEA_POPULATION_SIZE: "100"
steps:
- name: Checkout
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0

- name: Install Task
uses: arduino/setup-task@b91d5d2c96a56797b48ac1e0e89220bf64044611 # v2.0.0
with:
version: "3.38.0"

- name: Run benchmark
run: |
task run
- name: Upload results
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: benchmark-results
path: |
src/results/
186 changes: 186 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,186 @@
# Created by https://www.toptal.com/developers/gitignore/api/python
# Edit at https://www.toptal.com/developers/gitignore?templates=python

### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
cover/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
.pybuilder/
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
# For a library or package, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in:
# .python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# poetry
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
# This is especially recommended for binary packages to ensure reproducibility, and is more
# commonly ignored for libraries.
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
#poetry.lock

# pdm
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/#use-with-ide
.pdm.toml

# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/

# pytype static type analyzer
.pytype/

# Cython debug symbols
cython_debug/

# PyCharm
# JetBrains specific template is maintained in a separate JetBrains.gitignore that can
# be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/

### Python Patch ###
# Poetry local configuration file - https://python-poetry.org/docs/configuration/#local-configuration
poetry.toml

# ruff
.ruff_cache/

# LSP config files
pyrightconfig.json

# End of https://www.toptal.com/developers/gitignore/api/python

*.jar
output/
blazectl


results/
spark-tmp/

synthea/
8 changes: 8 additions & 0 deletions .sqlfluff
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[sqlfluff]
dialect = trino
max_line_length = 120
# RF01 doesn't really work with structs.
exclude_rules = RF01

[sqlfluff:rules:capitalisation.identifiers]
extended_capitalisation_policy = lower
16 changes: 16 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python Debugger: Current File",
"type": "debugpy",
"request": "launch",
"program": "${file}",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/src"
}
]
}
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"sqlfluff.executablePath": ".venv/bin/sqlfluff"
}
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
# analytics-on-fhir-benchmark
# Analytics on FHIR Benchmark

## Setup

```sh
git clone https://github.com/bzkf/analytics-on-fhir-benchmark.git
cd analytics-on-fhir-benchmark/
./setup.sh

task run
```
81 changes: 81 additions & 0 deletions Taskfile.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
version: "3"

env:
SYNTHEA_POPULATION_SIZE: 1000

vars:
# only here as a comment. not yet used to loop through all at once.
SYNTHEA_POPULATION_SIZES:
- 1000
- 5000
- 10000
- 50000
- 100000

tasks:
install-dependencies:
cmds:
- curl -LO https://github.com/synthetichealth/synthea/releases/download/master-branch-latest/synthea-with-dependencies.jar
- curl -LO https://repo1.maven.org/maven2/io/trino/trino-cli/453/trino-cli-453-executable.jar
- curl -LO https://github.com/samply/blazectl/releases/download/v0.16.0/blazectl-0.16.0-linux-amd64.tar.gz
- tar xzf blazectl-0.16.0-linux-amd64.tar.gz
- rm blazectl-0.16.0-linux-amd64.tar.gz
- ./blazectl --version
- pip install -r requirements.txt
generates:
- synthea-with-dependencies.jar
- blazectl
- trino-cli-453-executable.jar

# TODO: could use a task loop to generate synthea data for all sizes at once.
generate-fhir-data:
cmds:
- java -jar synthea-with-dependencies.jar -s 20240711 -cs 20240711 -r 20240711 -p "${SYNTHEA_POPULATION_SIZE}" -c config/synthea.properties --exporter.baseDirectory="./synthea/output-${SYNTHEA_POPULATION_SIZE}/bulk" --exporter.fhir.bulk_data="true"
- java -jar synthea-with-dependencies.jar -s 20240711 -cs 20240711 -r 20240711 -p "${SYNTHEA_POPULATION_SIZE}" -c config/synthea.properties --exporter.baseDirectory="./synthea/output-${SYNTHEA_POPULATION_SIZE}/transactions" --exporter.fhir.bulk_data="false"

start-servers:
cmds:
- docker compose -f compose.blaze.yaml -f compose.pathling.yaml -f compose.trino.yaml up -d
# after the import is done, we no longer need the pathling server itself
- docker compose -f compose.pathling.yaml stop pathling

upload-fhir-data:
cmds:
# blaze
# hospitalInformation & practitionerInformation are required for referential integrity.
- curl -X POST --header 'Content-Type:application/fhir+json' --data @"$(find synthea/output-${SYNTHEA_POPULATION_SIZE}/transactions/fhir/ -name 'hospitalInformation*.json')" --url 'http://localhost:8084/fhir'
- curl -X POST --header 'Content-Type:application/fhir+json' --data @"$(find synthea/output-${SYNTHEA_POPULATION_SIZE}/transactions/fhir/ -name 'practitionerInformation*.json')" --url 'http://localhost:8084/fhir'
- ./blazectl upload --concurrency 32 synthea/output-${SYNTHEA_POPULATION_SIZE}/transactions/fhir/ --server http://localhost:8084/fhir
# hapi fhir jpa
# - curl -X POST --header 'Content-Type:application/fhir+json' --data @"$(find output/transactions/fhir/ -name 'hospitalInformation*.json')" --url 'http://localhost:8084/fhir'
# - curl -X POST --header 'Content-Type:application/fhir+json' --data @"$(find output/transactions/fhir/ -name 'practitionerInformation*.json')" --url 'http://localhost:8084/fhir'
# - ./blazectl upload output/transactions/fhir/ --server http://localhost:8084/fhir

remove-local-synthea-files:
cmds:
- rm -r synthea/

run-benchmarks:
dir: src/
cmds:
- python main.py

draw-plots:
dir: src/
cmds:
- python plot.py

run:
cmds:
- task: install-dependencies
- task: generate-fhir-data
- task: start-servers
- task: upload-fhir-data
- task: remove-local-synthea-files
- task: run-benchmarks
- task: draw-plots
- task: clean

clean:
cmds:
- docker compose -f compose.blaze.yaml -f compose.pathling.yaml -f compose.trino.yaml down -v --remove-orphans
35 changes: 35 additions & 0 deletions compose.blaze.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
services:
blaze:
image: docker.io/samply/blaze:0.29.3@sha256:47527f478ef2ddf932f4e5c882c0266ac179d7a2fc37ed66868d079698541da3
environment:
JAVA_TOOL_OPTIONS: "-Xmx64g"
BASE_URL: "http://localhost:8083"
volumes:
- "blaze-data:/app/data"
ports:
- "127.0.0.1:8083:8080"

wait-for-blaze:
image: docker.io/curlimages/curl:8.8.0@sha256:73e4d532ea62d7505c5865b517d3704966ffe916609bedc22af6833dc9969bcd
ipc: none
security_opt:
- "no-new-privileges:true"
cap_drop:
- ALL
privileged: false
restart: "no"
environment:
BLAZE_SERVER_URL: http://blaze:8080
entrypoint: ["/bin/sh", "-c"]
command:
- |
until [ "$(curl -s -o /dev/null -L -w "%{http_code}" "$$BLAZE_SERVER_URL/fhir/metadata")" == "200" ]; do
echo "$(date): Waiting for blaze server @ $$BLAZE_SERVER_URL to be up";
sleep 5;
done;
depends_on:
blaze:
condition: service_started

volumes:
blaze-data: {}
Loading

0 comments on commit ffb9381

Please sign in to comment.