ndexbio / ndex2-client

NDEx2 Client
BSD 3-Clause "New" or "Revised" License
6 stars 6 forks source link

get_network_ids_for_user not returning expected network_ids #78

Closed ariutta closed 3 years ago

ariutta commented 3 years ago

The method get_network_ids_for_user appears to be limited to 1000 network_ids.

Test Case for v3.3.1:

Query the test server http://test.ndexbio.org to see how many networks I own:

user_network_ids = my_ndex.get_network_ids_for_user("ariutta")
print(len(user_network_ids))

I'm getting back 1000, but the number should be much larger (over 30k).

coleslaw481 commented 3 years ago

Oh that is bad. thank you for catching this.

Under the hood get_network_ids_for_user() is simply calling get_user_network_summaries() which by default limits results returned to 1000 networks. I'll fix this, but in the meantime you can call get_user_network_summaries() and set the limit to a giant number like 1000000

Upon success, the result you get back from get_user_network_summaries() is a list of dict objects where each dict is a network. To get the network id simply get the value from the key externalId.

Here is example code that puts all the network ids into the list my_uuids:

res = my_ndex.get_user_network_summaries('ariutta', limit=1000000)

my_uuids = []
for entry in res:
   my_uuids.append(entry['externalId'])

NOTE: get_user_network_summaries() shows not only networks owned by user, but also any networks directly shared with the user.

coleslaw481 commented 3 years ago

Fixed in branch3.4.0 by updating documentation and adding offset and limit parameters to let caller choose to get more then 1,000 results or to get results via paginations.

coleslaw481 commented 3 years ago

Version with offsets and limit parameter Currently available to try as an alpha version by running pip install ndex2==3.4.0a1 For usage see: https://ndex2.readthedocs.io/en/latest/ndex2client.html#ndex2.client.Ndex2.get_network_ids_for_user

coleslaw481 commented 3 years ago

ndex2 version 3.4.0 formally released. Can be installed via pip install ndex2