Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Packaging the project #18

Merged
merged 21 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@

name : Deploy Panel App

concurrency: production

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
deploy:
name: Deploy Panel App
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up SSH
run: |
mkdir -p ~/.ssh/
echo "${{secrets.SSH_PRIVATE_KEY}}" > ~/.ssh/id_ed25519
chmod 600 ~/.ssh/id_ed25519
ssh-keyscan -t ed25519 -H ${{secrets.PROD_IP}} >> ~/.ssh/known_hosts

- name: Deploy to Server
run: |
ssh ubuntu@${{secrets.PROD_IP}} << 'EOF'
# Arrêter le serveur Panel
pkill -f 'streamlit run'
cd ${{vars.PROD_PATH}}
git pull
git lfs pull
nohup hatch run serve:prod </dev/null >./log-prod.log 2>&1 &
EOF
40 changes: 40 additions & 0 deletions .github/workflows/page_deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: documentation

on: [push, pull_request, workflow_dispatch]

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

jobs:
docs:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
- name: Install dependencies
run: |
sudo apt update
sudo apt install pandoc
sudo apt install pipx
pipx install hatch
- name: sphinx build
run: |
hatch run docs:build
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
# Upload entire repository
path: './doc/_build'
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,3 +160,6 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
notebooks/weather/forcasts/*.parquet
data/bronze/*/*.xls
data/bronze/*.xls
doc/_build
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"taipyStudio.gUI.elementsFilePaths": []
}
76 changes: 75 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,75 @@
# energetic-stress-production
# Forecast of French electric mix

The aim of this project is to forecast the French electric mix for the next few days.

The electric mix is the relative proportion of each energy source used to produce electricity. The main energy sources are: nuclear, wind, solar, hydraulic, coal, gas, bioenergy and waste.

The Wind and solar energy sources are green, but they are intermittent and depend on the weather. The hydraulic energy source is also dependent on the weather, but to a lesser extent.

Hence, the weather directly impacts the CO2 emissions of the electry consumption.
Knowing the CO2 emission forecast can help plan the time of use of electric devices to reduce the carbon footprint.

## Description of the project

The project is divided into 2 parts:
1. Analysis of the historical data
2. Forecast of the electric mix

### 1. Analysis of the historical data
We gathered the data from the French electricity transmission system operator RTE (Réseau de Transport d'Electricité) and the French meteorological service Météo France.
The data start in 2022 and end in 2024.

We used the data to:
- train a model to predict the electric mix
- assess the performance of the model
- identify the main factors influencing the electric mix

### 2. Forecast of the electric mix
We will use the model trained in the first part to forecast the electric mix for the next few days.

The forecast is updated every day.

A website will be created to display the forecast.

## Installation

We use [hatch](https://hatch.pypa.io) to manage the project.

There is [a bug](https://github.com/ecmwf/eccodes-python/issues/88) in the current version of `eccodes`, failing the installation.
Installing with `conda` first solved the issue for me.

Run the following commands to check if `eccodes` is installed:
```bash
python -m eccodes selfcheck
```

### Interactive mode

You can use Hatch to activate the virtual environment and install the dependencies with:
```bash
hatch shell
```
This will open a shell with the virtual environment activated.
The dependencies listed in the `pyproject.toml` file will be installed automatically.

### Run the tests
You can run the tests with:
```bash
hatch test
```
This will run the tests in the virtual environment.

### Serve the Dashboard

You can serve the dashboard with:
```bash
hatch serve:prod
```
This will serve the dashboard on `http://localhost:8000`.

## The dashboard
The dashoard is developed with [Taipy](https://docs.taipy.io/en/latest/).
Lauchind the app will automaticaly
- Download the weather forecast
- Download the electricity mix history
- Display the forecast
Binary file removed data/arpege_data.npz
Binary file not shown.
Loading
Loading