Skip to content

Commit fdcbcb9

Browse files
authored
feat: add stdout output for tesseract build (#87)
#### Relevant issue or PR n/a #### Description of changes `tesseract build` now prints a JSON representation of the tags of the built image to stdout. This allows scripts to discover the correct Docker image to use for further processing (in cases where the Tesseract name is unknown). #### Testing done CI #### License - [x] By submitting this pull request, I confirm that my contribution is made under the terms of the [Apache 2.0 license](https://pasteurlabs.github.io/tesseract/LICENSE). - [x] I sign the Developer Certificate of Origin below by adding my name and email address to the `Signed-off-by` line. <details> <summary><b>Developer Certificate of Origin</b></summary> ```text Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ``` </details> Signed-off-by: Dion Häfner <dion.haefner@simulation.science>
1 parent 687139b commit fdcbcb9

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tesseract_core/sdk/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,9 @@ def build_image(
272272
273273
The passed directory must contain the files `tesseract_api.py` and `tesseract_config.yaml`
274274
(can be created via `tesseract init`).
275+
276+
Prints the built images as JSON array to stdout, for example: `["mytesseract:latest"]`.
277+
If `--generate-only` is set, the path to the build context is printed instead.
275278
"""
276279
if config_override is None:
277280
config_override = []
@@ -313,6 +316,7 @@ def build_image(
313316
# output is the built image
314317
image = build_out
315318
logger.info(f"Built image {image.short_id}, {image.tags}")
319+
typer.echo(json.dumps(image.tags))
316320

317321

318322
@app.command("init")

tests/endtoend_tests/common.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Copyright 2025 Pasteur Labs. All Rights Reserved.
22
# SPDX-License-Identifier: Apache-2.0
33

4+
import json
45
import traceback
56

67
from typer.testing import CliRunner
@@ -27,7 +28,7 @@ def print_debug_info(result):
2728

2829

2930
def build_tesseract(sourcedir, image_name, tag=None, build_retries=3):
30-
cli_runner = CliRunner()
31+
cli_runner = CliRunner(mix_stderr=False)
3132

3233
build_args = [
3334
"--loglevel",
@@ -58,4 +59,7 @@ def build_tesseract(sourcedir, image_name, tag=None, build_retries=3):
5859

5960
print_debug_info(result)
6061
assert result.exit_code == 0, result.exception
61-
return image_name
62+
63+
image_tags = json.loads(result.stdout.strip())
64+
assert image_name in image_tags
65+
return image_tags[0]

0 commit comments

Comments
 (0)