Skip to content

Commit d04cf37

Browse files
committed
feat: add ci, update cbc
1 parent 79a2936 commit d04cf37

File tree

3 files changed

+125
-35
lines changed

3 files changed

+125
-35
lines changed

.github/workflows/ci.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: CI
2+
on:
3+
push:
4+
branches:
5+
- "main"
6+
pull_request:
7+
8+
env:
9+
REGISTRY: ghcr.io
10+
IMAGE_NAME: ${{ github.repository }}
11+
12+
jobs:
13+
lint-python:
14+
name: Lint Python
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up Python
20+
uses: actions/setup-python@v5
21+
with:
22+
cache: "pip"
23+
24+
- name: Run flake8
25+
uses: py-actions/flake8@v2
26+
27+
validate-compute-block:
28+
name: Validate Compute Block Config
29+
runs-on: ubuntu-latest
30+
needs: lint-python
31+
steps:
32+
- uses: actions/checkout@v4
33+
34+
- name: Set up Python
35+
uses: actions/setup-python@v5
36+
37+
- name: Intall dependencies
38+
run: |
39+
pip install -r requirements.txt
40+
41+
- name: Check cbcs
42+
run: |
43+
python3 - <<'EOF'
44+
import main
45+
46+
from scystream.sdk.config import load_config, get_compute_block
47+
from scystream.sdk.config.config_loader import _compare_configs
48+
from pathlib import Path
49+
50+
CBC_PATH = Path("cbc.yaml")
51+
52+
if not CBC_PATH.exists():
53+
raise FileNotFoundError("cbc.yaml not found in repo root.")
54+
55+
block_from_code = get_compute_block()
56+
block_from_yaml = load_config(str(CBC_PATH))
57+
58+
_compare_configs(block_from_code, block_from_yaml)
59+
60+
print("cbc.yaml matches python code definition")
61+
EOF
62+
63+
build:
64+
name: Build docker image
65+
runs-on: ubuntu-latest
66+
needs: run-test
67+
permissions:
68+
contents: read
69+
packages: write
70+
steps:
71+
- name: Checkout Repository
72+
uses: actions/checkout@v4
73+
74+
- name: Log in to Docker Hub
75+
uses: docker/login-action@v3
76+
with:
77+
registry: ${{ env.REGISTRY }}
78+
username: ${{ github.actor }}
79+
password: ${{ secrets.GITHUB_TOKEN }}
80+
81+
- name: Extract metadata for docker
82+
id: meta
83+
uses: docker/metadata-action@v5
84+
with:
85+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}/database-interactions
86+
tags: |
87+
type=ref, event=pr
88+
type=raw, value=latest, enable=${{ (github.ref == format('refs/heads/{0}', 'main')) }}
89+
90+
- name: Build and push Docker image
91+
uses: docker/build-push-action@v5
92+
with:
93+
push: true
94+
tags: ${{ steps.meta.outputs.tags }}
95+
labels: ${{ steps.meta.outputs.labels }}
96+

cbc.yaml

Lines changed: 27 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,58 @@
11
author: Anna Beckers
2-
description: Query the PatstatDB to a CSV
2+
description: Query DB to a CSV
33
docker_image: registry.git.rwth-aachen.de/tim-institute/literature-analysis-pipeline/patstat-compute-block/patstatcb
4-
name: Patstat Compute Block
4+
name: Database Interactions
55
entrypoints:
6-
run_query:
7-
description: Run the query by directly passing an SQL Query
6+
run_query_from_file:
7+
description: Run the query using a file containing the query
88
envs:
9-
PATSTAT_DB: patstat
10-
PATSTAT_HOST: 134.130.176.139
11-
PATSTAT_PORT: 5432
12-
PATSTAT_USER: guest
9+
DB_DSN: null
1310
inputs:
14-
query_str:
11+
query_file:
1512
config:
16-
QUERY: ''
17-
description: Pass your SQL-Query here
18-
type: custom
13+
query_file_BUCKET_NAME: null
14+
query_file_FILE_EXT: null
15+
query_file_FILE_NAME: null
16+
query_file_FILE_PATH: null
17+
query_file_S3_ACCESS_KEY: null
18+
query_file_S3_HOST: null
19+
query_file_S3_PORT: null
20+
query_file_S3_SECRET_KEY: null
21+
description: txt file containing the SQL query
22+
type: file
1923
outputs:
2024
csv_output:
2125
config:
2226
csv_output_BUCKET_NAME: null
23-
csv_output_FILE_EXT: null
27+
csv_output_FILE_EXT: csv
2428
csv_output_FILE_NAME: null
2529
csv_output_FILE_PATH: null
2630
csv_output_S3_ACCESS_KEY: null
2731
csv_output_S3_HOST: null
2832
csv_output_S3_PORT: null
2933
csv_output_S3_SECRET_KEY: null
30-
description: The CSV-File of the queries result
34+
description: CSV of the queries result
3135
type: file
32-
run_query_from_file:
33-
description: Run the query using a txt file
36+
run_query_from_string:
37+
description: Run the query directly by passing an SQL Query
3438
envs:
35-
PATSTAT_DB: patstat
36-
PATSTAT_HOST: 134.130.176.139
37-
PATSTAT_PORT: 5432
38-
PATSTAT_USER: guest
39+
DB_DSN: null
3940
inputs:
40-
query_file:
41+
query_str:
4142
config:
42-
query_file_BUCKET_NAME: null
43-
query_file_FILE_EXT: null
44-
query_file_FILE_NAME: null
45-
query_file_FILE_PATH: null
46-
query_file_S3_ACCESS_KEY: null
47-
query_file_S3_HOST: null
48-
query_file_S3_PORT: null
49-
query_file_S3_SECRET_KEY: null
50-
description: Pass the txt file here including your SQL Query
51-
type: file
43+
QUERY: ''
44+
description: Pass your SQL-Query here
45+
type: custom
5246
outputs:
5347
csv_output:
5448
config:
5549
csv_output_BUCKET_NAME: null
56-
csv_output_FILE_EXT: null
50+
csv_output_FILE_EXT: csv
5751
csv_output_FILE_NAME: null
5852
csv_output_FILE_PATH: null
5953
csv_output_S3_ACCESS_KEY: null
6054
csv_output_S3_HOST: null
6155
csv_output_S3_PORT: null
6256
csv_output_S3_SECRET_KEY: null
63-
description: The CSV-File of the queries result
57+
description: CSV of the queries result
6458
type: file

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
scystream-sdk==1.2.1
22
SQLAlchemy==2.0.43
33
psycopg2-binary==2.9.10
4-
PYMSQL==1.1.2
4+
PyMySQL==1.1.2
55
duckdb==1.4.1
6-
cx-Oracle==8.3.0
76
pyodbc==5.2.0
87
snowflake-sqlalchemy==1.7.7
8+
oracledb==3.4.2

0 commit comments

Comments
 (0)