" mix date_production name k_ac_mm_root_day \\\n",
"0 20230918-N01-XC2-D 2023-09-18 d 1.590000000000000000 \n",
"1 20230918-N03-XC1-S 2023-09-18 s 2.070000000000000000 \n",
"2 20230919-N03-XC1-D 2023-09-19 d 1.390000000000000000 \n",
"3 20230920-N03-XC2-D 2023-09-20 d 1.260000000000000000 \n",
"4 20230918-N04-XC1-S 2023-09-18 s 2.090000000000000000 \n",
"5 20230919-N06-XC1-S 2023-09-19 s 1.070000000000000000 \n",
"6 20230920-N06-XC2-D 2023-09-20 d 0.770000000000000000 \n",
"\n",
" test_procedure mean_depth_t0_mm \n",
"0 KB-TVFA 0.750000000000000000 \n",
"1 KB-TVFA 0.250000000000000000 \n",
"2 KB-TVFA 0.200000000000000000 \n",
"3 KB-TVFA 0.300000000000000000 \n",
"4 KB-TVFA 0.300000000000000000 \n",
"5 KB-TVFA 0E-18 \n",
"6 KB-TVFA 0E-18 "
],
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>mix</th>\n",
" <th>date_production</th>\n",
" <th>name</th>\n",
" <th>k_ac_mm_root_day</th>\n",
" <th>test_procedure</th>\n",
" <th>mean_depth_t0_mm</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>0</th>\n",
" <td>20230918-N01-XC2-D</td>\n",
" <td>2023-09-18</td>\n",
" <td>d</td>\n",
" <td>1.590000000000000000</td>\n",
" <td>KB-TVFA</td>\n",
" <td>0.750000000000000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>1</th>\n",
" <td>20230918-N03-XC1-S</td>\n",
" <td>2023-09-18</td>\n",
" <td>s</td>\n",
" <td>2.070000000000000000</td>\n",
" <td>KB-TVFA</td>\n",
" <td>0.250000000000000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>20230919-N03-XC1-D</td>\n",
" <td>2023-09-19</td>\n",
" <td>d</td>\n",
" <td>1.390000000000000000</td>\n",
" <td>KB-TVFA</td>\n",
" <td>0.200000000000000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>3</th>\n",
" <td>20230920-N03-XC2-D</td>\n",
" <td>2023-09-20</td>\n",
" <td>d</td>\n",
" <td>1.260000000000000000</td>\n",
" <td>KB-TVFA</td>\n",
" <td>0.300000000000000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>4</th>\n",
" <td>20230918-N04-XC1-S</td>\n",
" <td>2023-09-18</td>\n",
" <td>s</td>\n",
" <td>2.090000000000000000</td>\n",
" <td>KB-TVFA</td>\n",
" <td>0.300000000000000000</td>\n",
" </tr>\n",
" <tr>\n",
" <th>5</th>\n",
" <td>20230919-N06-XC1-S</td>\n",
" <td>2023-09-19</td>\n",
" <td>s</td>\n",
" <td>1.070000000000000000</td>\n",
" <td>KB-TVFA</td>\n",
" <td>0E-18</td>\n",
" </tr>\n",
" <tr>\n",
" <th>6</th>\n",
" <td>20230920-N06-XC2-D</td>\n",
" <td>2023-09-20</td>\n",
" <td>d</td>\n",
" <td>0.770000000000000000</td>\n",
" <td>KB-TVFA</td>\n",
" <td>0E-18</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"execution_count": 4
},
},
{
{
"metadata": {},
"metadata": {},
...
@@ -125,15 +330,33 @@
...
@@ -125,15 +330,33 @@
"id": "54b9b1f732219331"
"id": "54b9b1f732219331"
},
},
{
{
"metadata": {},
"metadata": {
"ExecuteTime": {
"end_time": "2024-12-14T07:22:46.566518Z",
"start_time": "2024-12-14T07:22:45.197517Z"
}
},
"cell_type": "code",
"cell_type": "code",
"source": [
"source": [
"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)\n",
"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\")\n",
"subset"
"subset"
],
],
"id": "f165e5e3861a0dda",
"id": "f165e5e3861a0dda",
"outputs": [],
"outputs": [
"execution_count": null
{
"ename": "ResponseCodeError",
"evalue": "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\"}]",
"Cell \u001B[0;32mIn[5], line 1\u001B[0m\n\u001B[0;32m----> 1\u001B[0m subset \u001B[38;5;241m=\u001B[39m \u001B[43mclient\u001B[49m\u001B[38;5;241;43m.\u001B[39;49m\u001B[43mcreate_subset\u001B[49m\u001B[43m(\u001B[49m\u001B[43mdatabase_id\u001B[49m\u001B[43m,\u001B[49m\u001B[43m \u001B[49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[38;5;124;43mSELECT 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\u001B[39;49m\u001B[38;5;124;43m\"\u001B[39;49m\u001B[43m)\u001B[49m\n\u001B[1;32m 2\u001B[0m subset\n",
"File \u001B[0;32m~/Projects/fda-services/.jupyter/venv/lib/python3.11/site-packages/dbrepo/RestClient.py:1590\u001B[0m, in \u001B[0;36mRestClient.create_subset\u001B[0;34m(self, database_id, query, page, size, timestamp)\u001B[0m\n\u001B[1;32m 1588\u001B[0m \u001B[38;5;28;01mif\u001B[39;00m response\u001B[38;5;241m.\u001B[39mstatus_code \u001B[38;5;241m==\u001B[39m \u001B[38;5;241m503\u001B[39m:\n\u001B[1;32m 1589\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m ServiceError(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mFailed to create subset: failed to establish connection with data database\u001B[39m\u001B[38;5;124m'\u001B[39m)\n\u001B[0;32m-> 1590\u001B[0m \u001B[38;5;28;01mraise\u001B[39;00m ResponseCodeError(\u001B[38;5;124mf\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124mFailed to create subset: response code: \u001B[39m\u001B[38;5;132;01m{\u001B[39;00mresponse\u001B[38;5;241m.\u001B[39mstatus_code\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m is not \u001B[39m\u001B[38;5;124m'\u001B[39m\n\u001B[1;32m 1591\u001B[0m \u001B[38;5;124mf\u001B[39m\u001B[38;5;124m'\u001B[39m\u001B[38;5;124m201 (CREATED): \u001B[39m\u001B[38;5;132;01m{\u001B[39;00mresponse\u001B[38;5;241m.\u001B[39mtext\u001B[38;5;132;01m}\u001B[39;00m\u001B[38;5;124m'\u001B[39m)\n",
"\u001B[0;31mResponseCodeError\u001B[0m: 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\"}]"
]
}
],
"execution_count": 5
}
}
],
],
"metadata": {
"metadata": {
...
...
%% 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.
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")
----> 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"}]