Skip to content

Commit 85605d9

Browse files
authored
Merge pull request #269 from 3DBAG/fix/235--update-test-data
Fix/235 update test data
2 parents bf3e85e + 86dce57 commit 85605d9

File tree

17 files changed

+268
-242
lines changed

17 files changed

+268
-242
lines changed

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ include .env
113113
download:
114114
rm -rf $(BAG3D_TEST_DATA)
115115
mkdir -p $(BAG3D_TEST_DATA)
116-
cd $(BAG3D_TEST_DATA) ; curl -O https://data.3dbag.nl/testdata/pipeline/test_data_v13.zip ; unzip -q test_data_v13.zip ; rm test_data_v13.zip
116+
cd $(BAG3D_TEST_DATA) ; curl -O https://data.3dbag.nl/testdata/pipeline/test_data_v14.zip ; unzip -q test_data_v14.zip ; rm test_data_v14.zip
117117

118118

119119
install_uv:

packages/common/src/bag3d/common/resources/__init__.py

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import os
2-
from pathlib import Path
32

43
from bag3d.common.resources.executables import (
54
GDALResource,
@@ -60,17 +59,6 @@
6059
file_store = FileStoreResource(data_dir=os.getenv("BAG3D_FILESTORE"))
6160
file_store_fastssd = FileStoreResource(data_dir=os.getenv("BAG3D_FILESTORE_FASTSSD"))
6261

63-
file_store_test = FileStoreResource(
64-
data_dir=str(Path(os.getenv("BAG3D_FILESTORE")) / "reconstruction_input")
65-
)
66-
file_store_fastssd_test = FileStoreResource(
67-
data_dir=str(Path(os.getenv("BAG3D_FILESTORE")) / "integration_core")
68-
)
69-
70-
# Configure for gilfoyle
71-
file_store_gilfoyle = FileStoreResource(data_dir="/data")
72-
file_store_gilfoyle_fastssd = FileStoreResource(data_dir="/fastssd/data")
73-
7462

7563
lastools = LASToolsResource(
7664
exe_lasindex=os.getenv("EXE_PATH_LASINDEX"),
@@ -118,23 +106,6 @@
118106
}
119107

120108

121-
# RESOURCES_TEST = {
122-
# "gdal": gdal,
123-
# "file_store": file_store_test,
124-
# "file_store_fastssd": file_store_fastssd_test,
125-
# "db_connection": db_connection,
126-
# "pdal": pdal,
127-
# "lastools": lastools,
128-
# "tyler": tyler,
129-
# "geoflow": geoflow,
130-
# "validation": validation,
131-
# "roofer": roofer,
132-
# "version": version,
133-
# "specs": specs,
134-
# "godzilla_server": godzilla_server,
135-
# "podzilla_server": podzilla_server,
136-
# }
137-
#
138109
# RESOURCES_PROD = {
139110
# "gdal": gdal,
140111
# "file_store": file_store_gilfoyle,

packages/common/src/bag3d/common/utils/files.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,9 @@ def get_export_tile_ids() -> Sequence[str]:
101101

102102
env = os.getenv("DAGSTER_ENVIRONMENT", "test")
103103
if env == "test":
104-
root_dir = Path(os.getenv("BAG3D_FILESTORE")) / "reconstruction_input"
104+
root_dir = (
105+
Path(os.getenv("BAG3D_FILESTORE")) / "integration_party_walls/file_store"
106+
)
105107
version = "test_version"
106108
else:
107109
root_dir = Path(os.getenv("BAG3D_FILESTORE", "/data"))

packages/common/tests/conftest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,5 +109,8 @@ def test_data_dir():
109109

110110

111111
@pytest.fixture(scope="session")
112-
def laz_files_ahn3_dir(test_data_dir):
113-
yield test_data_dir / "reconstruction_input/pointcloud/AHN3/as_downloaded/LAZ"
112+
def sample_laz_file(test_data_dir):
113+
yield (
114+
test_data_dir
115+
/ "integration_core/file_store/pointcloud/AHN3/as_downloaded/LAZ/C_32BZ2.LAZ"
116+
)

packages/common/tests/test_resources.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,15 @@ def test_gdal_local(test_data_dir):
3737
assert return_code == 0
3838

3939

40-
def test_pdal_local(laz_files_ahn3_dir):
40+
def test_pdal_local(sample_laz_file):
4141
"""Use local PDAL installation"""
4242
pdal = PDALResource(exe_pdal=EnvVar("EXE_PATH_PDAL").get_value())
4343
assert not pdal.with_docker
44-
filepath = laz_files_ahn3_dir / "C_32BZ2.LAZ"
45-
return_code, output = pdal_info(pdal.app, filepath, with_all=True)
44+
return_code, output = pdal_info(pdal.app, sample_laz_file, with_all=True)
4645
assert return_code == 0
4746

4847

49-
def test_lastools(laz_files_ahn3_dir):
48+
def test_lastools(sample_laz_file):
5049
lastools_resource = LASToolsResource(
5150
exe_lasindex=EnvVar("EXE_PATH_LASINDEX").get_value(),
5251
exe_las2las=EnvVar("EXE_PATH_LAS2LAS").get_value(),
@@ -55,8 +54,6 @@ def test_lastools(laz_files_ahn3_dir):
5554

5655
lastools = lastools_resource.app
5756

58-
filepath = laz_files_ahn3_dir / "C_32BZ2.LAZ"
59-
6057
cmd_list = [
6158
"{exe}",
6259
"-i {local_path}",
@@ -66,7 +63,7 @@ def test_lastools(laz_files_ahn3_dir):
6663
"-dont_reindex",
6764
]
6865
return_code, output = lastools.execute(
69-
"lasindex", " ".join(cmd_list), local_path=filepath
66+
"lasindex", " ".join(cmd_list), local_path=sample_laz_file
7067
)
7168

7269
assert return_code == 0

packages/core/src/bag3d/core/assets/ahn/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ def compute_load_metadata(
241241
ST_SetSRID(ST_GeomFromGeoJSON({boundary}), 28992)
242242
);
243243
""").format(**query_params)
244-
context.log.info(conn.print_query(query))
244+
context.log.debug(conn.print_query(query))
245245
conn.send_query(query)
246246
# Cannot index the table here, because this is a partitioned assed. This means that
247247
# this function is called for each partition, which would index the table after

packages/core/tests/conftest.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,30 @@ def context(
168168
)
169169

170170

171+
@pytest.fixture
172+
def context_ahn(
173+
database,
174+
file_store,
175+
gdal,
176+
validation,
177+
godzilla_server,
178+
podzilla_server,
179+
):
180+
yield build_op_context(
181+
partition_key="01cz1",
182+
resources={
183+
"gdal": gdal,
184+
"validation": validation,
185+
"db_connection": database,
186+
"file_store": file_store,
187+
"version": VersionResource("test_version"),
188+
"godzilla_server": godzilla_server,
189+
"podzilla_server": podzilla_server,
190+
"specs": Specs3DBAGResource(),
191+
},
192+
)
193+
194+
171195
@pytest.fixture
172196
def context_missing(
173197
database, wkt_testarea, file_store, gdal_missing, validation_missing
@@ -265,6 +289,23 @@ def test_data_dir():
265289
yield Path(LOCAL_DIR)
266290

267291

292+
@pytest.fixture(scope="session")
293+
def core_integration_test_dir(test_data_dir):
294+
yield test_data_dir / "integration_core"
295+
296+
297+
@pytest.fixture(scope="session")
298+
def core_file_store_fastssd(core_integration_test_dir) -> Path:
299+
"""Root directory path for test data"""
300+
return core_integration_test_dir / "file_store_fastssd"
301+
302+
303+
@pytest.fixture(scope="session")
304+
def core_file_store(core_integration_test_dir) -> Path:
305+
"""Root directory path for test data"""
306+
return core_integration_test_dir / "file_store"
307+
308+
268309
@pytest.fixture(scope="session")
269310
def md5_ahn3_fix():
270311
yield {"C_01CZ1.LAZ": "063b23d038f97576d279fb7d8a1481ad"}

packages/core/tests/test_assets_ahn.py

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -51,77 +51,77 @@ def test_get_checksums(ahn_version):
5151
assert sha is not None
5252

5353

54-
def test_checksums_for_ahn(context):
55-
res = md5_ahn3(context)
54+
def test_checksums_for_ahn(context_ahn):
55+
res = md5_ahn3(context_ahn)
5656
assert len(res) > 0
5757
for k, sha in list(res.items())[:5]:
5858
assert sha is not None
59-
res = md5_ahn4(context)
59+
res = md5_ahn4(context_ahn)
6060
assert len(res) > 0
6161
for k, sha in list(res.items())[:5]:
6262
assert sha is not None
63-
res = sha256_ahn5(context)
63+
res = sha256_ahn5(context_ahn)
6464
assert len(res) > 0
6565
for k, sha in list(res.items())[:5]:
6666
assert sha is not None
6767

6868

69-
def test_tile_index_ahn(context):
70-
res = tile_index_ahn(context)
69+
def test_tile_index_ahn(context_ahn):
70+
res = tile_index_ahn(context_ahn)
7171
assert len(res) == 1407
7272
assert res[list(res.keys())[0]] is not None
7373

7474

7575
@pytest.mark.slow
76-
def test_laz_files_ahn3(context, md5_ahn3_fix, tile_index_ahn_fix):
77-
laz_dir = ahn_laz_dir(context.resources.file_store.file_store.data_dir, 3)
76+
def test_laz_files_ahn3(context_ahn, md5_ahn3_fix, tile_index_ahn_fix):
77+
laz_dir = ahn_laz_dir(context_ahn.resources.file_store.file_store.data_dir, 3)
7878
laz_dir.mkdir(exist_ok=True, parents=True)
7979
config = LazFilesConfig(force_download=False, check_hash=False)
80-
res = laz_files_ahn3(context, config, md5_ahn3_fix, tile_index_ahn_fix)
80+
res = laz_files_ahn3(context_ahn, config, md5_ahn3_fix, tile_index_ahn_fix)
8181
assert res.value.url is not None
8282
assert res is not None
8383
print(res.value)
8484

8585

8686
@pytest.mark.slow
87-
def test_laz_files_ahn4(context, md5_ahn4_fix, tile_index_ahn_fix):
88-
laz_dir = ahn_laz_dir(context.resources.file_store.file_store.data_dir, 4)
87+
def test_laz_files_ahn4(context_ahn, md5_ahn4_fix, tile_index_ahn_fix):
88+
laz_dir = ahn_laz_dir(context_ahn.resources.file_store.file_store.data_dir, 4)
8989
laz_dir.mkdir(exist_ok=True, parents=True)
9090
config = LazFilesConfig(force_download=False, check_hash=False)
91-
res = laz_files_ahn4(context, config, md5_ahn4_fix, tile_index_ahn_fix)
91+
res = laz_files_ahn4(context_ahn, config, md5_ahn4_fix, tile_index_ahn_fix)
9292
assert res.value.url is not None
9393
assert res is not None
9494

9595

9696
@pytest.mark.slow
97-
def test_laz_files_ahn5(context, sha256_ahn5_fix, tile_index_ahn_fix):
98-
laz_dir = ahn_laz_dir(context.resources.file_store.file_store.data_dir, 5)
97+
def test_laz_files_ahn5(context_ahn, sha256_ahn5_fix, tile_index_ahn_fix):
98+
laz_dir = ahn_laz_dir(context_ahn.resources.file_store.file_store.data_dir, 5)
9999
laz_dir.mkdir(exist_ok=True, parents=True)
100100
config = LazFilesConfig(force_download=False, check_hash=False)
101-
res = laz_files_ahn5(context, config, sha256_ahn5_fix, tile_index_ahn_fix)
101+
res = laz_files_ahn5(context_ahn, config, sha256_ahn5_fix, tile_index_ahn_fix)
102102
assert res.value.url is not None
103103
assert res is not None
104104

105105

106-
def test_metadata_table_ahn3(context):
107-
metadata = metadata_table_ahn3(context)
106+
def test_metadata_table_ahn3(context_ahn):
107+
metadata = metadata_table_ahn3(context_ahn)
108108
tbl = PostgresTableIdentifier("ahn", "metadata_ahn3")
109-
assert table_exists(context, tbl)
109+
assert table_exists(context_ahn, tbl)
110110
assert isinstance(metadata, PostgresTableIdentifier)
111111
assert str(metadata) == f"{tbl.schema}.{tbl.table}"
112112

113113

114-
def test_metadata_table_ahn4(context):
115-
metadata = metadata_table_ahn4(context)
114+
def test_metadata_table_ahn4(context_ahn):
115+
metadata = metadata_table_ahn4(context_ahn)
116116
tbl = PostgresTableIdentifier("ahn", "metadata_ahn4")
117-
assert table_exists(context, tbl)
117+
assert table_exists(context_ahn, tbl)
118118
assert isinstance(metadata, PostgresTableIdentifier)
119119
assert str(metadata) == f"{tbl.schema}.{tbl.table}"
120120

121121

122-
def test_metadata_table_ahn5(context):
123-
metadata = metadata_table_ahn5(context)
122+
def test_metadata_table_ahn5(context_ahn):
123+
metadata = metadata_table_ahn5(context_ahn)
124124
tbl = PostgresTableIdentifier("ahn", "metadata_ahn5")
125-
assert table_exists(context, tbl)
125+
assert table_exists(context_ahn, tbl)
126126
assert isinstance(metadata, PostgresTableIdentifier)
127127
assert str(metadata) == f"{tbl.schema}.{tbl.table}"

packages/core/tests/test_assets_top10nl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ def test_extract_top10nl(context_top10nl):
77
"""Does the complete asset work?"""
88
res = download.extract_top10nl(context_top10nl)
99
assert res.value.exists()
10-
context_top10nl.resources.file_store.file_store.rm(force=True)

packages/core/tests/test_integration.py

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737

3838
@pytest.mark.needs_tools
39-
def test_integration_ahn(database, test_data_dir):
39+
def test_integration_ahn(database, core_file_store):
4040
"""Test the ahn jobs."""
4141
resources = {
4242
"lastools": LASToolsResource(
@@ -47,9 +47,7 @@ def test_integration_ahn(database, test_data_dir):
4747
exe_pdal=os.getenv("EXE_PATH_PDAL"),
4848
),
4949
"db_connection": database,
50-
"file_store": FileStoreResource(
51-
data_dir=str(test_data_dir / "reconstruction_input")
52-
),
50+
"file_store": FileStoreResource(data_dir=str(core_file_store)),
5351
}
5452

5553
all_ahn_assets = load_assets_from_package_module(
@@ -108,6 +106,8 @@ def test_integration_ahn(database, test_data_dir):
108106
def test_integration_reconstruction_and_export(
109107
database,
110108
test_data_dir,
109+
core_file_store,
110+
core_file_store_fastssd,
111111
mock_asset_reconstruction_input,
112112
mock_asset_tiles,
113113
mock_asset_index,
@@ -117,9 +117,7 @@ def test_integration_reconstruction_and_export(
117117
):
118118
# update quadtree
119119
og_quadtree = test_data_dir / "quadtree.tsv"
120-
export_dir = (
121-
test_data_dir / "reconstruction_input" / "3DBAG" / "export_test_version"
122-
)
120+
export_dir = core_file_store / "3DBAG" / "export_test_version"
123121
export_dir.mkdir(exist_ok=True)
124122
os.system(f"cp {og_quadtree} {export_dir}")
125123

@@ -143,12 +141,8 @@ def test_integration_reconstruction_and_export(
143141
exe_sozip=os.getenv("EXE_PATH_SOZIP"),
144142
),
145143
"db_connection": database,
146-
"file_store": FileStoreResource(
147-
data_dir=str(test_data_dir / "reconstruction_input")
148-
),
149-
"file_store_fastssd": FileStoreResource(
150-
data_dir=str(test_data_dir / "integration_core")
151-
),
144+
"file_store": FileStoreResource(data_dir=str(core_file_store)),
145+
"file_store_fastssd": FileStoreResource(data_dir=str(core_file_store_fastssd)),
152146
"version": VersionResource("test_version"),
153147
"validation": ValidationResource(
154148
exe_val3dity=os.getenv("EXE_PATH_VAL3DITY"),
@@ -203,7 +197,6 @@ def test_integration_reconstruction_and_export(
203197
}
204198
},
205199
)
206-
207200
assert isinstance(result, ExecuteInProcessResult)
208201
assert result.success
209202

@@ -219,13 +212,11 @@ def test_integration_reconstruction_and_export(
219212
}
220213
},
221214
)
222-
223215
assert isinstance(result, ExecuteInProcessResult)
224216
assert result.success
225217

226218
resolved_job = defs.get_job_def("nl_export_after_floors")
227219
result = resolved_job.execute_in_process(instance=instance, resources=resources)
228-
229220
assert isinstance(result, ExecuteInProcessResult)
230221
assert result.success
231222

0 commit comments

Comments
 (0)