Skip to content

Commit b84dcee

Browse files
committed
replace superset with evidence
1 parent e2f9ff7 commit b84dcee

17 files changed

+11020
-369
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"version": "1.0",
3+
"customFormats": []
4+
}

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,3 +89,8 @@ $RECYCLE.BIN/
8989

9090
assets/*
9191
!assets/.gitkeep
92+
*.duckdb
93+
.evidence/template
94+
.svelte-kit
95+
build
96+
node_modules

README.md

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# in⚡️ight
22

3-
A simple data project using [dbt](https://getdbt.com), [DuckDB](https://duckdb.org/) and [Superset](https://superset.apache.org/) to analyse your electricity data from Belgian smart meters.
3+
A simple data project using [dbt](https://getdbt.com), [DuckDB](https://duckdb.org/) and [Evidence](https://evidence.dev/) to analyse your electricity data from Belgian smart meters.
44

55
Thanks to [Jacob Matson](https://github.com/matsonj) for [his blog post](https://www.dataduel.co/modern-data-stack-in-a-box-with-duckdb/) that inspired all of this.
66

@@ -12,14 +12,18 @@ The dbt documentation is available at [https://sdebruyn.github.io/inzight](https
1212

1313
### Requirements
1414

15-
* Python 3.8 or newer
16-
* Docker (for Superset)
15+
* Python 3.8 or newer (dbt & DuckDB)
16+
* NPM 7 or newer and Node.JS 14 or newer (Evidence)
1717
* Your source data (see below)
1818

1919
### Setup
2020

21-
1. Clone with all submodules: `git clone --recurse-submodules https://github.com/sdebruyn/inzight.git`
22-
1. Install the dependencies: `pip install -r requirements.txt`
21+
1. Clone the repo: `git clone https://github.com/sdebruyn/inzight.git`
22+
1. Install the dependencies:
23+
```bash
24+
pip install -r requirements.txt
25+
npm install
26+
```
2327
1. Create a profile named `inzight` in `~/.dbt/profiles.yml` with the following content:
2428

2529
```yaml
@@ -29,8 +33,7 @@ The dbt documentation is available at [https://sdebruyn.github.io/inzight](https
2933
dev:
3034
type: duckdb
3135
threads: 12 # should be the number of cores in your system (or double if you have hyperthreading)
32-
database: /tmp/inzight.duckdb # or any other path on your system
33-
external_root: /Users/Quack/code/inzight/assets # point to the assets folder in this repo
36+
database: /path_to_the_project/inzight.duckdb # point to the project folder
3437
```
3538

3639
### Source data
@@ -44,16 +47,7 @@ My column names are in Dutch, I have no idea what you get if you have a differen
4447
1. Make sure your source data has been added as a file named `assets/fluvius.csv`
4548
1. Run `dbt deps` to install the dbt package dependencies
4649
1. Run `dbt build` to create all models
47-
1. Run `docker compose up -d` to start Superset
48-
1. Open `http://localhost:8088` in your browser to go to Superset
49-
1. Log in with the default credentials: `admin` / `admin`
50-
1. Create a new database (*Settings > Database Connections*) with the following settings:
51-
52-
| Setting | Value |
53-
| --- | --- |
54-
| Display Name | `inzight` |
55-
| SQLAlchemy URI | `duckdb:///:memory:` |
56-
1. Register the data marts in Superset as the following query: `select * from '/app/assets/name_of_the_mart.parquet';`
50+
1. Run `npm run dev` to start the Evidence server and open the dashboards in your browser
5751

5852
## Note
5953

@@ -62,5 +56,3 @@ It's (like most hobby projects) a never-ending work in progress. Contributions a
6256
## License
6357
6458
MIT License
65-
66-
Code under `superset/` is licensed under the Apache License 2.0 and taken from the [Superset repository](https://github.com/apache/superset)

dbt_project.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ dispatch:
1515
models:
1616
inzight:
1717
marts:
18-
+materialized: external
18+
+materialized: table

docker-compose.yml

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

models/marts/marts.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,22 @@ models:
4242
description: Average of the last 12 peak values including this month (used for your capacity tariff)
4343
tests:
4444
- not_null
45+
- name: month_name_short
46+
description: Short name of the month
47+
tests:
48+
- not_null
49+
- name: month_name
50+
description: Name of the month
51+
tests:
52+
- not_null
53+
- name: month_start_date
54+
description: Start date of the month
55+
tests:
56+
- not_null
57+
- name: pct_change
58+
description: Percentage change of the peak value compared to previous month
59+
tests:
60+
- dbt_utils.at_least_one
4561

4662
- name: mrt_validated
4763
description: |

models/marts/mrt_capacity_tariff.sql

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,14 @@ with usage_data as (
77

88
components as (
99
select
10-
month(from_timestamp) as month,
11-
year(from_timestamp) as year,
12-
from_timestamp,
13-
usage * 4 as quarter_power
14-
from usage_data
10+
month(u.from_timestamp) as month,
11+
year(u.from_timestamp) as year,
12+
u.from_timestamp,
13+
u.usage * 4 as quarter_power,
14+
dd.*
15+
from usage_data u
16+
left join {{ ref('dim_dates') }} dd
17+
on u.from_timestamp::date = dd.date_day
1518
),
1619

1720
month_peaks as (
@@ -23,19 +26,29 @@ month_peaks as (
2326
group by month, year
2427
),
2528

29+
with_avg as (
30+
select
31+
d.month as month,
32+
d.year as year,
33+
d.month_name as month_name,
34+
d.month_name_short as month_name_short,
35+
d.month_start_date as month_start_date,
36+
d.from_timestamp as month_peak_timestamp,
37+
d.from_timestamp::date as month_peak_date,
38+
p.month_peak as month_peak_value,
39+
avg(p.month_peak) over (rows between 11 preceding and current row) as month_peak_12month_avg,
40+
from components d
41+
join month_peaks p
42+
on d.month = p.month
43+
and d.year = p.year
44+
and d.quarter_power = p.month_peak
45+
),
46+
2647
final as (
2748
select
28-
components.month as month,
29-
components.year as year,
30-
components.from_timestamp as month_peak_timestamp,
31-
components.from_timestamp::date as month_peak_date,
32-
month_peaks.month_peak as month_peak_value,
33-
avg(month_peaks.month_peak) over (rows between 11 preceding and current row) as month_peak_12month_avg
34-
from components
35-
join month_peaks
36-
on components.month = month_peaks.month
37-
and components.year = month_peaks.year
38-
and components.quarter_power = month_peaks.month_peak
49+
*,
50+
(month_peak_value - lag(month_peak_value) over (order by month_start_date)) / lag(month_peak_value) over (order by month_start_date) as pct_change
51+
from with_avg
3952
)
4053

4154
select *

models/overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ Welcome to the auto-generated documentation for [In⚡️ight](https://github.co
66

77
#### Available datasets
88

9-
The available datasets can be found in the marts folder in the project. These are materialized as parquet files in the assets folder.
9+
The available datasets can be found in the marts folder in the project.
1010

1111
{% enddocs %}

0 commit comments

Comments
 (0)