Skip to content

Commit f5dc165

Browse files
committed
Remove old non-functional BrGI DB check logic. Leave function skeletons.
1 parent 2b71d64 commit f5dc165

File tree

1 file changed

+41
-99
lines changed

1 file changed

+41
-99
lines changed

src/bedrock_ge/gi/validate.py

Lines changed: 41 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -4,138 +4,80 @@
44
import pandas as pd
55

66
from bedrock_ge.gi.schemas import (
7-
InSituTestSchema,
8-
LocationSchema,
9-
ProjectSchema,
10-
SampleSchema,
7+
BedrockGIDatabase,
8+
BedrockGIGeospatialDatabase,
119
)
1210

1311

14-
# TODO: rename to check_brgi_geodb
15-
# TODO: make this check actually work...
16-
def check_brgi_database(brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]):
17-
"""Validates the structure and relationships of a 'Bedrock Ground Investigation' (BRGI) database (which is a dictionary of DataFrames).
12+
def check_brgi_geospatial_database(
13+
brgi_geodb: BedrockGIGeospatialDatabase,
14+
):
15+
"""Validates the structure and relationships of a 'Bedrock Ground Investigation' (BrGI) geospatial database.
1816
19-
This function checks that all tables in the BRGI database conform to their respective schemas
17+
This function checks that all tables in the BrGI geospatialdatabase conform to their respective schemas
2018
and that all foreign key relationships are properly maintained. It validates the following tables:
2119
- Project
2220
- Location
21+
- LonLatHeight
22+
- All In-Situ test tables
2323
- Sample
24-
- InSitu_TESTX
25-
- Lab_TESTY (not yet implemented)
24+
- All Lab test tables
2625
2726
Args:
28-
brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary
29-
containing the BRGI database tables, where keys are table names and
30-
values are the corresponding data tables (DataFrame or GeoDataFrame).
27+
brgi_geodb (BedrockGIGeospatialDatabase): Bedrock GI geospatial database object.
3128
3229
Returns:
3330
is_valid (bool): True if all tables are valid and relationships are properly maintained.
3431
3532
Example:
3633
```python
37-
brgi_db = {
38-
"Project": project_df,
39-
"Location": location_gdf,
40-
"Sample": sample_gdf,
41-
"InSitu_ISPT": in_situ_ispt_gdf,
42-
}
43-
check_brgi_database(brgi_db)
34+
brgi_geodb = BedrockGIGeospatialDatabase(
35+
Project=project_df,
36+
Location=location_geodf,
37+
LonLatHeight=lon_lat_height_geodf,
38+
InSituTests={"ISPT": ispt_geodf},
39+
Sample=sample_geodf,
40+
LabTests={"LLPL": llpl_df},
41+
)
42+
check_brgi_geospatial_database(brgi_db)
4443
```
4544
"""
46-
for table_name, table in brgi_db.items():
47-
if table_name == "Project":
48-
ProjectSchema.validate(table)
49-
print("'Project' table aligns with Bedrock's 'Project' table schema.")
50-
elif table_name == "Location":
51-
LocationSchema.validate(table)
52-
check_foreign_key("project_uid", brgi_db["Project"], table)
53-
print("'Location' table aligns with Bedrock's 'Location' table schema.")
54-
elif table_name == "Sample":
55-
SampleSchema.validate(table)
56-
check_foreign_key("project_uid", brgi_db["Project"], table)
57-
check_foreign_key("location_uid", brgi_db["Location"], table)
58-
print("'Sample' table aligns with Bedrock's 'Sample' table schema.")
59-
# ! JG is pretty sure that this doesn't work
60-
# ! The line below should be:
61-
# ! elif table_name.startswith("InSitu_"):
62-
elif table_name == "InSitu":
63-
InSituTestSchema.validate(table)
64-
check_foreign_key("project_uid", brgi_db["Project"], table)
65-
check_foreign_key("location_uid", brgi_db["Location"], table)
66-
print(
67-
f"'{table_name}' table aligns with Bedrock's table schema for In-Situ measurements."
68-
)
69-
elif table_name.startswith("Lab_"):
70-
print(
71-
"🚨 !NOT IMPLEMENTED! We haven't come across Lab data yet. !NOT IMPLEMENTED!"
72-
)
73-
45+
# TODO: implement this
7446
return True
7547

7648

77-
# TODO: rename to check_brgi_db
78-
def check_no_gis_brgi_database(
79-
brgi_db: Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]],
49+
def check_brgi_database(
50+
brgi_db: BedrockGIDatabase,
8051
):
81-
"""Validates the structure and relationships of a 'Bedrock Ground Investigation' (BGI) database without GIS geometry.
52+
"""Validates the structure and relationships of a 'Bedrock Ground Investigation' (BrGI) database.
8253
83-
This function performs the same validation as `check_brgi_database` but uses schemas
84-
that don't require GIS geometry. It validates the following tables:
85-
- Project (never has GIS geometry)
86-
- Location (without GIS geometry)
87-
- Sample (without GIS geometry)
88-
- InSitu_TESTX (without GIS geometry)
89-
- Lab_TESTY (not yet implemented)
54+
This function performs the same validation as `check_brgi_geospatial_database`, but uses schemas
55+
that don't require geospatial geometry. It validates the following tables:
56+
- Project (never has geospatial geometry)
57+
- Location (without geospatial geometry)
58+
- All In-Situ test tables (without geospatial geometry)
59+
- Sample (without geospatial geometry)
60+
- All Lab test tables (never has geospatial geometry)
9061
9162
Args:
92-
brgi_db (Dict[str, Union[pd.DataFrame, gpd.GeoDataFrame]]): A dictionary
93-
containing the Bedrock GI database tables, where keys are table names
94-
and values are the corresponding data tables (DataFrame or GeoDataFrame).
63+
brgi_db (BedrockGIDatabase): A Bedrock GI database object.
9564
9665
Returns:
9766
bool: True if all tables are valid and relationships are properly maintained.
9867
9968
Example:
10069
```python
101-
brgi_db = {
102-
"Project": projects_df,
103-
"Location": locations_df,
104-
"Sample": samples_df,
105-
"InSitu_measurements": insitu_df,
106-
}
107-
check_no_gis_brgi_database(brgi_db)
70+
brgi_db = BedrockGIDatabase(
71+
Project=project_df,
72+
Location=location_df,
73+
InSituTests={"ISPT": ispt_df},
74+
Sample=sample_df,
75+
LabTests={"LLPL": llpl_df},
76+
)
77+
check_brgi_database(brgi_db)
10878
```
10979
"""
110-
for table_name, table in brgi_db.items():
111-
if table_name == "Project":
112-
ProjectSchema.validate(table)
113-
print("'Project' table aligns with Bedrock's 'Project' table schema.")
114-
elif table_name == "Location":
115-
LocationSchema.validate(table)
116-
check_foreign_key("project_uid", brgi_db["Project"], table)
117-
print(
118-
"'Location' table aligns with Bedrock's 'Location' table schema without GIS geometry."
119-
)
120-
elif table_name == "Sample":
121-
SampleSchema.validate(table)
122-
check_foreign_key("project_uid", brgi_db["Project"], table)
123-
check_foreign_key("location_uid", brgi_db["Location"], table)
124-
print(
125-
"'Sample' table aligns with Bedrock's 'Sample' table schema without GIS geometry."
126-
)
127-
elif table_name.startswith("InSitu_"):
128-
InSituTestSchema.validate(table)
129-
check_foreign_key("project_uid", brgi_db["Project"], table)
130-
check_foreign_key("location_uid", brgi_db["Location"], table)
131-
print(
132-
f"'{table_name}' table aligns with Bedrock's '{table_name}' table schema without GIS geometry."
133-
)
134-
elif table_name.startswith("Lab_"):
135-
print(
136-
"🚨 !NOT IMPLEMENTED! We haven't come across Lab data yet. !NOT IMPLEMENTED!"
137-
)
138-
80+
# TODO: implement this
13981
return True
14082

14183

0 commit comments

Comments
 (0)