question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:10 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
benhoytcommented, 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 (https://github.com/canonical/operator/commit/be1fdf0698e33ed2274eb417da5b64f2656239fb) and ensure that this works for you?

1reaction
jameinelcommented, Apr 22, 2021

So we do run a regression test on Python 3.5, but our test infrastructure is 3.5.10. Is it possible for you to test with a newer version of Python? That feels like the sort of thing they might have fixed upstream. https://github.com/canonical/operator/runs/2395784540

On Thu, Apr 22, 2021 at 11:24 AM Emin AKTAS @.***> wrote:

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 https://github.com/Property line earlier in the code is confusing the annotations parsing. … <#m_-1131703211203150840_> 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 https://github.com/canonical/operator/issues/517>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABRQ7M47FI5VVZSKD3XKR3TKAYB7ANCNFSM43MTIOXQ .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/canonical/operator/issues/517#issuecomment-824938866, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABRQ7O5AO23FTAMMGTF2STTKA5RJANCNFSM43MTIOXQ .

Read more comments on GitHub >

github_iconTop Results From Across the Web

'Layer' object has no attribute 'metadata' from ArcPy with ...
I think you are trying to use a property that only became available in versions later than ArcGIS Pro 2.4. When I run...
Read more >
AttributeError: 'property' object has no attribute - Stack Overflow
Property objects have no doSomething attribute. Properties are designed to be created in classes as descriptions of how the instances of those classes...
Read more >
Getting AttributeError when trying to overwrite feature layer in ...
AttributeError : 'PropertyMap' instance has no attribute 'tables'. I get the same error when I try to update just the csv item that...
Read more >
Python AttributeError: 'tuple' object has no attribute
AttributeError : 'tuple' object has no attribute. Learn Data Science with. This error occurs when attempting to access the values of a tuple...
Read more >
AttributeError DataFrame object has no attribute is impossible
AttributeError DataFrame object has no attribute is impossible · Hey, @Mohammed,. In which version of python you are running? You can try to ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found