Skip to content

Commit c8a2462

Browse files
committed
wip
1 parent 876c8a0 commit c8a2462

35 files changed

+132
-19873
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Deploy Web Application
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
trigger-build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Trigger build in Repo A
14+
id: trigger-build
15+
run: |
16+
curl -L \
17+
-X POST \
18+
-H "Accept: application/vnd.github+json" \
19+
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
20+
-H "X-GitHub-Api-Version: 2022-11-28" \
21+
https://api.github.com/repos/lingo-db/lingo-db/actions/workflows/release-for-webinterface.yml/dispatches \
22+
-d '{"ref":"b0d8f7a"}'
23+
24+
- name: Wait for a few seconds
25+
run: sleep 5
26+
27+
- name: Get workflow run ID
28+
id: get-run-id
29+
run: |
30+
run_id=$(curl -L \
31+
-H "Accept: application/vnd.github+json" \
32+
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
33+
-H "X-GitHub-Api-Version: 2022-11-28" \
34+
https://api.github.com/repos/lingo-db/lingo-db/actions/workflows/release-for-webinterface.yml/runs \
35+
| jq -r '.workflow_runs[0].id')
36+
echo "::set-output name=run_id::$run_id"
37+
38+
wait-for-build:
39+
runs-on: ubuntu-latest
40+
needs: trigger-build
41+
42+
steps:
43+
- name: Wait for build completion
44+
id: wait-for-build
45+
run: |
46+
while true; do
47+
status=$(curl -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
48+
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }} \
49+
| jq -r '.status')
50+
if [ "$status" == "completed" ]; then
51+
conclusion=$(curl -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
52+
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }} \
53+
| jq -r '.conclusion')
54+
if [ "$conclusion" == "success" ]; then
55+
echo "Build completed successfully."
56+
break
57+
else
58+
echo "Build failed."
59+
exit 1
60+
fi
61+
else
62+
echo "Build in progress..."
63+
sleep 30
64+
fi
65+
done
66+
67+
- name: List artifacts from specific run in Repo A
68+
id: list-artifacts
69+
run: |
70+
artifacts=$(curl -L \
71+
-H "Accept: application/vnd.github+json" \
72+
-H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
73+
-H "X-GitHub-Api-Version: 2022-11-28" \
74+
https://api.github.com/repos/lingo-db/lingo-db/actions/runs/${{ needs.trigger-build.outputs.run_id }}/artifacts)
75+
echo "$artifacts" > artifacts.json
76+
77+
- name: Extract artifact URL
78+
id: extract-url
79+
run: |
80+
artifact_url=$(jq -r '.artifacts[0].archive_download_url' artifacts.json)
81+
echo "::set-output name=url::$artifact_url"
82+
83+
- name: Download artifacts from Repo A
84+
run: |
85+
curl -L -o artifacts.zip -H "Authorization: Bearer ${{ secrets.LINGODB_TOKEN }}" \
86+
${{ steps.extract-url.outputs.url }}
87+
unzip artifacts.zip -d ./artifacts

Dockerfile

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
1-
FROM gitlab.db.in.tum.de:5005/lingo-db/lingo-db/lingodb:latest
2-
RUN pip install fastapi uvicorn
1+
FROM ubuntu:latest
2+
RUN apt-get update && apt-get install -y python3-pip python3-venv
3+
ENV VIRTUAL_ENV=/root/venv
4+
RUN python3 -m venv $VIRTUAL_ENV
5+
RUN $VIRTUAL_ENV/bin/pip install fastapi uvicorn pyarrow===14.0.0 tbb-devel==2021.11.0
36
ENV DATA_ROOT="/data/"
4-
ENV LINGODB_BINARY_DIR="/build/lingodb/"
7+
ENV LINGODB_BINARY_DIR="/lingodb/"
8+
ENV LINGODB_SCRIPT_DIR="/scripts/"
9+
ENV LD_LIBRARY_PATH=$VIRTUAL_ENV/lib:$VIRTUAL_ENV/lib/python3.12/site-packages/pyarrow:$LD_LIBRARY_PATH
510
RUN mkdir /webinterface
611
COPY backend/backend.py /webinterface/backend.py
7-
COPY frontend/build /webinterface/frontend
12+
COPY docker-build/frontend /webinterface/frontend
13+
COPY docker-build/lingodb-binaries /lingodb
14+
RUN mkdir /scripts
15+
COPY clean-snapshot.sh /scripts/clean-snapshot.sh
816
RUN find /webinterface
917
WORKDIR /webinterface
10-
ENTRYPOINT ["uvicorn", "backend:app","--host", "0.0.0.0","--port","80"]
18+
ENTRYPOINT ["/root/venv/bin/uvicorn" , "backend:app","--host", "0.0.0.0","--port","80"]

backend/backend.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def run_sql_query(query_str, db):
6262

6363
# Execute command and capture output
6464
output = subprocess.check_output(cmd, universal_newlines=True, stderr=subprocess.STDOUT, timeout=20,
65-
env={"LINGODB_PARALLELISM": "4"})
65+
env={**os.environ,"LINGODB_PARALLELISM": "4"})
6666
# Parse output and skip first and last 4 lines
6767
splitted = output.split("\n")
6868
header_list = splitted[-2].split()
@@ -107,7 +107,7 @@ async def analyze(database: str = Body(...), query: str = Body(...), real_card:
107107
print(BINARY_DIR + "run-sql " + query_file + " " + DATA_ROOT + database)
108108
output = subprocess.check_output([BINARY_DIR + "run-sql", query_file, DATA_ROOT + database],
109109
universal_newlines=True, stderr=subprocess.STDOUT, timeout=20,
110-
env={"LINGODB_SNAPSHOT_DIR": snapshotdir,
110+
env={**os.environ,"LINGODB_SNAPSHOT_DIR": snapshotdir,
111111
"LINGODB_SNAPSHOT_PASSES": "true",
112112
"LINGODB_SNAPSHOT_LEVEL": "important",
113113
"LINGODB_EXECUTION_MODE": "NONE"})

clean-snapshot.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
3+
# Ensure the script is called with two arguments
4+
if [[ $# -ne 3 ]]; then
5+
echo "Usage: $0 <binary_dir> <source_file> <target_file>"
6+
exit 1
7+
fi
8+
9+
binary_dir=$1
10+
source_file="$2"
11+
target_file="$3"
12+
${binary_dir}/mlir-db-opt --strip-debuginfo ${source_file} > ${target_file}
13+
14+
15+
16+
# Count lines starting with "#loc" continuously from the beginning
17+
count=$(awk '!/^#loc/{exit} {count++} END {print count}' ${source_file})
18+
19+
# Create a real temporary file for the empty lines
20+
temp_file=$(mktemp)
21+
22+
# Generate the empty lines and write them to the temporary file
23+
for ((i=0; i<count; i++)); do echo ""; done > ${temp_file}
24+
25+
# Prepend the empty lines to the target file
26+
cat ${target_file} >> ${temp_file} && mv ${temp_file} ${target_file}
27+
28+

frontend-old/.gitignore

Lines changed: 0 additions & 24 deletions
This file was deleted.

frontend-old/README.md

Lines changed: 0 additions & 46 deletions
This file was deleted.

frontend-old/index.js

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)