Skip to content

Commit

Permalink
chore(deps): py bump docker ^7.1.0, requests ^2.32.2 (#115)
Browse files Browse the repository at this point in the history
* chore(deps): py bump docker ^7.1.0, requests ^2.32.2

Signed-off-by: Matteo Mortari <[email protected]>

* add Mac OSX specific instructions

Signed-off-by: Matteo Mortari <[email protected]>

* Update CONTRIBUTING.md

Signed-off-by: Matteo Mortari <[email protected]>

Co-authored-by: Isabella Basso <[email protected]>

* Update CONTRIBUTING.md

Signed-off-by: Matteo Mortari <[email protected]>

---------

Signed-off-by: Matteo Mortari <[email protected]>
Co-authored-by: Isabella Basso <[email protected]>
  • Loading branch information
tarilabs and isinyaaa authored Jun 4, 2024
1 parent c022fdb commit e695960
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 61 deletions.
41 changes: 41 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,19 @@ and now you can substitute `gmake` every time the make command is mentioned in g
Several options of docker engines are available for Mac.
Having Docker installed is also helpful for Testcontainers.

### Podman

[Podman](https://podman.io/) also supports Rosetta (Apple specific) emulation which is handy since the Google MLMD project dependency is x86 specific.

We recommend setting up the Podman machine with root privileges,
and setting the environment variable

```sh
export TESTCONTAINERS_RYUK_PRIVILEGED=true
```

when running TestContainer-based Model Registry Python tests (for more information, see [here](https://pypi.org/project/testcontainers/#:~:text=TESTCONTAINERS_RYUK_PRIVILEGED)).

### Colima

Colima offers Rosetta (Apple specific) emulation which is handy since the Google MLMD project dependency is x86 specific.
Expand Down Expand Up @@ -202,3 +215,31 @@ Then with the given setup MLMD is already installed inside the DevContainer:
At this point Poetry is already installed as well and can be used to build and run test of the Model Registry Python client.

<!-- to be continued with explanation of this "hack": https://github.com/tarilabs/ml-metadata-remote#readme -->

# FAQ

## Error `docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.41/containers ...`

This happens on Mac OSX when running Testcontainers-based Python tests, and [Ryuk](https://github.com/testcontainers/moby-ryuk) does not have the correct access priviledges.

```
-------------------------------------------- Captured stderr setup ---------------------------------------------
Pulling image testcontainers/ryuk:0.7.0
Container started: 4af385c2d670
---------------------------------------------- Captured log setup ----------------------------------------------
WARNING root:config.py:59 DOCKER_AUTH_CONFIG is experimental, see testcontainers/testcontainers-python#566
INFO testcontainers.core.container:container.py:88 Pulling image testcontainers/ryuk:0.7.0
INFO testcontainers.core.container:container.py:101 Container started: 4af385c2d670
=========================================== short test summary info ============================================
ERROR tests/store/test_wrapper.py::test_get_undefined_artifact_type_id - docker.errors.NotFound: 404 Client Error for http+docker://localhost/v1.41/containers/4af385c2d67067875f6f0...
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! stopping after 1 failures !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=============================================== 1 error in 0.50s ===============================================
```

Solution:
- Use `export TESTCONTAINERS_RYUK_PRIVILEGED=true` (we recommend this option)
- Use `export TESTCONTAINERS_RYUK_DISABLED=true` to disable Ryuk entirely; the tests are configured to close all container resources, but we do not recommend this option

For more information:
- section [Docker engine](https://github.com/kubeflow/model-registry/blob/main/CONTRIBUTING.md#docker-engine) in this document
- https://pypi.org/project/testcontainers/#:~:text=the%20database%20version.-,Configuration,-Env%20Variable
3 changes: 2 additions & 1 deletion clients/python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,14 @@ Use `nox -l` to list sessions and execute them using `nox -s [session]`.

### Running Locally on Mac M1 or M2 (arm64 architecture)

If you want run tests locally you will need to set up a colima develeopment environment using the instructions [here](https://github.com/kubeflow/model-registry/blob/main/CONTRIBUTING.md#colima)
If you want run tests locally you will need to set up a development environment, including docker engine; we recommend following the instructions [here](https://github.com/kubeflow/model-registry/blob/main/CONTRIBUTING.md#docker-engine).

You will also have to change the package source to one compatible with ARM64 architecture. This can be actioned by uncommenting lines 14 or 15 in the pyproject.toml file. Run the following command after you have uncommented the line.

```sh
poetry lock
```

Use the following commands to directly run the tests with individual test output. Alternatively you can use the nox session commands above.

```sh
Expand Down
97 changes: 39 additions & 58 deletions clients/python/poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions clients/python/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ homepage = "https://github.com/kubeflow/model-registry"
[tool.poetry.dependencies]
python = ">= 3.9, < 3.11"
attrs = "^21.0"
ml-metadata = "^1.14.0"
ml-metadata = "==1.14.0"
# you might consider using locally the following alternative, when developing on Apple-silicon/ARM-based computers:
# ml-metadata = { url = "https://github.com/opendatahub-io/ml-metadata/releases/download/v1.14.0%2Bremote.1/ml_metadata-1.14.0+remote.1-py3-none-any.whl" }
typing-extensions = "^4.8"

huggingface-hub = { version = ">=0.20.1,<0.24.0", optional = true }
# pin docker+requests dependencies of testcontainers to docker ^7.1.0 for compatibility with requests ^2.32.2; ref: https://github.com/testcontainers/testcontainers-python/issues/577#issuecomment-2123324367
requests = { version = "^2.32.2", optional = true }

[tool.poetry.extras]
hf = ["huggingface-hub"]
Expand All @@ -33,7 +35,9 @@ pytest-cov = "^4.1.0"
sphinx-autobuild = ">=2021.3.14,<2025.0.0"
ruff = "^0.4.4"
mypy = "^1.7.0"
testcontainers = "^3.7.1"
testcontainers = "^4.5.0"
# pin docker+requests dependencies of testcontainers to docker ^7.1.0 for compatibility with requests ^2.32.2; ref: https://github.com/testcontainers/testcontainers-python/issues/577#issuecomment-2123324367
docker = "^7.1.0"

[tool.coverage.run]
branch = true
Expand Down

0 comments on commit e695960

Please sign in to comment.