[hotfix] Extension example for clean could not import Conan API search#193
Conversation
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
|
Yes, it is true that the I understand that this PR will later update the example to use the |
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
|
@memsharded as far as I see, it comes from conan-io/conan#18726 I could import the search package as in the commit 3005ea6 only to unblock other PRs, then, thinking to update it to conan list in a next PR |
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
| recipes = conan_api.search.recipes("*/*", remote=remote) | ||
| if recipes and not confirmation("Do you want to remove all the recipes revisions and their packages ones, " | ||
| # Get all recipes and packages, where recipe revision is not the latest | ||
| pkg_list = conan_api.list.select(ListPattern("*/*#!latest:*#*", rrev=None, prev=None), remote=remote) |
There was a problem hiding this comment.
I think the whole command implementation sounds a bit too complicated.
For example, it is not necessary to select all binaries and all revisions here with :*#* as later only the recipe will be removed (and it will remove all the associated binaries automatically)
Then, it sounds very inefficient to list twice with the */* pattern. It sounds better to do a recipe revision list only pkg_list = conan_api.list.select(ListPattern("*/*", rrev=None, prev=None), then remove all but the latest revision, and for that latest revision list the specific package revisions to remove (!latest)
There was a problem hiding this comment.
Indeed, I have a learn curve just to write this small piece, needing to understand the API class implementation around this example. Let me update according to your suggestion.
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
memsharded
left a comment
There was a problem hiding this comment.
I still don't love that the ListPattern is running twice again for returning the whole Conan cache pkg+versions, but good enough for me for a custom command example
We don't have helpers anymore to filter the latest rrev and later, to filter prev. It looks a bit complex now, but without these methods, my feeling is the code will be harder to understand based on accessing the list index and filtering manually. |
| # Get all package revisions from the latest recipe revision, except the latest package revision | ||
| pkg_list = conan_api.list.select(ListPattern("*/*:*#!latest", rrev=None, prev=None), remote=remote) | ||
| for recipe_ref, recipe_bundle in pkg_list.refs().items(): | ||
| pkg_list = PackagesList.prefs(recipe_ref, recipe_bundle) |
There was a problem hiding this comment.
In Conan we usually would call this static method from the pkg_list object itself, but do note that this is still an undocumented method, maybe we need to take a look into it - I think getting the refs and prefs of a pkglist is a valid operation that users might want access to.
We also need to check if the remove api can be improved
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
@memsharded Please, check the commit 729e9f7. I'm using a single I used |
|
conan-io/conan#18833 has been merged, examples should use the new PackagesLists API |
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
memsharded
left a comment
There was a problem hiding this comment.
Looks good, just avoid the "bundle" terminology for package lists (it is still used internally, but it was removed from all public code)
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
|
@memsharded Thanks for reviewing! Your suggestions are addressed in the commits ae4d974 and e1ed8d7 |
|
The CI will NOT pass until we have Conan 2.21 available as latest release. As the CI validates with Conan develop 2 and latest, the API is now only compatible with develop2 (future 2.21) |
|
@uilianries maybe we can add a condition to the test so it only runs on conan >= 2.21.0-dev? |
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
|
There was a small bug that was pronounced in this new test. |
Signed-off-by: Uilian Ries <uilianr@jfrog.com>
|
@czoido Good to go now. It's skipping Conan <2.21.0-dev. |
|
We also have to update the code in the docs: https://docs.conan.io/2/examples/extensions/commands/clean/custom_command_clean_revisions.html targeting to develop2 as these chages will be released in 2.21.0 |
When pushing the PR #192 , the following error occurred in the CI:
It seems be affected by conan-io/conan#18726