Bug 1029022 - RFE: API for reverse group operations
RFE: API for reverse group operations
Status: CLOSED ERRATA
Product: Fedora
Classification: Fedora
Component: dnf (Show other bugs)
rawhide
Unspecified Unspecified
unspecified Severity unspecified
: ---
: ---
Assigned To: Ales Kozumplik
Fedora Extras Quality Assurance
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-11 08:48 EST by Tim Lauridsen
Modified: 2014-09-30 19:41 EDT (History)
5 users (show)

See Also:
Fixed In Version: dnf-plugins-core-0.0.8-2.fc20
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2014-05-31 19:58:06 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Tim Lauridsen 2013-11-11 08:48:11 EST
Description of problem:
I have made a document on a possible API for DNF

https://docs.google.com/document/d/1yKeT5OLDw3H5ZXv9hNS68KA0oGqSOP0yTl92w_wt6-I/edit?usp=sharing

based on the current one
http://akozumpl.github.io/dnf/api.html

It is just a brainstorm to get something to start a discusion.
Comment 1 Ales Kozumplik 2013-11-11 09:01:41 EST
Thanks for this Tim, I'll try to keep looking at this as I progress with the API.
Comment 2 Ales Kozumplik 2013-11-11 09:09:10 EST
Comment on the properties autosetup: this unfortunately was one of the things we got many complains about from other teams, most notably Anaconda. Properties either have a reasonable default (like conf or repos), or they have to be activated manually in case doing so is an important step that e.g. prevents the user from repeating certain actions (loading the sack---new repos are not considered after).
Comment 3 Ales Kozumplik 2013-11-11 09:11:25 EST
On naming: all public method names use the underscore notation which is more prevalent in the Python world. CamelCases are used for classes. Everything else follows PEP008 and https://github.com/akozumpl/dnf/wiki/Hacking
Comment 4 Ales Kozumplik 2013-11-11 09:12:45 EST
On packages and dependencies lookups: these can be done via dnf.queries. I have yet to document them.
Comment 5 Ales Kozumplik 2013-11-11 09:14:42 EST
On transactions: they already do what the linked document describes, in a different form. 'pattern' parameter is not supported by design, one should use Subject or Query for lookups.
Comment 6 Ales Kozumplik 2013-11-11 09:18:49 EST
On group operations undos: we really need to work on that.

What do you propose is the exact semantics?
Comment 7 Tim Lauridsen 2013-11-11 12:51:38 EST
The group are a little tricky, yum has 2 kind of packages:

oldstyle group just a collection of packages, if all packages in the collection is installed, then the group is installed.

groups is installed by getting the mandatory+default package names from comps and add the not installed ones to the transaction.

groups is removed by adding all mandatory+default packages for remove to the transaction.

Besides reading from comps, no special metods is needed, yum provides some, i think they are used by anaconda for for make et easier if the user select and then deselect a group.

newstyle groups are more object like so they need metods for installing, removing, updating

install_group, remove_group, etc.

When I think about it, then the undo, unselect methods is kind of weird, we have no methods for undo package actions like update, so if the install_group returns the txmbrs, then the API should be able to handle undo/unselect actions IMHO.
Comment 8 Tim Lauridsen 2013-11-11 12:53:02 EST
I must be tired :)

It should have been

groups are a little tricky, yum has 2 kind of groups:
Comment 9 Tim Lauridsen 2013-11-11 13:06:25 EST
- No auto setup is fine with me, a little more work but make easier to understand what is going on.

- naming all public API using underscore naming and camelcase class is fine. All other private methods, should start with _ to mark that they are private. Maybe making a BaseCore parent class to Base, with all the private stuff, so it is easier to se what is public API and what is private api. 

- only supporting po on install, update etc is also fine, if there is other ways to find the patterns.

It would be nice with some doc on how to work with the sack would be great :)
Comment 10 Ales Kozumplik 2013-11-13 04:01:33 EST
(In reply to Tim Lauridsen from comment #9)
> - naming all public API using underscore naming and camelcase class is fine.
> All other private methods, should start with _ to mark that they are

It does not matter what is underscored and what is not. What the API documentation's Intro [1] says applies. That is: if it's not in the documentation then it does not comprise the API and we will remove it and change it any time.

> private. Maybe making a BaseCore parent class to Base, with all the private
> stuff, so it is easier to se what is public API and what is private api. 

Absolutely not, that's an OO antipattern.

> It would be nice with some doc on how to work with the sack would be great :)

Good point. Do you have something specific besides the package queries on your mind?

[1] http://akozumpl.github.io/dnf/api.html#introduction
Comment 11 Tim Lauridsen 2013-11-13 07:39:46 EST
> > It would be nice with some doc on how to work with the sack would be great :)
> 
> Good point. Do you have something specific besides the package queries on
> your mind?
> 

It is mostly package queries, I was thinking about.

A simple example of using the API whould be nice to

