Skip to content

Commit 43d3688

Browse files
Update README.md
1 parent 4302f5b commit 43d3688

File tree

1 file changed

+72
-24
lines changed

1 file changed

+72
-24
lines changed

README.md

Lines changed: 72 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,86 @@
1-
# python-template
1+
# DevOps und Software Engineering Tutorial
22

3-
Precondition:
4-
Windows users can follow the official microsoft tutorial to install python, git and vscode here:
3+
Dieses Repository dient als Vorlage für Machine Learning Projekte. Es enthält Anleitungen zum Einrichten des Projekts, zum Trainieren und Vorhersagen mit einem Modell, zum Hochladen auf GitHub und zum Bereitstellen auf Heroku.
54

6-
- ​​https://docs.microsoft.com/en-us/windows/python/beginners
7-
- german: https://docs.microsoft.com/de-de/windows/python/beginners
5+
## Voraussetzungen:
6+
7+
Windows-Benutzer können dem offiziellen Microsoft-Tutorial folgen, um Python, Git und VSCode zu installieren:
8+
9+
* Englisch: https://docs.microsoft.com/en-us/windows/python/beginners
10+
* Deutsch: https://docs.microsoft.com/de-de/windows/python/beginners
811

912
## Visual Studio Code
1013

11-
This repository is optimized for [Visual Studio Code](https://code.visualstudio.com/) which is a great code editor for many languages like Python and Javascript. The [introduction videos](https://code.visualstudio.com/docs/getstarted/introvideos) explain how to work with VS Code. The [Python tutorial](https://code.visualstudio.com/docs/python/python-tutorial) provides an introduction about common topics like code editing, linting, debugging and testing in Python. There is also a section about [Python virtual environments](https://code.visualstudio.com/docs/python/environments) which you will need in development. There is also a [Data Science](https://code.visualstudio.com/docs/datascience/overview) section showing how to work with Jupyter Notebooks and common Machine Learning libraries.
14+
Dieses Repository ist für [Visual Studio Code](https://code.visualstudio.com/) optimiert. Das `.vscode`-Verzeichnis enthält Konfigurationen für nützliche Erweiterungen wie [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens0) und [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python).
15+
16+
## Entwicklungseinrichtung
17+
18+
1. **Repository erstellen**: Erstellen Sie ein GitHub-Repository. Verwenden Sie als Grundlage das folgende Template-Repository: https://github.com/fullstack-ml-academy/python-template.
19+
2. **Virtuelle Umgebung einrichten**: Öffnen Sie das integrierte Terminal und führen Sie das Setup-Skript für Ihr Betriebssystem aus. Dadurch wird eine virtuelle Python-Umgebung mit allen in `requirements.txt` angegebenen Paketen installiert.
20+
21+
* **Linux/Mac**:
22+
```bash
23+
./setup.sh
24+
source .venv/bin/activate
25+
```
26+
* **Windows**:
27+
```powershell
28+
.\setup.ps1
29+
.\.venv\Scripts\Activate.ps1
30+
```
31+
* **Fehlerbehebung**: Wenn Ihr System das Ausführen von Powershell-Skripten nicht zulässt, versuchen Sie, die Ausführungsrichtlinie festzulegen: `Set-ExecutionPolicy RemoteSigned`.
32+
33+
3. **Daten herunterladen**: Laden Sie die Trainingsdaten von https://gist.github.com/OFranke/9359880e40ba14afe795c1e1549839be herunter und legen Sie diese im Repository im Ordner `/data` ab.
34+
35+
## Modell trainieren und Vorhersagen treffen
1236

13-
The `.vscode` directory contains configurations for useful extensions like [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens0) and [Python](https://marketplace.visualstudio.com/items?itemName=ms-python.python). When opening the repository, VS Code will open a prompt to install the recommended extensions.
37+
1. **Modell trainieren**: Erstellen Sie ein Skript `train.py`. Trainieren Sie das Modell (z.B. Sklearn Decision Tree) und speichern Sie es mit der "pickle"-Bibliothek unter `/data/models`.
38+
2. **Modellvorhersage**: Erstellen Sie ein Skript `predict.py`. Lesen Sie das zuvor erstellte Modell wieder ein und generieren Sie eine Vorhersage, die im Terminal ausgegeben wird.
1439

15-
## Development Setup
40+
## Flask API erstellen
1641

17-
Open the [integrated terminal](https://code.visualstudio.com/docs/editor/integrated-terminal) and run the setup script for your OS (see below). This will install a [Python virtual environment](https://docs.python.org/3/library/venv.html) with all packages specified in `requirements.txt`.
42+
Erstellen Sie eine Flask-API, um das Modell über HTTP-Anfragen verfügbar zu machen.
1843

19-
### Linux and Mac Users
44+
1. **Abhängigkeiten installieren**: Installieren Sie `flask` und `flask-cors`.
45+
2. **API-Struktur**: Erstellen Sie eine `wsgi.py`-Datei und eine `src/api.py`-Datei.
46+
3. **Endpunkte implementieren**:
47+
* `GET /`: Gibt `{"hello": "world"}` als JSON zurück.
48+
* `GET /hello_world`: Gibt `<p>Hello, World!</p>` als HTML zurück.
49+
* `GET /training_data`: Gibt die Trainingsdaten als JSON zurück.
50+
* `GET /predict`: Nimmt die Parameter `zylinder`, `ps`, `gewicht`, `beschleunigung` und `baujahr` entgegen und gibt eine Vorhersage als JSON zurück (z.B. `{"result": 18.1}`).
2051

21-
1. run the setup script: `./setup.sh` or `sh setup.sh`
22-
2. activate the python environment: `source .venv/bin/activate`
23-
3. run example code: `python src/hello.py`
24-
4. install new dependency: `pip install sklearn`
25-
5. save current installed dependencies back to requirements.txt: `pip freeze > requirements.txt`
52+
## Auf GitHub hochladen
2653

27-
### Windows Users
54+
Verwenden Sie den JIRA + GitHub Workflow, um Ihre Änderungen zu verwalten.
2855

29-
1. run the setup script `.\setup.ps1`
30-
2. activate the python environment: `.\.venv\Scripts\Activate.ps1`
31-
3. run example code: `python src/hello.py`
32-
4. install new dependency: `pip install sklearn`
33-
5. save current installed dependencies back to requirements.txt: `pip freeze > requirements.txt`
56+
1. **Git-Repository initialisieren**:
57+
```bash
58+
git init
59+
```
60+
2. **Dateien hinzufügen und committen**:
61+
```bash
62+
git add .
63+
git commit -m "Erster Commit"
64+
```
65+
3. **Remote-Repository hinzufügen und pushen**:
66+
```bash
67+
git remote add origin <REMOTE_REPOSITORY_URL>
68+
git push -u origin master
69+
```
3470

35-
Troubleshooting:
71+
## Auf Heroku bereitstellen
3672

37-
- If your system does not allow to run powershell scripts, try to set the execution policy: `Set-ExecutionPolicy RemoteSigned`, see https://www.stanleyulili.com/powershell/solution-to-running-scripts-is-disabled-on-this-system-error-on-powershell/
38-
- If you still cannot run the setup.ps1 script, open it and copy all the commands step by step in your terminal and execute each step
73+
1. **Heroku-Konto erstellen**: Legen Sie einen neuen Heroku-Account an.
74+
2. **Heroku-App erstellen**: Erstellen Sie eine neue Heroku-App.
75+
3. **GitHub Action für automatisches Deployment einrichten**:
76+
* Erstellen Sie eine neue GitHub Action, die bei Änderungen im `main`-Branch automatisch auf Heroku deployed wird.
77+
* Setzen Sie die folgenden Environment Variables in Ihrem GitHub Repository unter `Settings > Secrets`: `HEROKU_API_KEY`, `HEROKU_APP_NAME`, `HEROKU_EMAIL`.
78+
* Verwenden Sie den Code für die Action von: https://gist.github.com/OFranke/e39c7629bfaa4538fbc616ba60be2d57.
79+
4. **Procfile erstellen**: Erstellen Sie eine `Procfile`-Datei im Stammverzeichnis Ihres Projekts mit dem folgenden Inhalt, um den API-Server mit `gunicorn` zu starten:
80+
```
81+
web: gunicorn wsgi:app
82+
```
83+
5. **Runtime definieren**: Erstellen Sie eine `runtime.txt`-Datei im Stammverzeichnis, um die Python-Version für Heroku festzulegen:
84+
```
85+
python-3.9.0
86+
```

0 commit comments

Comments
 (0)