Skip to content

Commit 4e2aed2

Browse files
feat: Remove docker_py usage in favor of custom client that uses Docker CLI (#33)
#### Relevant issue or PR Fixes #10 Enables #8 #### Description of changes - Created a new `docker_client.py` file that contains a `CLIDockerClient` class that is a custom python wrapper over `docker_cli` that mimics the interface of `docker_py`. - The file has 3 additional classes, `Container`, `Compose`, and `Image`. - Removed a lot of functions from existing files (all calls to subprocess) and docker errors. Migrated them to the `docker_client.py` and replaced errors with our new errors. - `teardown` function in cli has the most amount of changes as handling of `--all` flag is moved to `engine.teardown` instead as we no longer need to filter through all the projects in docker and parse which ones belong to Tesseract as our `DockerWrapper` class already knows all the projects that are Tesseracts. - Renamed `_display_container_meta` to `_display_project_meta` as I think it's more fitting to the function since we are listing the metadata of all the containers in a project, aka the project's metadata. - Modified some unit tests to fit the new mocked class. BREAKING CHANGE: Tesseract Core does not clear build caches anymore. That means, the option `--keep-build-cache` and environment variable `TESSERACT_KEEP_BUILD_CACHE` are now removed, and users are advised to clean up Docker resources manually as needed (e.g. via `docker system prune`). #### Testing done Unit tests + Manually tested commands: `serve` `build` `ps` `list` `teardown` `teardown --all` `apidoc` #### 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: [Angela Ko] <angela.ko@simulation.science> --------- Co-authored-by: Dion Häfner <dion.haefner@simulation.science>
1 parent 90d486c commit 4e2aed2

File tree

14 files changed

+3102
-2086
lines changed

14 files changed

+3102
-2086
lines changed

docs/content/creating-tesseracts/advanced.md

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ various circumstances:
8282
only be printed if something fails; this means that your shell might appear unresponsive
8383
during this process. If you want more detailed information on what's going on during your
8484
build, and see updates about it in real-time, use `--loglevel debug`.
85-
- By default `tesseract build` does not cache the various steps of building a Tesseract[^1]. This is a good choice once your Tesseract is mature enough (i.e., once you are not re-building frequently). While you are still implementing new features in the Tesseract and rebuilding it
86-
often, we recommend to use `--keep-build-cache` flag to keep your build steps in the cache,
87-
so that the next `tesseract build` runs faster.
88-
```{note}
89-
A single `tesseract build` command without
90-
the `--keep-build-cache` option will invalidate the cache.
91-
```
9285
- `--config-override` can be used to manually override options specified in the `tesseract_config.yaml`,
9386
for example: `--config-override build_config.target_platform=linux/arm64`
9487
- `tesseract build` relies on a `docker build` command to create the Tesseract image. By
@@ -100,11 +93,11 @@ various circumstances:
10093

10194
## Building Tesseracts with private dependencies
10295

103-
- In case you have some dependencies in `tesseract_requirements.txt` for which you need to
104-
ssh into a server (e.g., private repositories which you specify via "git+ssh://..."),
105-
you can make your ssh agent available to `tesseract build` with the option
106-
`--forward-ssh-agent`. Alternatively you can use `pip download` to download a dependency
107-
to the machine that builds the Tesseract.
96+
In case you have some dependencies in `tesseract_requirements.txt` for which you need to
97+
ssh into a server (e.g., private repositories which you specify via "git+ssh://..."),
98+
you can make your ssh agent available to `tesseract build` with the option
99+
`--forward-ssh-agent`. Alternatively you can use `pip download` to download a dependency
100+
to the machine that builds the Tesseract.
108101

109102
## Customizing the build process
110103

@@ -140,10 +133,9 @@ For example:
140133
## Tesseracts without containerization
141134

142135
While developing a Tesseract, the process of building and rebuilding the
143-
tesseract image for quick local tests can be very time-consuming. Using
144-
`--keep-build-cache` ameliorates this issue, but the fastest and most
145-
convenient way to speed this up is to just run the code you are developing
146-
in your virtual environment.
136+
tesseract image for quick local tests can be very time-consuming. The fastest and most
137+
convenient way to speed this up is to just run the code you are developing directly
138+
in your virtual Python environment.
147139

148140
In order to do so, you should:
149141
- Make sure you have a development installation of Tesseract (see <project:#installation-dev>).
@@ -181,9 +173,3 @@ Python package. In order to do so, you can run `tesseract init` in the root fold
181173
your package (i.e., where `setup.py` and `requirements.txt` would be). Import your package
182174
as needed in `tesseract_api.py`, and specify the dependencies you need at runtime in
183175
`tesseract_requirements.py`.
184-
185-
[^1]: There are several reasons for this. We wanted to make Tesseracts friendly to
186-
people unfamiliar with Docker, and this default reduces the chance of them accidentally filling their
187-
hard drives with data. Also, in a typical SciML setting, cache gets
188-
invalidated quite fast, so a lot of the data which would be saved to the disk
189-
would not really help with build times.

inject_runtime_pyproject.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"tesseract-core[runtime]",
2525
],
2626
"dev": [
27+
"docker",
2728
"fastapi",
2829
"httpx", # required by fastapi test client
2930
"jsf",

production.uv.lock

Lines changed: 1493 additions & 1493 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ authors = [
88
license = { text = "Apache-2.0" }
99
requires-python = ">=3.10"
1010
dependencies = [
11-
"docker",
1211
"jinja2",
1312
"rich",
1413
"typer",

requirements.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ click==8.1.8
1010
# via typer
1111
colorama==0.4.6 ; sys_platform == 'win32'
1212
# via click
13-
docker==7.1.0
14-
# via tesseract-core
1513
idna==3.10
1614
# via requests
1715
jinja2==3.1.6
@@ -32,14 +30,10 @@ pydantic-core==2.33.0
3230
# via pydantic
3331
pygments==2.19.1
3432
# via rich
35-
pywin32==310 ; sys_platform == 'win32'
36-
# via docker
3733
pyyaml==6.0.2
3834
# via tesseract-core
3935
requests==2.32.3
40-
# via
41-
# docker
42-
# tesseract-core
36+
# via tesseract-core
4337
rich==14.0.0
4438
# via
4539
# tesseract-core
@@ -58,6 +52,4 @@ typing-extensions==4.13.2
5852
typing-inspection==0.4.0
5953
# via pydantic
6054
urllib3==2.4.0
61-
# via
62-
# docker
63-
# requests
55+
# via requests

0 commit comments

Comments
 (0)