Bug 1542482 - [RFE] Add to the API methods that are marked as private
Summary: [RFE] Add to the API methods that are marked as private
Keywords:
Status: CLOSED DUPLICATE of bug 2047251
Alias: None
Product: Fedora
Classification: Fedora
Component: dnf
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: rpm-software-management
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks: 1455456 1542492
TreeView+ depends on / blocked
 
Reported: 2018-02-06 12:29 UTC by Yuval Turgeman
Modified: 2022-08-29 05:26 UTC (History)
5 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2022-01-27 13:17:53 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description Yuval Turgeman 2018-02-06 12:29:48 UTC
The following methods were public in the old api (version 1) are now marked as private (underscore prefix) in the current version, and are used by oVirt's otopi installer

base._group_persistor
base._plugins._unload()
base._history_undo_operations()
base.comps._group_by_id()
repo.md_expire_cache()

Comment 1 Jaroslav Mracek 2019-06-28 09:44:04 UTC
Minimal repo.md_expire_cache() and base._group_persistor completely disappeared from dnf-4

Comment 2 Jaroslav Mracek 2019-06-28 09:56:04 UTC
In Python there is very difficult to prevent calling anything. We decided to mark API functions with # API mark. Also we provide a documentation that explicitly list API function (https://dnf.readthedocs.io/en/latest/api.html), but even this approach was not sufficient enough, than we renamed non-API function using _ prefix. But this approach is against PEP8 and to rename everything inside dnf with the prefix decrease readability of the code.

Please could you explain the use cases behind the usage?

Please could you reference the code where they used it?

Comment 3 Yedidyah Bar David 2019-07-17 10:21:00 UTC
(In reply to Jaroslav Mracek from comment #2)
> Please could you explain the use cases behind the usage?
> 
> Please could you reference the code where they used it?

Yes, see below:

(In reply to Yuval Turgeman from comment #0)
> The following methods were public in the old api (version 1) are now marked
> as private (underscore prefix) in the current version, and are used by
> oVirt's otopi installer
> 
> base._group_persistor

Wanted to check if a package is installed. Recently fixed by checking history, so can be marked "fixed":

https://gerrit.ovirt.org/100994

> base._plugins._unload()

Just as part of cleaning up. I do not see anywhere a concrete reason. I guess Alon simply followed then-best-practices following the docs or whatever:

https://gerrit.ovirt.org/44374

> base._history_undo_operations()

Same. Was already included in above original patch.

> base.comps._group_by_id()

Again, just to query a group. Already included in original patch above.

> repo.md_expire_cache()

In order to expire the cache. We do this before every transaction (optionally, True by default).

Other than the first one (is this a correct fix, from your POV?), we worked around all of the others by adding '_', see bug 1542529:

https://gerrit.ovirt.org/87113

Yuval pushed it as a workaround and then opened current bug to discuss long-term solutions. So:

If you are simply against us (or other wrappers/api-users) doing all of above, fine - say so clearly, and we'll have to decide if they are mandatory or can be dropped (e.g. perhaps cache expiry can be dropped, but I am certain some people strongly object). If you can provide better solutions, fine. Otherwise, either rename back the functions to be officially part of the api (and then we'll have to revert above last patch) or simply do nothing (and then we'll keep using these private methods against your intention). Thanks.

Comment 4 Yedidyah Bar David 2022-01-27 13:17:53 UTC
(In reply to Yedidyah Bar David from comment #3)
> (In reply to Jaroslav Mracek from comment #2)
> > Please could you explain the use cases behind the usage?
[snip]
> 
> > base._plugins._unload()

Now filed bug 2047251 for this one, and IIRC all the other cases discussed
in this bug were already handled elsewhere. So closing it.

*** This bug has been marked as a duplicate of bug 2047251 ***


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