Closed Callum027 closed 2 months ago
Originally encountered while troubleshooting a separate issue with python-gnocchiclient
.
https://github.com/gnocchixyz/python-gnocchiclient/pull/142#issuecomment-2264401121
Test failing because of an unrelated dependency toolchain issue with the version of pkg_resources
(and jaraco.text
) being used.
Traceback (most recent call last):
File "/github/workspace/.tox/py39-postgresql-file-upgrade-from-4.4/bin/gnocchi", line 5, in <module>
from gnocchiclient.shell import main
File "/github/workspace/.tox/py39-postgresql-file-upgrade-from-4.4/lib/python3.9/site-packages/gnocchiclient/shell.py", line 40, in <module>
from gnocchiclient.version import __version__
File "/github/workspace/.tox/py39-postgresql-file-upgrade-from-4.4/lib/python3.9/site-packages/gnocchiclient/version.py", line 15, in <module>
import pkg_resources
File "/github/workspace/.tox/py39-postgresql-file-upgrade-from-4.4/lib/python3.9/site-packages/pkg_resources/__init__.py", line 96, in <module>
from jaraco.text import (
ImportError: cannot import name 'yield_lines' from 'jaraco.text' (/usr/lib/python3/dist-packages/jaraco/text/__init__.py)
py39-postgresql-file-upgrade-from-4.4: exit 1 (45.47 seconds) /github/workspace> run-upgrade-tests.sh postgresql-file pid=120
py39-postgresql-file-upgrade-from-4.4: FAIL code 1 (52.61=setup[7.14]+cmd[45.47] seconds)
evaluation failed :( (52.67 seconds)
Replace usage of the deprecated backref option [1] and implicit relationship population, with the new back_populates [2] option and explicit relationship definitions on both the Metric and Resource classes.
This eliminates "AttributeError: type object 'Metric' has no attribute 'resource'" exceptions that can occur when Metric.resource is referenced using sqlalchemy.orm.joinedload in queries.
This change is backwards compatible with SQLAlchemy 1.4.
1: https://docs.sqlalchemy.org/en/20/orm/backref.html 2: https://docs.sqlalchemy.org/en/20/orm/basic_relationships.html