Skip to content

Commit c7c0fbe

Browse files
committed
Time Series QA: Add CI configuration
1 parent 070f079 commit c7c0fbe

File tree

8 files changed

+193
-2
lines changed

8 files changed

+193
-2
lines changed

.github/dependabot.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ updates:
9797
schedule:
9898
interval: "weekly"
9999

100+
- directory: "/topic/timeseries"
101+
package-ecosystem: "pip"
102+
schedule:
103+
interval: "weekly"
104+
100105
# Testing.
101106

102107
- directory: "/testing/testcontainers/java"

.github/workflows/timeseries.yml

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Time Series
2+
3+
on:
4+
pull_request:
5+
branches: ~
6+
paths:
7+
- '.github/workflows/timeseries.yml'
8+
- 'topic/timeseries/**'
9+
- 'requirements.txt'
10+
push:
11+
branches: [ main ]
12+
paths:
13+
- '.github/workflows/timeseries.yml'
14+
- 'topic/timeseries/**'
15+
- 'requirements.txt'
16+
17+
# Allow job to be triggered manually.
18+
workflow_dispatch:
19+
20+
# Run job each night after CrateDB nightly has been published.
21+
schedule:
22+
- cron: '0 3 * * *'
23+
24+
# Cancel in-progress jobs when pushing to the same branch.
25+
concurrency:
26+
cancel-in-progress: true
27+
group: ${{ github.workflow }}-${{ github.ref }}
28+
29+
jobs:
30+
test:
31+
name: "
32+
Python: ${{ matrix.python-version }}
33+
CrateDB: ${{ matrix.cratedb-version }}
34+
on ${{ matrix.os }}"
35+
runs-on: ${{ matrix.os }}
36+
strategy:
37+
fail-fast: false
38+
matrix:
39+
os: [ 'ubuntu-latest' ]
40+
python-version: [ '3.11' ]
41+
cratedb-version: [ 'nightly' ]
42+
43+
services:
44+
cratedb:
45+
image: crate/crate:${{ matrix.cratedb-version }}
46+
ports:
47+
- 4200:4200
48+
- 5432:5432
49+
env:
50+
CRATE_HEAP_SIZE: 4g
51+
52+
env:
53+
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
54+
55+
steps:
56+
57+
- name: Acquire sources
58+
uses: actions/checkout@v4
59+
60+
- name: Set up Python
61+
uses: actions/setup-python@v5
62+
with:
63+
python-version: ${{ matrix.python-version }}
64+
architecture: x64
65+
cache: 'pip'
66+
cache-dependency-path: |
67+
requirements.txt
68+
topic/timeseries/requirements.txt
69+
topic/timeseries/requirements-dev.txt
70+
71+
- name: Install utilities
72+
run: |
73+
pip install -r requirements.txt
74+
75+
- name: Validate topic/timeseries
76+
run: |
77+
ngr test --accept-no-venv topic/timeseries

topic/timeseries/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,28 @@ repository, e.g. about machine learning, to see predictions and AutoML in action
4848
To ensure the dashboard functions correctly, it's necessary to configure the data source within Grafana. This dashboard uses the `grafana-postgresql-datasource` or another configured default data source. In the data source settings, fill in the necessary parameters to connect to your CrateDB instance. This includes setting up the database name (`database=doc`), user, password, and host.
4949

5050

51+
## Software Tests
52+
53+
For running the software tests, install a development sandbox in this
54+
folder, also satisfying all the dependencies.
55+
```console
56+
python3 -m venv .venv
57+
source .venv/bin/activate
58+
pip install -r requirements.txt -r requirements-dev.txt
59+
```
60+
61+
Then, invoke the software tests, roughly validating all notebooks within
62+
this folder, by running them to completion.
63+
```console
64+
time pytest
65+
```
66+
67+
In order to run tests for individual notebooks by name, use the
68+
`-k` option for selecting by name fragment.
69+
```console
70+
time pytest -k explo
71+
time pytest -k visu
72+
```
73+
74+
5175
[CrateDB]: https://github.com/crate/crate

topic/timeseries/conftest.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import os
2+
from pathlib import Path
3+
4+
import pytest
5+
import sqlalchemy as sa
6+
from pueblo.testing.notebook import generate_tests
7+
8+
9+
def pytest_generate_tests(metafunc):
10+
"""
11+
Generate pytest test case per Jupyter Notebook.
12+
"""
13+
here = Path(__file__).parent
14+
generate_tests(metafunc, path=here)
15+
16+
17+
@pytest.fixture(autouse=True)
18+
def reset_database_tables():
19+
"""
20+
Before running a test case, reset relevant tables in database.
21+
"""
22+
23+
connection_string = os.environ.get("CRATEDB_CONNECTION_STRING")
24+
25+
engine = sa.create_engine(connection_string, echo=os.environ.get("DEBUG"))
26+
connection = engine.connect()
27+
28+
reset_tables = [
29+
"cities",
30+
"weather_data",
31+
"weather_stations",
32+
]
33+
34+
for table in reset_tables:
35+
connection.execute(sa.text(f"DROP TABLE IF EXISTS {table};"))

topic/timeseries/pyproject.toml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
[tool.pytest.ini_options]
2+
minversion = "2.0"
3+
addopts = """
4+
-rfEX -p pytester --strict-markers --verbosity=3 --capture=no
5+
"""
6+
env = [
7+
"CRATEDB_CONNECTION_STRING=crate://crate@localhost/?schema=notebook",
8+
"PYDEVD_DISABLE_FILE_VALIDATION=1",
9+
]
10+
11+
log_level = "DEBUG"
12+
log_cli_level = "DEBUG"
13+
14+
testpaths = [
15+
"*.py",
16+
]
17+
xfail_strict = true
18+
markers = [
19+
]
20+
21+
[tool.coverage.run]
22+
branch = false
23+
24+
[tool.coverage.report]
25+
fail_under = 0
26+
show_missing = true
27+
omit = [
28+
"conftest.py",
29+
"test*.py",
30+
]

topic/timeseries/requirements-dev.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Real.
2+
# pueblo[notebook,testing]>=0.0.7
3+
4+
# Development.
5+
pueblo[notebook,testing] @ git+https://github.com/pyveci/pueblo.git@amo/testbook

topic/timeseries/requirements.txt

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1-
pycaret>=3.0
2-
refinitiv-data
31
crate[sqlalchemy]==0.34.0
2+
refinitiv-data<1.7
3+
pandas<2
4+
pycaret>=3.0,<3.4
5+
pydantic<2
6+
sqlalchemy<2

topic/timeseries/test.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import pytest
2+
from testbook import testbook
3+
4+
5+
def test_notebook(notebook):
6+
"""
7+
Execute Jupyter Notebook, one test case per .ipynb file.
8+
"""
9+
if notebook.name == "dask-weather-data-import.ipynb":
10+
raise pytest.skip("Depends on DOWNLOAD_PATH/daily_weather.parquet")
11+
with testbook(notebook) as tb:
12+
tb.execute()

0 commit comments

Comments
 (0)