Skip to content

Commit 3e98681

Browse files
authored
Merge pull request #30 from cyiallou/feat/open-source-basic-notebooks
Open source basic Alert and Solar Notebooks
2 parents 79e5996 + b860aad commit 3e98681

19 files changed

+625
-0
lines changed

RELEASE_NOTES.md

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
## New Features
1212

1313
- Improved MIME type detection for email attachments, with a fallback for unknown file types.
14+
- Introduced a new alerts module for generating and formatting alert emails.
15+
- Added basic Alert and Solar Maintenance notebooks with instructions in English and German. These notebooks are aimed for running in a Deepnote project as they contain Deepnote related UI elements but they can also run in a common jupyter environment if the Deepnote UI elements are discarded.
1416

1517
## Bug Fixes
1618

examples/Alerts Notebook.ipynb

+1
Large diffs are not rendered by default.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
## **Anleitung: Deepnote Projekt erstellen und Notebook importieren**
2+
3+
---
4+
5+
### **1\. Einloggen in Deepnote**
6+
7+
Öffnen Sie [Deepnote](https://deepnote.com/) und loggen Sie sich mit Ihrem Account ein.
8+
9+
### **2\. Neues Projekt erstellen**
10+
11+
Wählen Sie oben in dem Seitenmenü den Workspace, in dem Sie das neue Projekt erstellen wollen.
12+
13+
Klicken sie dann bei dem Menüpunkt Projects auf das “+” und dann auf “New Project”
14+
15+
<img src="images/image1.png" width="25%">
16+
17+
Das erstellte Projekt öffnet sich automatisch:
18+
19+
<img src="images/image2.png" width="50%">
20+
21+
### **3\. Ändern der verwendeten Python Version**
22+
23+
Das Notebook benötigt Python 3.11. Da Deepnote standardmäßig neue Projekte mit Python 3.9 initialisiert, muss die Version geändert werden.
24+
25+
Dazu klicken sie unten links auf das Dropdown Feld in dem die Python Version angezeigt wird und wählen sie Python 3.11
26+
27+
<img src="images/image3.png" width="25%">
28+
<img src="images/image4.png" width="50%">
29+
30+
### **4\. Python Notebook hochladen**
31+
32+
Klicken Sie im Menü Links im Reiter **Files** auf das **\+**, wählen sie die Option **Upload .ipynb file**
33+
34+
<img src="images/image5.png" width="25%">
35+
36+
Laden Sie die zugeschickte Python Notebook Datei (.ipynb) hoch.
37+
38+
Das hochgeladene Notebook sollte nach einer Aktualisierung der Seite in Ihrem Browser im Seitenmenü unter Notebooks zu sehen sein (im Bild als „Solar Notebook“ angezeigt)..
39+
40+
Das ursprüngliche leere Notebook hier “Notebook 1” wird nicht mehr benötigt und kann gelöscht werden.
41+
42+
<img src="images/image6.png" width="25%">
43+
44+
### **5\. Requirements installieren**
45+
46+
Klicken Sie im Seitenmenü auf das hinzugefügte Notebook.
47+
48+
Damit Ihre Daten angezeigt werden können, müssen vor der Verwendung noch Pakete installiert werden.
49+
50+
Führen Sie dazu die erste Codezelle durch einen Klick auf das blaue Dreieck aus oder platzieren Sie Ihren Cursor innerhalb der Codezelle und verwenden Sie die Tastenkombination „STRG \+ Eingabe“. Sie können die Paketversion durch die gewünschte ersetzen.
51+
52+
**Es ist immer eine gute Idee, die neueste Version zu installieren, da diese neue Funktionen und/oder wichtige Fehlerbehebungen enthalten kann.**
53+
54+
Beispiel zur Installation von [`frequenz-lib-notebooks`](https://github.com/frequenz-floss/frequenz-lib-notebooks):
55+
56+
<img src="images/image7.png" width="70%">
57+
58+
Die Installation der benötigten Pakete kann einen Moment dauern. Danach sollte ein gelber Kasten unter dem Code zu sehen sein in dem steht:
59+
60+
“Delete this cell and move packages "frequenz-lib-notebooks"
61+
62+
Falls dies nicht der Fall ist, muss der Code Block durch erneutes Klicken auf das blaue Dreieck erneut ausgeführt werden.
63+
64+
Klicken sie auf den blauen Link move packages "frequenz-lib-notebooks" to “requirements.txt”
65+
66+
Die Requirements werden in dem Projekt jetzt automatisch für alle Notebooks erstellt, sodass sie beliebig viele Kopien des Notebooks erstellen können, ohne die Installation erneut durchführen zu müssen.
67+
68+
### **6\. Microgrids.toml-Datei hochladen**
69+
70+
Wenn Sie eine microgrids.toml-Datei oder eine andere Datei von uns erhalten haben, laden Sie diese bitte über Files \> Upload file in Ihr Projekt.
71+
72+
<img src="images/image8.png" width="35%">
73+
74+
### **7\. API Anmeldedaten hinterlegen**
75+
76+
Damit das Notebook Ihre Daten anzeigen kann, müssen Sie zunächst noch eine Integration Ihrer Kuiper API anlegen.
77+
78+
Klicken Sie dazu im Seitenmenü links im Reiter **Integrations** auf das **\+** und wählen Sie
79+
**Create a new integration.**
80+
81+
Wählen Sie die Option Environment variables in dem sich öffnenden Dropdown.
82+
83+
<img src="images/image9.png" width="25%">
84+
85+
Geben Sie der Integration einen Namen ihrer Wahl und fügen Sie die unten aufgelisteten Key Value Pairs hinzu.
86+
87+
**Key** **Value**
88+
89+
REPORTING\_SERVER\_URL grpc://reporting.api.frequenz.com:443
90+
91+
REPORTING\_API\_KEY Sie finden ihren API Key in Kuiper ([Anleitung](https://docs.google.com/document/u/0/d/1ePlCtr92pA1fRt2kt1PbyPs636ADk1r4PeuIOMBCM18/edit))
92+
93+
WEATHER\_SERVER\_URL grpc://fz-0003.frequenz.io:50052?ssl=false
94+
95+
Bestätigen Sie ihre Eingabe durch klicken auf **Create integration**
96+
97+
###
98+
99+
### **8\. App erstellen**
100+
101+
Wenn Sie aus dem Notebook eine App erstellen möchten, können Sie dies tun, indem Sie oben rechts auf die Schaltfläche **Create app** klicken:
102+
103+
<img src="images/image10.png" width="70%">
104+
105+
Wählen sie folgende Einstellungen (diese sollten bereits voreingestellt sein) und bestätigen Sie mit einem Klicken auf **Create app:**
106+
107+
<img src="images/image11.png" width="15%">
108+
109+
### **9\. Führen Sie das Notebook aus**
110+
111+
Befolgen Sie die im Notebook beschriebenen spezifischen Anweisungen.
112+
113+
## **Anleitung: Planen Sie die regelmäßige Ausführung eine Notebook**
114+
115+
---
116+
117+
1\. Klicken Sie auf das Kalendersymbol **Schedule notebook**, das sich oben im Notizbuch befindet, direkt neben der Schaltfläche **Run notebook**.
118+
119+
2\. Konfigurieren Sie die Häufigkeit, mit der das Notizbuch ausgeführt werden soll, und klicken Sie dann auf **Save schedule**.
120+
121+
3\. Darüber hinaus können Sie auch Benachrichtigungen für erfolgreiche und fehlgeschlagene Ausführungen konfigurieren, entweder per E-Mail oder in Slack.
122+
123+
<img src="images/image12.png" width="50%">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
## **Instructions: Create a Deepnote project and import a Notebook**
2+
3+
---
4+
5+
### **1\. Log in to Deepnote**
6+
7+
Open [Deepnote](https://deepnote.com/) and log in with your account.
8+
9+
### **2\. Create a new project**
10+
11+
Select the workspace in which you want to create the new project in the side menu at the top.
12+
13+
Then click on the “+” under the Projects menu item and then on “New Project”
14+
15+
<img src="images/image1.png" width="25%">
16+
17+
The newly created project opens automatically:
18+
19+
<img src="images/image2.png" width="50%">
20+
21+
### **3\. Changing the Python version**
22+
23+
The Notebook requires Python 3.11. Since Deepnote initializes new projects with Python 3.9 by default, the version must be changed.
24+
25+
To do this, click on the dropdown field at the bottom left where the Python version is displayed and select Python 3.11
26+
27+
<img src="images/image3.png" width="25%">
28+
<img src="images/image4.png" width="50%">
29+
30+
### **4\. Upload Python Notebook**
31+
32+
Click on the \+ in the Files tab on the left menu and select the **Upload .ipynb file option.** Then upload the Python notebook file (.ipynb).
33+
34+
<img src="images/image5.png" width="25%">
35+
36+
The uploaded notebook should be visible in the side menu under Notebooks after refreshing the page in your browser (shown as “Solar Notebook” in the image).
37+
38+
The original empty notebook here “Notebook 1” is no longer needed and can be deleted.
39+
40+
<img src="images/image6.png" width="25%">
41+
42+
### **5\. Install Requirements**
43+
44+
Click on the added Notebook in the side menu.
45+
46+
In order to display your data, packages must be installed before use.
47+
48+
To do this, run the first code cell by clicking on the blue triangle or place your cursor inside the code cell and use the keyboard shortcut "CTRL \+ Enter". You can replace the package version with the one you want.
49+
50+
**It is always a good idea to install the latest version as it may contain new features and/or important bug fixes.**
51+
52+
Example for installing [`frequenz-lib-notebooks`](https://github.com/frequenz-floss/frequenz-lib-notebooks):
53+
54+
<img src="images/image7.png" width="70%">
55+
56+
Installing the required packages may take a moment. After that, you should see a yellow box under the code that says:
57+
58+
“Delete this cell and move packages "frequenz-lib-notebooks"
59+
60+
If this is not the case, the code block must be executed again by clicking on the blue triangle again.
61+
62+
Click on the blue link move packages "frequenz-lib-notebooks" to “requirements.txt”
63+
64+
The requirements are now automatically created for all notebooks in the project, so you can create as many copies of the notebook as you want without having to perform the installation again.
65+
66+
### **6\. Upload other files**
67+
68+
If you have received a microgrids.toml file or any other file from us please upload them to your project via Files \> Upload file.
69+
70+
<img src="images/image8.png" width="35%">
71+
72+
### **7\. Enter API login data**
73+
74+
In order for the notebook to display your data, you must first create an integration of your Kuiper API.
75+
76+
To do this, click on the \+ in the **Integrations** tab on the left in the side menu and select **Create a new integration**.
77+
78+
Select the Environment variables option in the dropdown that opens.
79+
80+
<img src="images/image9.png" width="25%">
81+
82+
Give the integration a name of your choice and add the key value pairs listed below.
83+
84+
**Key** **Value**
85+
86+
REPORTING\_SERVER\_URL grpc://reporting.api.frequenz.com:443
87+
88+
REPORTING\_API\_KEY You can find your API key in Kuiper ([Anleitung](https://docs.google.com/document/u/0/d/1ePlCtr92pA1fRt2kt1PbyPs636ADk1r4PeuIOMBCM18/edit))
89+
90+
WEATHER\_SERVER\_URL grpc://fz-0003.frequenz.io:50052?ssl=false
91+
92+
Confirm your entry by clicking on **Create integration**.
93+
94+
###
95+
96+
### **8\. Create app**
97+
98+
If you want to create an app from the notebook then you can do so by clicking on the **Create app** button at the top right:
99+
100+
<img src="images/image10.png" width="70%">
101+
102+
Select the following settings (these should already be set) and confirm by clicking **Create app**:
103+
104+
<img src="images/image11.png" width="15%">
105+
106+
### **9\. Run the notebook**
107+
108+
Follow the specific instructions described in the notebook.
109+
110+
111+
## **Instructions: Schedule regular notebook execution**
112+
113+
---
114+
115+
1\. Click the **Schedule notebook** calendar icon located at the top of the notebook, right next to the **Run notebook** button.
116+
117+
2\. Configure the frequency at which you want the notebook to run, then click **Save schedule**.
118+
119+
3\. In addition, you can also configure notifications for successful and failed runs, either via email or in Slack.
120+
121+
<img src="images/image12.png" width="50%">

examples/Solar Maintenance.ipynb

+1
Large diffs are not rendered by default.

examples/images/image1.png

186 KB
Loading

examples/images/image10.png

16.1 KB
Loading

examples/images/image11.png

422 KB
Loading

examples/images/image12.png

139 KB
Loading

examples/images/image2.png

52.8 KB
Loading

examples/images/image3.png

103 KB
Loading

examples/images/image4.png

138 KB
Loading

examples/images/image5.png

143 KB
Loading

examples/images/image6.png

47.2 KB
Loading

examples/images/image7.png

13.4 KB
Loading

examples/images/image8.png

180 KB
Loading

examples/images/image9.png

170 KB
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
"""
2+
Alerts module for handling alert-related logic.
3+
4+
This includes email generation, processing, and formatting. This module
5+
provides utilities to generate alert summaries, format alert details, and
6+
create structured HTML emails.
7+
8+
Modules:
9+
- alert_email: Functions to generate alert-related emails.
10+
"""

0 commit comments

Comments
 (0)