Skip to content
Snippets Groups Projects
Commit 805c9d0e authored by Sabine Schröder's avatar Sabine Schröder
Browse files

Update README.md -- now in English

parent 9ea1f083
No related branches found
No related tags found
No related merge requests found
Pipeline #38088 passed
# Migration of TOAR database from Django to FastAPI
Gedanken zum Projekt, beziehungsweise, welche Tests gemacht wurden (und welche Tests noch ausstehen):
Thoughts around this project, especially which tests were taken (and which tests have still to be done):
https://gitlab.version.fz-juelich.de/toar/toar-db/-/issues/33
(oder aber auch: https://gitlab.version.fz-juelich.de/toar/toar-db/-/tree/sabine_%2333_testfastAPI/fastAPIproject)
Besonders in dem Issue habe ich mich bemüht, alles ein bisschen klarer aufzuschreiben.
(or see code development at: https://gitlab.version.fz-juelich.de/toar/toar-db/-/tree/sabine_%2333_testfastAPI/fastAPIproject)
This issue is structured with a table of contents and aims to clarify issues that were coming up.
## installation guide (soon available in English)
Ich habe eine Test-Datenbank angelegt (noch nicht komplett belegt) und als toardb_dump.sql im Gitlab abgelegt – hier kommt gleich die Anleitung, wie man sie installiert.
## installation guide
Nach dem Download **und der Installation (siehe unten)** von toardb_fastapi kann man mittels
```
pytest
```
sehen, ob alles funktioniert
(aus einem unerklärlichen Grund kann die Datenbank beim letzten Test nicht richtig aufgeräumt werden -- Fehler wird noch behoben).
This repository holds a simple test database *toardb_dump.sql* (not yet fully filled with example data).
Also some testing examples for the running application are provided within file *production_tests.sh*, as well as corresponding pytests.
Running the tests and pytest are described after the installation guide (you need to do this first).
Wenn man eine App gestartet hat, kann man auch mittels curl die „produktive“ Schnittstelle testen.
Hierzu findet man Testbeispiele in „production_tests.sh“.
Es fehlt noch das Definieren einer übergeordneten App, so dass man alle Module gleichzeitig abfragen kann (und nicht jeweils mittels uvicorn neu starten muss).
**Nun zur Installation und Einrichtung der Datenbank:**
Bitte genau nach der Anleitung
**installation and setup of database:**
Please follow exactly the instructions on page
https://gitlab.version.fz-juelich.de/toar/toar-db/-/blob/master/INSTALL_POSTGIS.md
vorgehen (ich hatte es erfolglos anders versucht).
Im Anschluss von der Shell:
(I unsuccessfully tried some shortcuts that did not work -- the above instructions do work!).
After the above instructions execute the following command from shell:
```
psql -U toaradmin -d toardb -h localhost -f toardb_dump.sql
```
ausführen.
**Die Installation von toardb_fastapi geht folgendermaßen:**
Nach dem Clonen (`git clone https://gitlab.version.fz-juelich.de/schroeder5/toardb_fastapi.git`)
richtet man sich am besten eine virtuelle Umgebung ein und installiert hier die Requirements, also:
**installation of toardb_fastapi:**
After cloning the repository (`git clone https://gitlab.version.fz-juelich.de/toar/toardb_fastapi.git`)
it is recommended to create a virtual environment and install the requirements therein:
```
python3 –m venv venv
source venv/bin/activate
pip install –r requirements.txt
```
## Simple database interface: TOAR table data
## Running pytest
After download **and installation (see above)** of toardb_fastapi you can check, if everything is working via
```
pytest
```
(due to an unknown error the database cannot be teared down correctly -- still under investigation (very last test will throw an error for teardown of database if run as ensemble, if every module is pytested stand-alone this error will not show up)).
## Running live tests
After download **and installation (see above)** of toardb_fastapi you can check, if everything is working in the live system via the following:
From the top directory of the project (*toardb_fastapi*) open two terminals.
In the first terminal start the application via:
```
source venv/bin/activate
uvicorn toardb.toardb:app --reload
```
In the second terminal start the live tests via:
```
./production_tests.sh
```
## database interface (REST API)
(more examples can be found in file *production_tests.sh*)
run as:
```
uvicorn data.data:app --reload
uvicorn toardb.toardb:app --reload
```
after having followed the installation instructions of the TOAR database in the toar-db project.
after having followed the above installation instructions.
For example try:
get all data of table data (you should **NOT** do this!):
```
http://127.0.0.1:8000/data/
```
get 4 arbitrary rows of table data:
```
http://127.0.0.1:8000/data/?limit=4
```
get all data of timeseries with id=2:
```
http://127.0.0.1:8000/data/2
```
upload a file to the table data of the TOAR database:
(at the moment every data will be uploaded to timeseries with timeseries_id=2 -- hardwired)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment