3
11

Extensions: use a new structure for the server's JSON listing #29

Closed
Campbell Barton wants to merge 4 commits from test-refactor-server-json into main

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.

Top level keys are now:

  • version

  • blocklist

  • data (a list of packages)

    Each list item now contains the package "id".

Top level keys are now: - version - blocklist - data (a list of packages) Each list item now contains the package "id".
Campbell Barton added 1 commit 2024-04-09 14:24:08 +02:00
Top level keys are now:
- version
- blocklist
- data (a list of packages)

  Each list item now contains the package "id".
Campbell Barton force-pushed test-refactor-server-json from 56e1be217f to 295d684561 2024-04-09 14:26:48 +02:00 Compare
Oleg-Komarov reviewed 2024-04-09 14:36:01 +02:00
@ -1128,1 +1139,3 @@
def repo_pkginfo_from_local_with_idname_as_key(*, local_dir: str) -> Optional[PkgManifest_RepoDict]:
def pkg_repo_dat_from_json(json_data: Dict[str, Any]) -> PkgRepoData:
result_new = PkgRepoData(
version=json_data.get("version", "1"),
First-time contributor

a minor concern, but let's finalize this before publishing the doc

in

'version': 'v1',
(the branch for the server changes) I started using "v1" for the version string

I don't mind changing this to "1", but having a prefix makes it impossible to mistake the string for a number, and it also subjectively looks nicer in the explicitly versioned urls, such as https://extensions.blender.org/api/v1/extensions/

what do you think?

a minor concern, but let's finalize this before publishing the doc in https://projects.blender.org/infrastructure/extensions-website/src/commit/11e2dea9f6ad6f8d470f0d4d1aa335cca3900c89/extensions/views/api.py#L105 (the branch for the server changes) I started using `"v1"` for the version string I don't mind changing this to `"1"`, but having a prefix makes it impossible to mistake the string for a number, and it also subjectively looks nicer in the explicitly versioned urls, such as https://extensions.blender.org/api/v1/extensions/ what do you think?

That seems fine, I don't have such a strong opinion on this.

That seems fine, I don't have such a strong opinion on this.
ideasman42 marked this conversation as resolved
Campbell Barton force-pushed test-refactor-server-json from 295d684561 to eb37be857c 2024-04-09 14:36:40 +02:00 Compare
Campbell Barton added 1 commit 2024-04-09 14:51:23 +02:00
Makes it impossible to mistake for a number and reads better in URL's
~ Oleg-Komarov

I'm running into this error:

KeyError: 'id'
Traceback (most recent call last):
  File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/modules/bpy_types.py", line 1026, in draw_ls
    func(self, context)
  File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/addons_contrib/bl_pkg/bl_extension_ui.py", line 691, in extensions_panel_draw
    extensions_panel_draw_impl(
  File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/addons_contrib/bl_pkg/bl_extension_ui.py", line 309, in extensions_panel_draw_impl
    for repo_index, (
  File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/addons_contrib/bl_pkg/bl_extension_utils.py", line 1028, in pkg_manifest_from_remote_ensure
    pkg_manifest_remote[item_remote.pop("id")] = item_remote
                        ^^^^^^^^^^^^^^^^^^^^^

My JSON file is:

{"blocklist":[],"data":[{"id":"blender_kitsu","schema_version":"1.0.0","name":"Kitsu","version":"0.1.5","tagline":"Blender addon to interact with Kitsu","archive_hash":"sha256:3559c8bf0fa9881535d820fb02b83745b68400976abe17c1bc69f68f07b4006d","archive_size":853847,"archive_url":"http://extensions.local:8111/add-ons/kitsu/0.1.5/download/","type":"add-on","blender_version_min":"4.2.0","website":"http://extensions.local:8111/add-ons/kitsu/","maintainer":"admin","license":["SPDX:GPL-2.0-or-later"],"tags":["Pipeline"]}],"version":"v1"}
I'm running into this error: ``` KeyError: 'id' Traceback (most recent call last): File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/modules/bpy_types.py", line 1026, in draw_ls func(self, context) File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/addons_contrib/bl_pkg/bl_extension_ui.py", line 691, in extensions_panel_draw extensions_panel_draw_impl( File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/addons_contrib/bl_pkg/bl_extension_ui.py", line 309, in extensions_panel_draw_impl for repo_index, ( File "/home/dfelinto/src/blender/build_linux_lite/bin/4.2/scripts/addons_contrib/bl_pkg/bl_extension_utils.py", line 1028, in pkg_manifest_from_remote_ensure pkg_manifest_remote[item_remote.pop("id")] = item_remote ^^^^^^^^^^^^^^^^^^^^^ ``` My JSON file is: ``` {"blocklist":[],"data":[{"id":"blender_kitsu","schema_version":"1.0.0","name":"Kitsu","version":"0.1.5","tagline":"Blender addon to interact with Kitsu","archive_hash":"sha256:3559c8bf0fa9881535d820fb02b83745b68400976abe17c1bc69f68f07b4006d","archive_size":853847,"archive_url":"http://extensions.local:8111/add-ons/kitsu/0.1.5/download/","type":"add-on","blender_version_min":"4.2.0","website":"http://extensions.local:8111/add-ons/kitsu/","maintainer":"admin","license":["SPDX:GPL-2.0-or-later"],"tags":["Pipeline"]}],"version":"v1"} ```
Dalai Felinto pinned this 2024-04-09 16:35:50 +02:00
Dalai Felinto reviewed 2024-04-09 17:03:33 +02:00
@ -1025,0 +1025,4 @@
yield None
else:
for item_remote in json_items:
pkg_manifest_remote[item_remote.pop("id")] = item_remote

For this to work I had to create a copy:

-                    for item_remote in json_items:
+                    for item_remote_iter in json_item:
+                        # Create copy otherwise we will be editing original data.
+                        item_remote = item_remote_iter.copy()

I didn't investigate on why it happens, but it does happen.

For this to work I had to create a copy: ```diff - for item_remote in json_items: + for item_remote_iter in json_item: + # Create copy otherwise we will be editing original data. + item_remote = item_remote_iter.copy() ``` I didn't investigate on why it happens, but it does happen.

Pushed similar fix with comment, strange I didn't run into this when testing.

Pushed similar fix with comment, strange I didn't run into this when testing.
ideasman42 marked this conversation as resolved
Campbell Barton added 1 commit 2024-04-10 07:14:13 +02:00
Campbell Barton added 1 commit 2024-04-11 12:46:08 +02:00
Dalai Felinto approved these changes 2024-04-11 12:58:45 +02:00
Author
Owner

Committed ebcda465b5

Committed ebcda465b5115ddcb18b16ac3ccd712ca7b984e2
Campbell Barton closed this pull request 2024-04-11 13:24:55 +02:00
This repo is archived. You cannot comment on pull requests.
No reviewers
No Label
No Milestone
No Assignees
3 Participants
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons-contrib#29
No description provided.