Skip to content

Commit 169601c

Browse files
authored
Merge pull request #303 from 3DBAG/fix/log-subprocess-commands
Fix/log subprocess commands
2 parents 0d98643 + 92762fa commit 169601c

File tree

7 files changed

+26
-11
lines changed

7 files changed

+26
-11
lines changed

docker/pipeline/bag3d-core.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM 3dgi/3dbag-pipeline-tools:2025.08.17 AS develop
1+
FROM 3dgi/3dbag-pipeline-tools:2025.08.19 AS develop
22
ARG VERSION=develop
33
ARG BAG3D_PIPELINE_LOCATION=/opt/3dbag-pipeline
44

docker/pipeline/bag3d-floors-estimation.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM 3dgi/3dbag-pipeline-tools:2025.08.17 AS develop
1+
FROM 3dgi/3dbag-pipeline-tools:2025.08.19 AS develop
22
ARG VERSION=develop
33
ARG BAG3D_PIPELINE_LOCATION=/opt/3dbag-pipeline
44

docker/pipeline/bag3d-party-walls.dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM 3dgi/3dbag-pipeline-tools:2025.08.17 AS develop
1+
FROM 3dgi/3dbag-pipeline-tools:2025.08.19 AS develop
22
ARG VERSION=develop
33
ARG BAG3D_PIPELINE_LOCATION=/opt/3dbag-pipeline
44

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ def execute(
115115
local_path: Path = None,
116116
silent=False,
117117
cwd: str = None,
118+
output_logging: str = "STREAM",
118119
) -> Tuple[int, str]:
119120
"""Execute a command in a docker container if an image is available, otherwise
120121
execute with the local executable.
@@ -149,6 +150,9 @@ def execute(
149150
mounted on the ``mount_point`` as
150151
``local_path : mount_point/local_path.name``.
151152
silent: If False, send execution messages to the logger, else do not log.
153+
output_logging: The logging mode to use. Supports STREAM, BUFFER, and NONE.
154+
STREAM: Stream back logs as they are emitted. BUFFER: Collect and
155+
buffer all logs, then emit.
152156
153157
Returns:
154158
The return code and STDOUT from the command execution.
@@ -200,7 +204,7 @@ def execute(
200204
output, return_code = execute_shell_command(
201205
shell_command=command.format(**kwargs_with_exe),
202206
log=self.logger,
203-
output_logging="STREAM",
207+
output_logging=output_logging,
204208
cwd=cwd,
205209
)
206210
if return_code != 0:

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ def ogrinfo(
7474
for feature_type in feature_types:
7575
kwargs = {"xsd": xsd, "dataset": dataset, "feature_type": feature_type}
7676
return_code, output = gdal.execute(
77-
"ogrinfo", command=cmd, kwargs=kwargs, local_path=extract_path
77+
"ogrinfo",
78+
command=cmd,
79+
kwargs=kwargs,
80+
local_path=extract_path,
81+
output_logging="BUFFER",
7882
)
7983
if return_code == 0:
8084
layername, layerinfo = parse_ogrinfo(output, feature_type)
@@ -235,7 +239,11 @@ def ogr2postgres(
235239
"dataset": dataset,
236240
}
237241
return_code, output = gdal.execute(
238-
"ogr2ogr", command=cmd, kwargs=kwargs, local_path=extract_path
242+
"ogr2ogr",
243+
command=cmd,
244+
kwargs=kwargs,
245+
local_path=extract_path,
246+
output_logging="BUFFER",
239247
)
240248
if return_code == 0:
241249
return postgrestable_metadata(context, new_table)
@@ -267,6 +275,7 @@ def pdal_info(
267275
command=" ".join(cmd_list),
268276
local_path=file_path,
269277
silent=(not verbose),
278+
output_logging="BUFFER",
270279
)
271280
except Exception as e:
272281
if "Global encoding WKT flag" in str(e):

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from functools import partial
44

55
import pytz
6-
from dagster import asset, Output, Field
6+
from dagster import asset, Output, Field, get_dagster_logger
77
from pgutils import PostgresTableIdentifier
88
from psycopg.sql import Literal, SQL
99
from psycopg.types.json import Jsonb, set_json_dumps
@@ -198,11 +198,12 @@ def compute_load_metadata(
198198
Returns:
199199
None
200200
"""
201+
logger = get_dagster_logger()
201202
tile_id = context.partition_key
202203
conn = context.resources.db_connection.connect
203204
if not laz_files_ahn.new:
204205
if not context.op_execution_context.op_execution_context.op_config["force"]:
205-
context.log.info(
206+
logger.info(
206207
f"Metadata for this LAZ tile {tile_id} already exists, "
207208
f"skipping computation."
208209
)
@@ -241,7 +242,7 @@ def compute_load_metadata(
241242
ST_SetSRID(ST_GeomFromGeoJSON({boundary}), 28992)
242243
);
243244
""").format(**query_params)
244-
context.log.debug(conn.print_query(query))
245+
logger.debug(conn.print_query(query))
245246
conn.send_query(query)
246247
# Cannot index the table here, because this is a partitioned assed. This means that
247248
# this function is called for each partition, which would index the table after
@@ -250,11 +251,12 @@ def compute_load_metadata(
250251

251252

252253
def metadata_table_ahn(context, ahn_version: int) -> PostgresTableIdentifier:
254+
logger = get_dagster_logger()
253255
conn = context.resources.db_connection.connect
254256
new_schema = "ahn"
255257
create_schema(context, new_schema)
256258
new_table = PostgresTableIdentifier(new_schema, f"metadata_ahn{ahn_version}")
257259
query = load_sql(query_params={"new_table": new_table})
258-
context.log.info(conn.print_query(query))
260+
logger.info(conn.print_query(query))
259261
conn.send_query(query)
260262
return new_table

packages/core/tests/test_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ def test_integration_ahn(database, core_file_store):
8383
"config": {"force_download": False, "check_hash": False}
8484
},
8585
f"metadata_{ahn_version}": {
86-
"config": {"force": True, "all": True}
86+
"config": {"force": True, "all": True, "verbose": True}
8787
},
8888
f"lasindex_{ahn_version}": {"config": {"force": True}},
8989
}

0 commit comments

Comments
 (0)