Skip to content

Commit 4c53a09

Browse files
authored
Merge pull request #189 from 3DBAG/validation-error-handling
A lot of small pieces of work
2 parents cfd9e06 + 025083a commit 4c53a09

File tree

18 files changed

+298
-51
lines changed

18 files changed

+298
-51
lines changed

.github/workflows/test.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ jobs:
2929
run: |
3030
make download
3131
make docker_volume_create
32-
make docker_up
32+
- name: Start containers
33+
run: make docker_up
34+
3335
- name: Run unit tests
3436
run: make test
3537
- name: Recreate volumes

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ For the changes in the 3DBAG data set, see the [3DBAG release notes](https://doc
44

55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

7+
## [2025.07.03]
8+
9+
Validation error handling
10+
removed rf_force_lod11
11+
712
## [2025.03.14]
813

914
Install cjval, val3dity (2.4.0) & cjio in tools image.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Additionally, this organization makes it easier to install and test the workflow
3939
## Deployment
4040

4141
Deploying the 3dbag-pipeline is complex, because of its many components and dependencies.
42-
You can read about the details on how can you deploy it in the [deployment section](deployment/index.md).
42+
You can read about the details on how can you deploy it in the [deployment section](docs/deployment/index.md).
4343

4444
## Production
4545

docker/compose.yaml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ services:
2020

2121
# This service stores the asset data that is generated by the pipeline
2222
data-postgresql:
23+
platform: linux/amd64
2324
build:
2425
context: ./postgres
2526
args:
@@ -31,9 +32,11 @@ services:
3132
environment:
3233
PGDATA: /var/lib/postgresql/data/pgdata
3334
healthcheck:
34-
test: ["CMD-SHELL", "pg_isready -d ${BAG3D_PG_DATABASE} -U {BAG3D_PG_USER}"]
35-
interval: 3s
35+
test: ["CMD-SHELL", "pg_isready -d ${BAG3D_PG_DATABASE}"]
36+
interval: 4s
3637
retries: 20
38+
timeout: 5s
39+
start_period: 20s
3740
shm_size: '1gb'
3841
ports:
3942
- "${BAG3D_PG_PORT_ON_HOST}:5432"
@@ -60,11 +63,12 @@ services:
6063
# its own port, and have its own entry in the workspace.yaml file that's loaded by the
6164
# webserver.
6265
bag3d-core:
66+
platform: linux/amd64
6367
build:
6468
context: ../
6569
dockerfile: docker/pipeline/bag3d-core.dockerfile
6670
args:
67-
- VERSION=${BAG3D_DOCKER_IMAGE_TAG}
71+
VERSION: ${BAG3D_DOCKER_IMAGE_TAG}
6872
image: 3dbag-pipeline-core:${BAG3D_DOCKER_IMAGE_TAG}
6973
pull_policy: build
7074
container_name: 3dbag-pipeline-core-${BAG3D_DOCKER_IMAGE_TAG}
@@ -81,6 +85,7 @@ services:
8185
volumes:
8286
- bag3d-data-pipeline:/data/volume
8387
- bag3d-dagster-home:/opt/dagster/dagster_home
88+
- ~/.ssh:/root/.ssh:ro
8489
networks:
8590
- bag3d-network
8691
depends_on:
@@ -109,6 +114,7 @@ services:
109114
target: /opt/3dbag-pipeline/packages/core/pyproject.toml
110115

111116
bag3d-floors-estimation:
117+
platform: linux/amd64
112118
build:
113119
context: ../
114120
dockerfile: docker/pipeline/bag3d-floors-estimation.dockerfile
@@ -152,6 +158,7 @@ services:
152158
target: /opt/3dbag-pipeline/packages/floors_estimation/pyproject.toml
153159

154160
bag3d-party-walls:
161+
platform: linux/amd64
155162
build:
156163
context: ../
157164
dockerfile: docker/pipeline/bag3d-party-walls.dockerfile

docker/dagster/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dagster libraries to run both dagster-webserver and the dagster-daemon. Does not
22
# need to have access to any pipeline code.
3-
FROM python:3.12-slim
3+
FROM python:3.12-alpine
44

55
COPY requirements.txt .
66
RUN pip install -r requirements.txt

docker/tools/requirements.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# Requirements for running a dagster grpc server in the workflow package images.
2-
dagster==1.10
3-
dagster-postgres==0.26
4-
dagster-docker==0.26
2+
dagster==1.9
3+
dagster-postgres==0.25
4+
dagster-docker==0.25

makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ include .env
8888
download:
8989
rm -rf $(BAG3D_TEST_DATA)
9090
mkdir -p $(BAG3D_TEST_DATA)
91-
cd $(BAG3D_TEST_DATA) ; curl -O https://data.3dbag.nl/testdata/pipeline/test_data_v9.zip ; unzip -q test_data_v9.zip ; rm test_data_v9.zip
91+
cd $(BAG3D_TEST_DATA) ; curl -O https://data.3dbag.nl/testdata/pipeline/test_data_v10.zip ; unzip -q test_data_v10.zip ; rm test_data_v10.zip
9292

9393

9494
install_uv:

packages/common/pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,9 @@ dev = [
4141

4242
[tool.uv.sources]
4343
pgutils = { git = "https://github.com/balazsdukai/pgutils.git", rev = "2024.1013" }
44+
45+
[tool.pytest.ini_options]
46+
filterwarnings = [
47+
"ignore:.*is not a Python type.*:UserWarning",
48+
"ignore:.*Accessing the 'model_fields' attribute on the instance is deprecated.*:DeprecationWarning",
49+
]

packages/core/pyproject.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,9 @@ dev = [
4444
[tool.uv.sources]
4545
pgutils = { git = "https://github.com/balazsdukai/pgutils.git", rev = "2024.1013" }
4646
bag3d-common = { path = "../common", editable = true }
47+
48+
[tool.pytest.ini_options]
49+
filterwarnings = [
50+
"ignore:.*is not a Python type.*:UserWarning",
51+
"ignore:.*Accessing the 'model_fields' attribute on the instance is deprecated.*:DeprecationWarning",
52+
]

packages/core/src/bag3d/core/assets/deploy/godzilla.py

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99

1010
from bag3d.common.utils.database import load_sql
1111
from bag3d.common.types import PostgresTableIdentifier
12+
from dagster import get_dagster_logger
13+
14+
logger = get_dagster_logger("deploy")
1215

1316

1417
@asset(
@@ -20,48 +23,88 @@
2023
AssetKey(("export", "compressed_tiles")),
2124
AssetKey(("export", "compressed_tiles_validation")),
2225
],
26+
required_resource_keys={"version"},
2327
)
2428
def compressed_export_nl(context, reconstruction_output_multitiles_nl):
2529
"""A .tar.gz compressed full directory tree of the exports"""
2630
export_dir = reconstruction_output_multitiles_nl
27-
output_tarfile = export_dir.parent / "export.tar.gz"
31+
version = context.resources.version.version
32+
output_tarfile = export_dir.parent / f"export_{version}.tar.gz"
2833
with tarfile.open(output_tarfile, "w:gz") as tar:
29-
tar.add(export_dir, arcname="export")
34+
tar.add(export_dir, arcname=f"export_{version}")
3035
metadata_output = {
3136
"size [Gb]": output_tarfile.stat().st_size * 1e-9,
3237
"path": str(output_tarfile),
3338
}
3439
return Output(output_tarfile, metadata=metadata_output)
3540

3641

37-
@asset(ins={"metadata": AssetIn(key_prefix="export")})
38-
def downloadable_godzilla(context, compressed_export_nl: Path, metadata: Path):
42+
@asset(
43+
ins={"metadata": AssetIn(key_prefix="export")}, required_resource_keys={"version"}
44+
)
45+
def downloadable_godzilla(
46+
context,
47+
compressed_export_nl: Path,
48+
metadata: Path,
49+
data_dir: str = "/data/3DBAG",
50+
public_dir: str = "/data/3DBAG/public",
51+
):
3952
"""Downloadable files hosted on godzilla.
40-
- Transfer the export.tar.gz archive to `godzilla:/data/3DBAG`
53+
- Transfer the export_<version>.tar.gz archive to `godzilla:/data/3DBAG`
4154
- Uncompress the archive and add the current version to the directory name
4255
- Symlink to the 'export' to the current version
4356
- Add the current version to the tar.gz archive
4457
"""
45-
data_dir = "/data/3DBAG"
4658
with metadata.open("r") as fo:
4759
metadata_json = json.load(fo)
4860
version = metadata_json["identificationInfo"]["citation"]["edition"]
4961
deploy_dir = f"{data_dir}/{version}"
50-
with Connection(host="godzilla.bk.tudelft.nl", user="dagster") as c:
51-
c.put(compressed_export_nl, remote=data_dir)
52-
# delete symlink here, because the uncompressed tar archive is also 'export',
53-
# so we have a bit of downtime here, but that's ok
54-
c.run(f"mkdir {deploy_dir}")
55-
c.run(
56-
f"tar --strip-components=1 -C {deploy_dir} -xzvf {data_dir}/export.tar.gz"
57-
)
58-
# symlink to latest version so the fileserver picks up the data
59-
version_nopoints = version.replace(".", "")
60-
c.run(f"ln -s {deploy_dir} {data_dir}/public/{version_nopoints}")
61-
# add version to the tar so that we can archive the data
62-
# c.run(f"mv {data_dir}/export.tar.gz {data_dir}/export_{version}.tar.gz")
63-
# remove archive
64-
c.run(f"rm {data_dir}/export.tar.gz")
62+
compressed_file = Path(data_dir) / compressed_export_nl.name
63+
64+
try:
65+
with Connection(host="godzilla.bk.tudelft.nl", user="dagster") as c:
66+
# test connection
67+
result = c.run("echo connected", hide=True)
68+
assert result.ok, "Connection command failed"
69+
logger.debug("SSH connection successful")
70+
71+
logger.debug(f"Transferring {compressed_export_nl} to {data_dir}")
72+
result = c.put(compressed_export_nl, remote=data_dir)
73+
logger.debug(f"Transferred: {result}")
74+
75+
logger.debug(f"Creating deploy_dir {deploy_dir}")
76+
result = c.run(f"mkdir -p {deploy_dir}")
77+
assert result.ok, "Creating deploy_dir failed"
78+
79+
logger.debug(f"Decompressing {compressed_file} to {deploy_dir}")
80+
result = c.run(
81+
f"tar --strip-components=1 -C {deploy_dir} -xzvf {compressed_file}"
82+
)
83+
assert result.ok, "Decompressing failed"
84+
85+
# symlink to latest version so the fileserver picks up the data
86+
version_nopoints = version.replace(".", "")
87+
88+
logger.debug(f"Creating public_dir {public_dir}")
89+
result = c.run(f"mkdir -p {public_dir}")
90+
assert result.ok, "Creating public_dir failed"
91+
92+
logger.debug(
93+
f"Creating symlink to {deploy_dir} as {public_dir}/{version_nopoints}"
94+
)
95+
result = c.run(f"ln -s {deploy_dir} {data_dir}/public/{version_nopoints}")
96+
assert result.ok, "Creating symlink failed"
97+
98+
logger.debug(f"Removing compressed file {compressed_file}")
99+
result = c.run(f"rm {compressed_file}")
100+
assert result.ok, "Removing compressed file failed"
101+
102+
logger.info(
103+
f"Deployment successful: Files transferred to {public_dir}/{version_nopoints} on godzilla"
104+
)
105+
except Exception as e:
106+
logger.error(f"SSH connection failed: {e}")
107+
raise
65108
return deploy_dir
66109

67110

0 commit comments

Comments
 (0)