unable to find certain project_groups via API

Bug #1028819 reported by Martin Mrazik
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Launchpad itself
Triaged
Low
Unassigned

Bug Description

On launchpad I can see the following project groups:
online-accounts
webapps

When running a script like this:
---------------------------snip----------------------
#!/usr/bin/env python

from launchpadlib.launchpad import Launchpad
launchpad = Launchpad.login_with('mrazik','production')

online_accounts = launchpad.projects('online-accounts')
webapps = launchpad.projects('webapps')
print online_accounts in launchpad.project_groups
print webapps in launchpad.project_groups
---------------------------snip----------------------

I would expect the following result:
---------------------------snip----------------------
True
True
---------------------------snip----------------------

But the actual result is:
---------------------------snip----------------------
True
False
---------------------------snip----------------------

Revision history for this message
Laura Czajkowski (czajkowski) wrote :

Martin can you explain some more what you are trying to do and why ?

Changed in launchpad:
status: New → Incomplete
Revision history for this message
Martin Mrazik (mrazik) wrote :

Ideally I want to get a list of projects where pspmteam (product strategy management team) is the owner so I can track them (for bug counts, test-coverage, etc). Unfortunately this doesn't seem to be possible neither via web gui nor via the API. The only way is to iterate through projects/super projects and find the ones with "correct" owner.

Ideally I would like to have something like getOwnedOrDrivenPillars (lib/lp/registry/model/person.py) available through the API.

Martin Mrazik (mrazik)
Changed in launchpad:
status: Incomplete → New
Curtis Hovey (sinzui)
Changed in launchpad:
status: New → Triaged
importance: Undecided → Low
tags: added: api projectgroups
Revision history for this message
Curtis Hovey (sinzui) wrote :

lazr.restful is doing something very odd with ProjectGroupSet.__iter__

https://launchpad.net/projectgroups/+all states there are 465 active and inactive project groups. It lists 345 active groups. The list matches the contents of the db table.

But over the API this fragment contains a different list of project groups. There are still 345 active items in the list, but many project groups are replaced by a duplicate of a group already in the list.
    project_groups = [pg for pg in launchpad.project_groups]

I see 47 duplicates I printed this listing.

launchpad.project_groups['webapps'] works fine and it is the proper way to look up a project group.

Revision history for this message
William Grant (wgrant) wrote :

ProjectGroupSet.search probably doesn't have a defined order, so you'll get back duplicates etc.

But nobody should be using this API -- it's not really sensible to iterate over all the projects and project groups.

Revision history for this message
Curtis Hovey (sinzui) wrote :

William, you are correct, It does not have an order.

Revision history for this message
Robert Collins (lifeless) wrote : Re: [Bug 1028819] [NEW] unable to find certain project_groups via API

Martin, you could contribute a small patch to export the thing you
want over the API. there is no need to use the inefficient approach!

Revision history for this message
Martin Mrazik (mrazik) wrote :

Ok. Let me try to contribute ;) I just had an impression this is not exposed via API as potentially expensive operation (even in the GUI you can not see all the related projects but only 75).

Revision history for this message
Curtis Hovey (sinzui) wrote :

IPerson.getOwnedOrDrivenPillars() will return the active distros, projects, and project groups that the user or team maintains or drives. Export the method. Your own script may want to filter out the driven projects.

The limit is only in the UI and it is bogus. Few people and teams exceed the limit, and the UI could batch.

Curtis Hovey (sinzui)
tags: added: disclosure sharing
Changed in launchpad:
assignee: nobody → Curtis Hovey (sinzui)
status: Triaged → In Progress
assignee: Curtis Hovey (sinzui) → nobody
status: In Progress → Triaged
tags: removed: disclosure sharing
Revision history for this message
Curtis Hovey (sinzui) wrote :

Exporting this method, which I am renaming to getAffiliatedPillars() is not easy. The method returns IPillarName which is not exported. I don't think we want to export it either because it is an intermediate object that no one wants. Even Lp's internal code always calls PillarName.pillar to get the real object. I think we want to change the method to return IPillars, or maybe I mean a heterogeneous collection of distributions, project groups, and projects. We might want to change the implementation from one db call to get the collection then 1+ calls to materialise the actual object to 3 db calls to get all the objects.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.