ep1cman / unifi-protect-backup

Python tool to backup unifi event clips in realtime
MIT License
576 stars 25 forks source link

Bump pyunifiprotect to support 3.0.22 #133

Closed mmolitor87 closed 3 months ago

ep1cman commented 3 months ago

Hi,

Are you able to provide any more details about this?

Why is it necessary? Has it been confirmed working?

This is a major version bump of pyunifiprotect which implies breaking changes. I don't feel comfortable making this upgrade unless a) it is necessary for the tool to continue to function b) the changes have been verified to not effect any of the functionality of the tool

Also please do not bump the version of the tool as part of the pull request. This shall be done when an actual release is made, which might not necessarily be directly after this PR (For example another PR has just come in too)

mmolitor87 commented 3 months ago

Hi,

Are you able to provide any more details about this?

Why is it necessary? Has it been confirmed working?

This is a major version bump of pyunifiprotect which implies breaking changes. I don't feel comfortable making this upgrade unless a) it is necessary for the tool to continue to function b) the changes have been verified to not effect any of the functionality of the tool

Also please do not bump the version of the tool as part of the pull request. This shall be done when an actual release is made, which might not necessarily be directly after this PR (For example another PR has just come in too)

Yes it is confirmed working in my own instance. I have been running the EA protect 3.0.10, 3.0.21 and 3.0.22 with pyunifiprotect 5.0.2 forcefully updated. It will not run without being bumped to 5.0.0 at a minimum due to 3.0.10+ relying on this commit:

https://github.com/AngellusMortis/pyunifiprotect/commit/077e9c8120016e825d658cbbe1119971765557b0

Also sorry for the mess I'm still learning git.

ontarionick commented 3 months ago

Hey @ep1cman, I can confirm that the latest Unifi Protect GA update has broken unifi-protect-backup (I use your amazing library in my Home Assistant addon: https://github.com/ontarionick/hass-unifi-protect-backup). I tested bumping pyunifiprotect locally to the v5.0.2 release and this has fixed the issues.

For the record, here's the exception I was getting:

Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/unifi_protect_backup/unifi_protect_backup_core.py", line 190, in start
    await self._protect.update()
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/api.py", line 673, in update
    self._bootstrap = await self.get_bootstrap()
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/api.py", line 1009, in get_bootstrap
    return Bootstrap.from_unifi_dict(**data, api=self)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 120, in from_unifi_dict
    data = cls.unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/bootstrap.py", line 224, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 369, in unifi_dict_to_dict
    data[key] = cls._clean_protect_obj_dict(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 311, in _clean_protect_obj_dict
    items[key] = cls._clean_protect_obj(value, klass, api)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 289, in _clean_protect_obj
    return klass.unifi_dict_to_dict(data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/user.py", line 170, in unifi_dict_to_dict
    return super().unifi_dict_to_dict(data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 360, in unifi_dict_to_dict
    data[key] = cls._clean_protect_obj_list(
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 300, in _clean_protect_obj_list
    items[index] = cls._clean_protect_obj(item, klass, api)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/base.py", line 289, in _clean_protect_obj
    return klass.unifi_dict_to_dict(data=data)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/user.py", line 34, in unifi_dict_to_dict
    data["nodes"] = [PermissionNode(n) for n in parts[1].split(",")]
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/pyunifiprotect/data/user.py", line 34, in <listcomp>
    data["nodes"] = [PermissionNode(n) for n in parts[1].split(",")]
                     ^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 712, in __call__
    return cls.__new__(cls, value)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/enum.py", line 1135, in __new__
    raise ve_exc
ValueError: 'readlive' is not a valid PermissionNode
natehudson commented 3 months ago

I'm seeing the same error after upgrading Protect to latest GA.

I was able to get my docker container working by execing and running the "dangerous" command.

pip install pyunifiprotect --upgrade --break-system-packages

Everything seems to be working with the latest version of pyunifiprotect for what it is worth.

NetDude12 commented 3 months ago

I'm seeing the same error after upgrading Protect to latest GA.

I was able to get my docker container working by execing and running the "dangerous" command.

pip install pyunifiprotect --upgrade --break-system-packages

Everything seems to be working with the latest version of pyunifiprotect for what it is worth.

This worked from me as well on Unraid. Thanks

ep1cman commented 3 months ago

Merging now and will soon push a new release to address this

natehudson commented 3 months ago

Thanks! Maybe it is just me but I pulled down the latest docker image and the error is still present even though it looks like version 0.10.6 is in the image.

# unifi-protect-backup --version
unifi-protect-backup, version 0.10.6

# pip list | grep -i pyunifi
pyunifiprotect       4.23.4
ep1cman commented 3 months ago

Nope, you're correct, this pull request didnt actually set the minimum pyunifiprotect version properly, it just updated the lock file. Expect a new really to properly force it to use 5.x.x in the next few mins

natehudson commented 3 months ago

Docker image 0.10.7 is working great, thanks so much.

Swallowtail23 commented 3 months ago

Doh.. Sees these last messages 2 mins after finishing update to 0.10.6... 😂