import dnf
base = dnf.Base()
<something is needed to setup conf and repos (maybe some api is needed to setup
the default enabled repos>
base.fill_sack()
<do something useful>

I have done some tests but, I haveing a hard time to get the repos loaded
Comment 12 Ales Kozumplik 2013-11-13 08:08:47 EST
(In reply to Tim Lauridsen from comment #11)
> It is mostly package queries, I was thinking about.

On my list already!

> <something is needed to setup conf and repos (maybe some api is needed to
> setup
> the default enabled repos>

I'm glad you're pointing this out, that's also on my list but the high-level functions to do this are in horrible state and will need some improvements before we can claim them as a part of the API.
Comment 13 Tim Lauridsen 2013-11-13 09:13:10 EST
I got a simple example up and running :

import dnf.yum
import dnf.const
from dnf import Base
base = Base()
# read the conf settings for dnf.conf
base.read_conf_file()
# setup cache suffix and prefix 
suffix = dnf.yum.parser.varReplace(dnf.const.CACHEDIR_SUFFIX, base.conf.yumvar)
base.cache_c.prefix =  base.conf.cachedir
base.cache_c.suffix =  suffix
# load the repo infomation from repo files
base.read_all_repos()
print " =============== loading sack====================="
# setup the sack
base.fill_sack()
# list installed packages
q = base.sack.query()
for po in q.installed():
    print po

Besides the suffix & prefix setup, it looks nice :)
Comment 14 Ales Kozumplik 2013-11-13 10:29:47 EST
the suffix&prefix is fixed in the new version. mind you, you use some non-API stuff there.
Comment 15 Tim Lauridsen 2013-11-14 06:03:45 EST
Yes, these are not API, but it dont work without them :)

base.read_conf_file()
base.read_all_repos()
Comment 16 Ales Kozumplik 2014-03-10 15:32:55 EDT
Tim, I am looking into providing the missing undo group methods now. I am wondering: what would be the use case? If it's for a UI to select/unselect some group (e.g. through a checkbox) then I think the app should be able to handle this in it's model code. If it's only this use case I would tend to avoid adding similar layer to DNF.
Comment 17 Tim Lauridsen 2014-03-11 02:20:27 EDT
I see no need for ui for select/unselect a group.
a agree that a package manager gui should handle that, not dnf.

something like

group_install(group)
group_remove(group)
group_update(group)

whould be useful.

and some public api to get group members (names or packages)
Comment 18 Ales Kozumplik 2014-04-17 05:22:33 EDT
I believe b4f23e4 which adds Base.group_upgrade() to the API is the last commit to fulfill this request, all mentioned methods are provided now.
Comment 19 Fedora Update System 2014-05-02 04:31:47 EDT
dnf-0.5.1-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/dnf-0.5.1-1.fc20
Comment 20 Fedora Update System 2014-05-02 17:04:20 EDT
Package dnf-0.5.1-1.fc20, hawkey-0.4.14-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-0.5.1-1.fc20 hawkey-0.4.14-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-5937/hawkey-0.4.14-1.fc20,dnf-0.5.1-1.fc20
then log in and leave karma (feedback).
Comment 21 Fedora Update System 2014-05-28 08:09:38 EDT
dnf-plugins-core-0.0.8-2.fc20, libsolv-0.6.1-1.git6d968f1.fc20, hawkey-0.4.16-1.fc20, dnf-0.5.2-1.fc20 has been submitted as an update for Fedora 20.
https://admin.fedoraproject.org/updates/libsolv-0.6.1-1.git6d968f1.fc20,hawkey-0.4.16-1.fc20,dnf-0.5.2-1.fc20,dnf-plugins-core-0.0.8-2.fc20
Comment 22 Fedora Update System 2014-05-28 19:49:35 EDT
Package dnf-plugins-core-0.0.8-2.fc20, libsolv-0.6.1-1.git6d968f1.fc20, hawkey-0.4.16-1.fc20, dnf-0.5.2-1.fc20:
* should fix your issue,
* was pushed to the Fedora 20 testing repository,
* should be available at your local mirror within two days.
Update it with:
# su -c 'yum update --enablerepo=updates-testing dnf-plugins-core-0.0.8-2.fc20 libsolv-0.6.1-1.git6d968f1.fc20 hawkey-0.4.16-1.fc20 dnf-0.5.2-1.fc20'
as soon as you are able to.
Please go to the following url:
https://admin.fedoraproject.org/updates/FEDORA-2014-6789/libsolv-0.6.1-1.git6d968f1.fc20,hawkey-0.4.16-1.fc20,dnf-0.5.2-1.fc20,dnf-plugins-core-0.0.8-2.fc20
then log in and leave karma (feedback).
Comment 23 Fedora Update System 2014-05-31 19:58:06 EDT
dnf-plugins-core-0.0.8-2.fc20, libsolv-0.6.1-1.git6d968f1.fc20, hawkey-0.4.16-1.fc20, dnf-0.5.2-1.fc20 has been pushed to the Fedora 20 stable repository.  If problems still persist, please make note of it in this bug report.

Note You need to log in before you can comment on or make changes to this bug.