Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'property' object has no attribute 'Layer' #517

Closed
eminaktas opened this issue Apr 22, 2021 · 10 comments · Fixed by #520
Closed

AttributeError: 'property' object has no attribute 'Layer' #517

eminaktas opened this issue Apr 22, 2021 · 10 comments · Fixed by #520

Comments

@eminaktas
Copy link

eminaktas commented Apr 22, 2021

Hello,

With the new release of the package (1.2.0) below error started while deploying the charm. I am not sure what causes this error but this happens at the very beginning of the code that importing the from ops.charm import CharmBase

unit-charm--0: 13:39:07 WARNING unit.charm-/0.install Traceback (most recent call last):
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "./src/charm.py", line 5, in <module>
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     from ops.charm import CharmBase
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/__init__.py", line 43, in <module>
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     from . import charm  # noqa: F401 (imported but unused)
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/charm.py", line 22, in <module>
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     from ops import model
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/model.py", line 1017, in <module>
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     class Container:
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/model.py", line 1053, in Container
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     combine: bool = False):
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     dict(self.__dict__), parameters, _root=True)
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/usr/lib/python3.5/typing.py", line 512, in __new__
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/usr/lib/python3.5/typing.py", line 190, in __subclasscheck__
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     self._eval_type(globalns, localns)
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "/usr/lib/python3.5/typing.py", line 177, in _eval_type
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install     eval(self.__forward_code__, globalns, localns),
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install   File "<string>", line 1, in <module>
unit-charm--0: 13:39:07 WARNING unit.charm-/0.install AttributeError: 'property' object has no attribute 'Layer'
unit-charm--0: 13:39:07 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1
unit-charm--0: 13:39:07 INFO juju.worker.uniter awaiting error resolution for "install" hook
unit-charm--0: 13:39:12 INFO juju.worker.uniter awaiting error resolution for "install" hook

Thanks

@jameinel
Copy link
Member

jameinel commented Apr 22, 2021 via email

@eminaktas
Copy link
Author

Thanks for the quick response. I am using Python 3.5.2 on Ubuntu1604.

Currently, I switched to the older version(ops==1.0.1).

What version of python is this? The line that they are complaining about is: def add_layer(self, label: str, layer: typing.Union[str, typing.Dict, 'pebble.Layer'], , combine: bool = False): Which is just a type annotation and not the code. It seems that the @Property line earlier in the code is confusing the annotations parsing.

On Thu, Apr 22, 2021 at 10:37 AM Emin AKTAS @.
**> wrote: Hello, With the new release of the package (1.2.0) below error started while deploying the charm unit-charm--0: 13:39:07 WARNING unit.charm-/0.install Traceback (most recent call last): unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "./src/charm.py", line 5, in unit-charm--0: 13:39:07 WARNING unit.charm-/0.install from ops.charm import CharmBase unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/init.py", line 43, in unit-charm--0: 13:39:07 WARNING unit.charm-/0.install from . import charm # noqa: F401 (imported but unused) unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/charm.py", line 22, in unit-charm--0: 13:39:07 WARNING unit.charm-/0.install from ops import model unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/model.py", line 1017, in unit-charm--0: 13:39:07 WARNING unit.charm-/0.install class Container: unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/var/lib/juju/agents/unit-charm--0/charm/venv/ops/model.py", line 1053, in Container unit-charm--0: 13:39:07 WARNING unit.charm-/0.install combine: bool = False): unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/usr/lib/python3.5/typing.py", line 552, in getitem unit-charm--0: 13:39:07 WARNING unit.charm-/0.install dict(self.dict), parameters, _root=True) unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/usr/lib/python3.5/typing.py", line 512, in new unit-charm--0: 13:39:07 WARNING unit.charm-/0.install for t2 in all_params - {t1} if not isinstance(t2, TypeVar)): unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/usr/lib/python3.5/typing.py", line 512, in unit-charm--0: 13:39:07 WARNING unit.charm-/0.install for t2 in all_params - {t1} if not isinstance(t2, TypeVar)): unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/usr/lib/python3.5/typing.py", line 190, in subclasscheck unit-charm--0: 13:39:07 WARNING unit.charm-/0.install self._eval_type(globalns, localns) unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "/usr/lib/python3.5/typing.py", line 177, in _eval_type unit-charm--0: 13:39:07 WARNING unit.charm-/0.install eval(self.forward_code, globalns, localns), unit-charm--0: 13:39:07 WARNING unit.charm-/0.install File "", line 1, in unit-charm--0: 13:39:07 WARNING unit.charm-/0.install AttributeError: 'property' object has no attribute 'Layer' unit-charm--0: 13:39:07 ERROR juju.worker.uniter.operation hook "install" (via hook dispatching script: dispatch) failed: exit status 1 unit-charm--0: 13:39:07 INFO juju.worker.uniter awaiting error resolution for "install" hook unit-charm--0: 13:39:12 INFO juju.worker.uniter awaiting error resolution for "install" hook Thanks — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#517>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABRQ7M47FI5VVZSKD3XKR3TKAYB7ANCNFSM43MTIOXQ .

@jameinel
Copy link
Member

jameinel commented Apr 22, 2021 via email

@eminaktas
Copy link
Author

The default version of Python for Xenial(Ubuntu1604) is 3.5.2. So, this could be a problem for someone who uses lxd-cloud.

My case:

juju bootstrap lxd
juju add-model testing localhost/localhost
juju deploy ./mycharm.charm

It automatically downloads the Ubuntu image for Xenial and installs the charm. This case it will fail

@jameinel
Copy link
Member

jameinel commented Apr 22, 2021 via email

@eminaktas
Copy link
Author

Unfortunately, We still use Xenial in some cases. ¯(°_o)/¯.
Thanks for the info John.

Emin

@benhoyt
Copy link
Collaborator

benhoyt commented Apr 23, 2021

I've attempted a fix in #520. I tried to install Python 3.5.2 locally (with pyenv) but it's not working -- something to do with an incorrect libssl version. I'm not going to mess with it anymore, so let's just remove this type annotation for now. @jameinel can you please review?

@benhoyt
Copy link
Collaborator

benhoyt commented Apr 23, 2021

@eminaktas I've fixed this on master now, but can't easily test against Python 3.5.2 locally. Can you please point your charm to the latest master commit (be1fdf0) and ensure that this works for you?

@eminaktas
Copy link
Author

Thanks for the update @benhoyt . I just tested with the latest commit (be1fdf0) it's perfectly working now.

@benhoyt
Copy link
Collaborator

benhoyt commented Apr 24, 2021

Good to know, thanks for the report @eminaktas.

openstack-mirroring pushed a commit to openstack/charm-vault that referenced this issue May 11, 2021
Fixes pip install wheelhouse failure on Hirsute.
canonical/layer-basic#193

Also pin ops!=1.2.0 due to that version of the ops (operator)
library not working with xenial [1].

[1] canonical/operator#517

Change-Id: Ia8194247d5d553e72e694b4e2c649bd418d2adf4
openstack-mirroring pushed a commit to openstack/openstack that referenced this issue May 11, 2021
* Update charm-vault from branch 'master'
  to c4f0c880a3d11a860fb5f408e0ce1150e4426bdb
  - Merge "Rebuild for picking up layer-basic#193"
  - Rebuild for picking up layer-basic#193
    
    Fixes pip install wheelhouse failure on Hirsute.
    canonical/layer-basic#193
    
    Also pin ops!=1.2.0 due to that version of the ops (operator)
    library not working with xenial [1].
    
    [1] canonical/operator#517
    
    Change-Id: Ia8194247d5d553e72e694b4e2c649bd418d2adf4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants