Skip to content
Snippets Groups Projects
Verified Commit db876eec authored by Martin Weise's avatar Martin Weise
Browse files

WIP

parent 92ea5cd9
Branches
Tags
No related merge requests found
...@@ -108,11 +108,11 @@ ...@@ -108,11 +108,11 @@
}, },
"aiosignal": { "aiosignal": {
"hashes": [ "hashes": [
"sha256:54cd96e15e1649b75d6c87526a6ff0b6c1b0dd3459f43d9ca11d48c339b68cfc", "sha256:45cde58e409a301715980c2b01d0c28bdde3770d8290b5eb2173759d9acb31a5",
"sha256:f8376fb07dd1e86a584e4fcdec80b36b7f81aac666ebc724e2c090300dd83b17" "sha256:a8c255c66fafb1e499c9351d0bf32ff2d8a0321595ebac3b93713656d2436f54"
], ],
"markers": "python_version >= '3.7'", "markers": "python_version >= '3.9'",
"version": "==1.3.1" "version": "==1.3.2"
}, },
"annotated-types": { "annotated-types": {
"hashes": [ "hashes": [
...@@ -423,19 +423,43 @@ ...@@ -423,19 +423,43 @@
}, },
"dbrepo": { "dbrepo": {
"hashes": [ "hashes": [
"sha256:49a18a9aea3cdcc32460a0c988a78ddf6ba7cd07ae1cbb995a3c30da4bb2b773", "sha256:19086c6f7aa3bc30de813c0622eac3a31ecc21c62ed7f2cd98406b2b308ec80f",
"sha256:6736240f42cd53bcda568186c25cf2fc75719f1f291fd8dd368ec16f22ba138a" "sha256:6d5ad9fa36de8ef7ff16a6a860bec0188dd78fc8fd9c55c84d9d1c68e6df486b"
], ],
"index": "pypi", "index": "pypi",
"version": "==1.5.2" "version": "==1.5.3"
}, },
"debugpy": { "debugpy": {
"hashes": [ "hashes": [
"sha256:97aa00af95983887806e06f37e144909d35215d66db74f8b0e9799b4eef40cfd", "sha256:0e22f846f4211383e6a416d04b4c13ed174d24cc5d43f5fd52e7821d0ebc8920",
"sha256:ee4ed903cbeb14ee1839549f953af519ffa512598ec987b2051f9c868e2249a8" "sha256:116bf8342062246ca749013df4f6ea106f23bc159305843491f64672a55af2e5",
"sha256:189058d03a40103a57144752652b3ab08ff02b7595d0ce1f651b9acc3a3a35a0",
"sha256:23dc34c5e03b0212fa3c49a874df2b8b1b8fda95160bd79c01eb3ab51ea8d851",
"sha256:28e45b3f827d3bf2592f3cf7ae63282e859f3259db44ed2b129093ca0ac7940b",
"sha256:2b26fefc4e31ff85593d68b9022e35e8925714a10ab4858fb1b577a8a48cb8cd",
"sha256:32db46ba45849daed7ccf3f2e26f7a386867b077f39b2a974bb5c4c2c3b0a280",
"sha256:40499a9979c55f72f4eb2fc38695419546b62594f8af194b879d2a18439c97a9",
"sha256:44b1b8e6253bceada11f714acf4309ffb98bfa9ac55e4fce14f9e5d4484287a1",
"sha256:52c3cf9ecda273a19cc092961ee34eb9ba8687d67ba34cc7b79a521c1c64c4c0",
"sha256:52d8a3166c9f2815bfae05f386114b0b2d274456980d41f320299a8d9a5615a7",
"sha256:61bc8b3b265e6949855300e84dc93d02d7a3a637f2aec6d382afd4ceb9120c9f",
"sha256:654130ca6ad5de73d978057eaf9e582244ff72d4574b3e106fb8d3d2a0d32458",
"sha256:6ad2688b69235c43b020e04fecccdf6a96c8943ca9c2fb340b8adc103c655e57",
"sha256:6c1f6a173d1140e557347419767d2b14ac1c9cd847e0b4c5444c7f3144697e4e",
"sha256:84e511a7545d11683d32cdb8f809ef63fc17ea2a00455cc62d0a4dbb4ed1c308",
"sha256:85de8474ad53ad546ff1c7c7c89230db215b9b8a02754d41cb5a76f70d0be296",
"sha256:8988f7163e4381b0da7696f37eec7aca19deb02e500245df68a7159739bbd0d3",
"sha256:8da1db4ca4f22583e834dcabdc7832e56fe16275253ee53ba66627b86e304da1",
"sha256:8ffc382e4afa4aee367bf413f55ed17bd91b191dcaf979890af239dda435f2a1",
"sha256:987bce16e86efa86f747d5151c54e91b3c1e36acc03ce1ddb50f9d09d16ded0e",
"sha256:ad7efe588c8f5cf940f40c3de0cd683cc5b76819446abaa50dc0829a30c094db",
"sha256:bb3b15e25891f38da3ca0740271e63ab9db61f41d4d8541745cfc1824252cb28",
"sha256:c928bbf47f65288574b78518449edaa46c82572d340e2750889bbf8cd92f3737",
"sha256:ce291a5aca4985d82875d6779f61375e959208cdf09fcec40001e65fb0a54768",
"sha256:d8768edcbeb34da9e11bcb8b5c2e0958d25218df7a6e56adf415ef262cd7b6d1"
], ],
"markers": "python_version >= '3.8'", "markers": "python_version >= '3.8'",
"version": "==1.8.10" "version": "==1.8.11"
}, },
"decorator": { "decorator": {
"hashes": [ "hashes": [
...@@ -1431,11 +1455,11 @@ ...@@ -1431,11 +1455,11 @@
}, },
"python-json-logger": { "python-json-logger": {
"hashes": [ "hashes": [
"sha256:23e7ec02d34237c5aa1e29a070193a4ea87583bb4e7f8fd06d3de8264c4b2e1c", "sha256:2c11056458d3f56614480b24e9cb28f7aba69cbfbebddbb77c92f0ec0d4947ab",
"sha256:f380b826a991ebbe3de4d897aeec42760035ac760345e57b812938dc8b35e2bd" "sha256:d73522ddcfc6d0461394120feaddea9025dc64bf804d96357dd42fa878cc5fe8"
], ],
"markers": "python_version >= '3.6'", "markers": "python_version >= '3.8'",
"version": "==2.0.7" "version": "==3.2.0"
}, },
"pytz": { "pytz": {
"hashes": [ "hashes": [
......
%% Cell type:markdown id:3ca0c15a13bd6882 tags: %% Cell type:markdown id:3ca0c15a13bd6882 tags:
# DBRepo Demo Notebook # DBRepo Demo Notebook
## Environment ## Environment
Set the REST API endpoint and your username + password in the `.env` file. This ensures it is not revealed in the code. Set the REST API endpoint and your username + password in the `.env` file. This ensures it is not revealed in the code.
%% Cell type:code id:4eb6c2470f464173 tags: %% Cell type:code id:4eb6c2470f464173 tags:
``` python ``` python
import dotenv import dotenv
from pandas.core.interchange.dataframe_protocol import DataFrame from pandas.core.interchange.dataframe_protocol import DataFrame
%load_ext dotenv %load_ext dotenv
%dotenv %dotenv
``` ```
%% Cell type:markdown id:2cbd7a83a800b879 tags: %% Cell type:markdown id:2cbd7a83a800b879 tags:
The code above loads the values from the `.env` file into this Jupyter Notebook. Alternatively you can set all parameters directly in the method: The code above loads the values from the `.env` file into this Jupyter Notebook. Alternatively you can set all parameters directly in the method:
```python ```python
client = RestClient(endpoint='https://test.dbrepo.tuwien.ac.at', username='foo', password='bar') client = RestClient(endpoint='https://test.dbrepo.tuwien.ac.at', username='foo', password='bar')
``` ```
## Global Variables & Imports ## Global Variables & Imports
Set the database id for convenience. Set the database id for convenience.
%% Cell type:code id:319e797ebb89b17b tags: %% Cell type:code id:319e797ebb89b17b tags:
``` python ``` python
from dbrepo.RestClient import RestClient from dbrepo.RestClient import RestClient
database_id = 37 database_id = 37
client = RestClient() client = RestClient()
``` ```
%% Cell type:markdown id:dc1ee2ab9378917 tags: %% Cell type:markdown id:dc1ee2ab9378917 tags:
## Tables ## Tables
Load data from any table, uncomment where needed. Load data from any table, uncomment where needed.
%% Cell type:code id:initial_id tags: %% Cell type:code id:initial_id tags:
``` python ``` python
# test_result_chloride_ageing = client.get_table_data(database_id, 615, df=True) # test_result_chloride_ageing = client.get_table_data(database_id, 615)
# test_result_chloride = client.get_table_data(database_id, 614, df=True) # test_result_chloride = client.get_table_data(database_id, 614)
# test_result_carb_nat = client.get_table_data(database_id, 613, df=True) # test_result_carb_nat = client.get_table_data(database_id, 613)
# test_result_carb_acc = client.get_table_data(database_id, 612, df=True) # test_result_carb_acc = client.get_table_data(database_id, 612)
# source_mat_analysis = client.get_table_data(database_id, 611, df=True) # source_mat_analysis = client.get_table_data(database_id, 611)
# source_mat = client.get_table_data(database_id, 610, df=True) # source_mat = client.get_table_data(database_id, 610)
# pruefstelle = client.get_table_data(database_id, 609, df=True) # pruefstelle = client.get_table_data(database_id, 609)
# mix_recipe = client.get_table_data(database_id, 607, df=True) # mix_recipe = client.get_table_data(database_id, 607)
# mix = client.get_table_data(database_id, 606, df=True) # mix = client.get_table_data(database_id, 606)
betonvariante = client.get_table_data(database_id, 604, df=True) betonvariante = client.get_table_data(database_id, 604)
betonvariante betonvariante
# optional: export table data as .csv # optional: export table data as .csv
# betonvariante.to_csv('betonvariante.csv') # betonvariante.to_csv('betonvariante.csv')
# optional: update table data from .csv # optional: update table data from .csv
# client.import_table_data(database_id, 604, 'my_data.csv') # client.import_table_data(database_id, 604, 'my_data.csv')
# optional: update table data from `pandas` DataFrame # optional: update table data from `pandas` DataFrame
# df = DataFrame() # df = DataFrame()
# client.import_table_data(database_id, 604, df) # client.import_table_data(database_id, 604, df)
``` ```
%% Output
id name
0 1 s
1 2 d
2 3 p
3 4 c
%% Cell type:markdown id:9098ea798a2ab598 tags: %% Cell type:markdown id:9098ea798a2ab598 tags:
## Views ## Views
Load data from any view, uncomment where needed. Load data from any view, uncomment where needed.
%% Cell type:code id:ddd433035e632df9 tags: %% Cell type:code id:ddd433035e632df9 tags:
``` python ``` python
beton_acc = client.get_view_data(database_id, 70, df=True) beton_acc = client.get_view_data(database_id, 70)
beton_acc beton_acc
# optional: export view data as .csv # optional: export view data as .csv
# beton_acc.to_csv('beton_acc.csv') # beton_acc.to_csv('beton_acc.csv')
``` ```
%% Output
mix date_production name k_ac_mm_root_day \
0 20230918-N01-XC2-D 2023-09-18 d 1.590000000000000000
1 20230918-N03-XC1-S 2023-09-18 s 2.070000000000000000
2 20230919-N03-XC1-D 2023-09-19 d 1.390000000000000000
3 20230920-N03-XC2-D 2023-09-20 d 1.260000000000000000
4 20230918-N04-XC1-S 2023-09-18 s 2.090000000000000000
5 20230919-N06-XC1-S 2023-09-19 s 1.070000000000000000
6 20230920-N06-XC2-D 2023-09-20 d 0.770000000000000000
test_procedure mean_depth_t0_mm
0 KB-TVFA 0.750000000000000000
1 KB-TVFA 0.250000000000000000
2 KB-TVFA 0.200000000000000000
3 KB-TVFA 0.300000000000000000
4 KB-TVFA 0.300000000000000000
5 KB-TVFA 0E-18
6 KB-TVFA 0E-18
%% Cell type:markdown id:54b9b1f732219331 tags: %% Cell type:markdown id:54b9b1f732219331 tags:
## Subsets ## Subsets
%% Cell type:code id:f165e5e3861a0dda tags: %% Cell type:code id:f165e5e3861a0dda tags:
``` python ``` python
subset = client.create_subset(database_id, "SELECT m.mix, date_production, b.name, ta.k_ac_mm_root_day, ta.test_procedure, ta.mean_depth_t0_mm FROM mix m JOIN betonvariante b ON b.id = m.betonvariante_id JOIN test_result_carb_acc ta ON m.id = ta.mix_id", df=True) subset = client.create_subset(database_id, "SELECT m.mix, date_production, b.name, ta.k_ac_mm_root_day, ta.test_procedure, ta.mean_depth_t0_mm FROM mix m JOIN betonvariante b ON b.id = m.betonvariante_id JOIN test_result_carb_acc ta ON m.id = ta.mix_id")
subset subset
``` ```
%% Output
---------------------------------------------------------------------------
ResponseCodeError Traceback (most recent call last)
Cell In[5], line 1
----> 1 subset = client.create_subset(database_id, "SELECT m.mix, date_production, b.name, ta.k_ac_mm_root_day, ta.test_procedure, ta.mean_depth_t0_mm FROM mix m JOIN betonvariante b ON b.id = m.betonvariante_id JOIN test_result_carb_acc ta ON m.id = ta.mix_id")
2 subset
File ~/Projects/fda-services/.jupyter/venv/lib/python3.11/site-packages/dbrepo/RestClient.py:1590, in RestClient.create_subset(self, database_id, query, page, size, timestamp)
1588 if response.status_code == 503:
1589 raise ServiceError(f'Failed to create subset: failed to establish connection with data database')
-> 1590 raise ResponseCodeError(f'Failed to create subset: response code: {response.status_code} is not '
1591 f'201 (CREATED): {response.text}')
ResponseCodeError: Failed to create subset: response code: 200 is not 201 (CREATED): [{"mix":"20230918-N01-XC2-D","date_production":"2023-09-18","name":"d","k_ac_mm_root_day":"1.590000000000000000","test_procedure":"KB-TVFA","mean_depth_t0_mm":"0.750000000000000000"},{"mix":"20230918-N03-XC1-S","date_production":"2023-09-18","name":"s","k_ac_mm_root_day":"2.070000000000000000","test_procedure":"KB-TVFA","mean_depth_t0_mm":"0.250000000000000000"},{"mix":"20230919-N03-XC1-D","date_production":"2023-09-19","name":"d","k_ac_mm_root_day":"1.390000000000000000","test_procedure":"KB-TVFA","mean_depth_t0_mm":"0.200000000000000000"},{"mix":"20230920-N03-XC2-D","date_production":"2023-09-20","name":"d","k_ac_mm_root_day":"1.260000000000000000","test_procedure":"KB-TVFA","mean_depth_t0_mm":"0.300000000000000000"},{"mix":"20230918-N04-XC1-S","date_production":"2023-09-18","name":"s","k_ac_mm_root_day":"2.090000000000000000","test_procedure":"KB-TVFA","mean_depth_t0_mm":"0.300000000000000000"},{"mix":"20230919-N06-XC1-S","date_production":"2023-09-19","name":"s","k_ac_mm_root_day":"1.070000000000000000","test_procedure":"KB-TVFA","mean_depth_t0_mm":"0E-18"},{"mix":"20230920-N06-XC2-D","date_production":"2023-09-20","name":"d","k_ac_mm_root_day":"0.770000000000000000","test_procedure":"KB-TVFA","mean_depth_t0_mm":"0E-18"}]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment