canonical / katib-operators

Operators for Katib which is part of Charmed Kubeflow.
Apache License 2.0
1 stars 3 forks source link

Integration test fails with Python 3.10 because of version conflict in requirements #139

Open bschimke95 opened 1 year ago

bschimke95 commented 1 year ago

Bug Description

I checked out the repository locally and tried to simply run the integration tests for charms/katib-controller with tox. The test fails to install the dependencies because of a version conflict between juju and websocket (see logs below).

This only surfaces when using Python 3.10 - 3.8 runs just fine. However, since 3.10 is the default on jammy I would assume that Python 3.10 should also be supported.

I see (and verified locally) three possible fixes:

  1. Pin the tox testenv version to 3.8 (if 3.10 is not a requirement)
  2. Juju version requirement is set to <4.0 which translates to 3.2.2 on my machine. Pinning the version to 3.1.x would resolve the dependency conflict.
  3. Update the requirements.txt file by rerunning pip-compile requirements-integration.in. This solves the conflict locally for me and is also backward-compatible with Python 3.8

Let me know which solution you'd prefer (if any) and I'll happily open a PR to fix it.

To Reproduce

  1. git checkout git@github.com:canonical/katib-operators.git
  2. cd katib-operators/charms/katib-controller
  3. tox

Environment

Relevant Log Output

katib-operators/charms/katib-controller on  main [$] …
➜ tox
...
  Using cached websocket_client-1.6.2-py3-none-any.whl.metadata (7.5 kB)
Collecting websockets==8.1 (from -r requirements-integration.txt (line 203))
  Using cached websockets-8.1.tar.gz (58 kB)
  Preparing metadata (setup.py) ... done
INFO: pip is looking at multiple versions of juju to determine which version is compatible with other requirements. This could take a while.

The conflict is caused by:
    The user requested websockets==8.1
    juju 3.2.2 depends on websockets>=10.0; python_version > "3.9"

To fix this you could try to:
1. loosen the range of package versions you've specified
2. remove package versions to allow pip attempt to solve the dependency conflict

ERROR: Cannot install -r requirements-integration.txt (line 66) and websockets==8.1 because these package versions have conflicting dependencies.
ERROR: ResolutionImpossible: for help visit https://pip.pypa.io/en/latest/topics/dependency-resolution/#dealing-with-dependency-conflicts

integration: exit 1 (6.01 seconds) /home/benjamin/work/katib-operators/charms/katib-controller> python -I -m pip install -r requirements-integration.txt pid=760514
  fmt: OK (1.89=setup[1.71]+cmd[0.07,0.10] seconds)
  lint: OK (2.94=setup[2.50]+cmd[0.07,0.13,0.07,0.17] seconds)
  unit: OK (0.07 seconds)
  integration: FAIL code 1 (6.09 seconds)
  evaluation failed :( (11.02 seconds)

Additional Context

No response

ca-scribner commented 9 months ago

Thanks @bschimke95! Sorry we got to this so slowly.

You're totally right, we should be using tox to handle this. It affects this repo and basically all the other charmed kubeflow repos, too. We've opened https://github.com/canonical/bundle-kubeflow/issues/761 to track this across the whole bundle.

Do you know or have an example of the syntax to do this in tox? I've seen some magic in tox environment names that drive the python version, but not how to do it explicitly - do you have an example we can model our change from?