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

Auto-stacking fails when skip_previous is True #10

Open
kvalev opened this issue Aug 31, 2024 · 8 comments
Open

Auto-stacking fails when skip_previous is True #10

kvalev opened this issue Aug 31, 2024 · 8 comments

Comments

@kvalev
Copy link

kvalev commented Aug 31, 2024

I just setup an immich stack with an auto-stacking sidecar container, but the auto-stacking fails if skip_previous is set to True:

immich-auto-stack-1        | Traceback (most recent call last):
immich-auto-stack-1        |   File "/script/immich_auto_stack.py", line 220, in <module>
immich-auto-stack-1        |     main()
immich-auto-stack-1        |   File "/script/immich_auto_stack.py", line 195, in main
immich-auto-stack-1        |     children_id = [x['id'] for x in stack[1:] if x['stackCount'] == None ]
immich-auto-stack-1        |                                                  ~^^^^^^^^^^^^^^
immich-auto-stack-1        | KeyError: 'stackCount'

I dont know whether stackCount is something that is supposed to come from the immich API or it is some refactoring leftover, but in any case, it fails with the latest immich version

@tenekev
Copy link
Owner

tenekev commented Aug 31, 2024

Could you find out which picture causes this error and provide the API response for it?

stackCount is part of the API response. It should be there always. And there is no deprecation notice.

I'll catch it but I really want to know what could have caused it.

@kvalev
Copy link
Author

kvalev commented Aug 31, 2024

Could you find out which picture causes this error and provide the API response for it?

stackCount is part of the API response. It should be there always. And there is no deprecation notice.

I'll catch it but I really want to know what could have caused it.

Thanks for the quick response. I ran couple of tests and there really isn't a stackCount field in the API response. I just started with immich so I might be missing something very obvious tho.

Here is the content of x, which should be what the API is returning:

{'id': '397eb2b2-7b3c-4862-a60c-8088f1e820ae', 'deviceAssetId': 'PXL_20240707_084051104.jpg', 'ownerId': '58a7d074-c1d4-4893-bd50-ab0648527566', 'deviceId': 'Library Import', 'libraryId': '1625a8c0-b36c-4753-a2cc-253357fb6b9d', 'type': 'IMAGE', 'originalPath': '/mnt/data/external/2024/2024.07.03-04 - Tirana/PXL_20240707_084051104.jpg', 'originalFileName': 'PXL_20240707_084051104.jpg', 'originalMimeType': 'image/jpeg', 'thumbhash': 'JMYFNQiZZqWYqGc3hp4I13dwegen', 'fileCreatedAt': '2024-07-07T08:40:51.104Z', 'fileModifiedAt': '2024-08-31T00:54:28.702Z', 'localDateTime': '2024-07-07T10:40:51.104Z', 'updatedAt': '2024-08-31T03:46:01.175Z', 'isFavorite': False, 'isArchived': False, 'isTrashed': False, 'duration': '0:00:00.00000', 'livePhotoVideoId': None, 'people': [], 'checksum': 'SrxPVDHHup7Rik8bBgQZRD2+Bh4=', 'isOffline': False, 'hasMetadata': True, 'duplicateId': None, 'resized': True}

I also ran a quick test and it seems none of the assets have this property:

immich = Immich(api_url, api_key)
assets = immich.fetchAssets()
print(any(a for a in assets if 'stackCount' in a))

>>> False

@tenekev
Copy link
Owner

tenekev commented Aug 31, 2024

I think it's another case of poorly documented changes to the stacks functionality. I updated to the latest v1.113.0. The API response differs from the one in the official API docs for the latest version.

But the weird part is that I still have a stack property in my response, even if it's null, while you are missing it altogether.

I'll push a potential fix for it but first I want to see what they say in the docs. The stacks changes are quite big.

@kvalev
Copy link
Author

kvalev commented Aug 31, 2024

Alright, no pressure. Thanks for looking into this issue!

@tenekev
Copy link
Owner

tenekev commented Aug 31, 2024

Keep an eye on the API responses. Maybe your library uses an old schema? Maybe after an update or two, or even a rescan, the schema will match the current version? Dunno, just thinking in writing.

Ще го оправим 😄

@PythonNut
Copy link

I also ran a quick test and it seems none of the assets have this property:

immich = Immich(api_url, api_key)
assets = immich.fetchAssets()
print(any(a for a in assets if 'stackCount' in a))

>>> False

Just as another data point, I am also seeing this on my instance.

@tenekev
Copy link
Owner

tenekev commented Sep 4, 2024

Yup. Also, they have updated the API with the proper schema and docs. There is a whole new Stacks endpoint. I'll go through the changes as soon as I can and implement them.

@tenekev tenekev mentioned this issue Sep 6, 2024
Majorfi added a commit to Majorfi/immich-auto-stack that referenced this issue Sep 11, 2024
Linked to tenekev#10 and tenekev#11

I ran into the same issue and gave it a shot. I am no python expert, so tried to make it work with the new `stack` endpoint as I could and tested it on my library (10k photos) with success.

Happy to answer any questions!
Thank yoy
@dwnsdp
Copy link

dwnsdp commented Nov 1, 2024

Still getting this error.
Logs:
/script/immich_auto_stack.py
2024-11-01 14:05:40,814 - INFO - ============== INITIALIZING ==============
2024-11-01 14:05:40,815 - INFO - ⬇️ Fetching assets:
2024-11-01 14:05:40,815 - INFO - Page size: 1000
2024-11-01 14:05:51,977 - INFO - Pages: None
2024-11-01 14:05:51,977 - INFO - Assets: 13197
Traceback (most recent call last):
File "/script/immich_auto_stack.py", line 251, in
main()
File "/script/immich_auto_stack.py", line 225, in main
children_id = [x['id'] for x in stack[1:] if x['stackCount'] == None ]
~^^^^^^^^^^^^^^

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

No branches or pull requests

5 participants
@kvalev @PythonNut @tenekev @dwnsdp and others