canonical / data-platform-libs

A collection of charm libraries curated by the Data Platform Team
https://charmhub.io/data-platform-libs
Apache License 2.0
10 stars 9 forks source link

metaclass conflict #58

Closed beliaev-maksim closed 1 year ago

beliaev-maksim commented 1 year ago

When try to import the library we get an exception:

2023-04-14 09:57:40 WARNING install Traceback (most recent call last):
2023-04-14 09:57:40 WARNING install   File "./src/charm.py", line 13, in <module>
2023-04-14 09:57:40 WARNING install     from charms.data_platform_libs.v0.data_interfaces import DatabaseRequires
2023-04-14 09:57:40 WARNING install   File "/var/lib/juju/agents/unit-mlflow-server-0/charm/lib/charms/data_platform_libs/v0/data_interfaces.py", line 356, in <module>
2023-04-14 09:57:40 WARNING install     class DataProvides(Object, ABC):
2023-04-14 09:57:40 WARNING install TypeError: metaclass conflict: the metaclass of a derived class must be a (non-strict) subclass of the metaclasses of all its bases
2023-04-14 09:57:40 ERROR juju.worker.uniter.operation runhook.go:140 hook "install" (via hook dispatching script: dispatch) failed: exit status 1

one of the potential issues might be that our charm requires ops<2 which we set in reqs.txt for our charm. While this lib requires ops>2. Not sure how charmcraft is going to resolve it. but the issue might different, worth to investigate

github-actions[bot] commented 1 year ago

https://warthogs.atlassian.net/browse/DPE-1659

taurus-forever commented 1 year ago

It sounds like a reason for reverting/refactoring https://github.com/canonical/data-platform-libs/pull/35 CC: @deusebio Try to bump ops lib to 2+, we have migrated from 1.5 to 2.2.0 without any issues.

beliaev-maksim commented 1 year ago

yes, I confirm that if we bump our charm to ops>2 then it works

maybe at least clear error if ops is of unsupported version? since now it fails very cryptic

deusebio commented 1 year ago

Uhm, we specified this using charmlibs dependency (see here). We point this out in the README as well, actually. It would actually be good if - when one does charmcraft pack - the consistency of these libraries are checked and errors are thrown otherwise

I can see that this can happen all the times that we have dependencies to comply with in our charmlibs unfortunately

beliaev-maksim commented 1 year ago

@deusebio I mentioned to Sergio. However, in meantime we can also offer something from the library end

sergiusens commented 1 year ago

using the new PYDEPS feature and having the libraries declare ops > 2 (for this case) would solve this issue.

sergiusens commented 1 year ago

recall that PYDEPS is currently on charmcraft edge only.

beliaev-maksim commented 1 year ago

@sergiusens that answers, then this ops dependency just got lost when we packed

@deusebio then I assume no action on the lib side

deusebio commented 1 year ago

:+1: Closing the issue then!