Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix misalignment in signatures for methods with @support_batches #13

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions easy_entrez/batch.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ def supports_batches(func):
"""

@wraps(func)
def batches_support_wrapper(self: 'EntrezAPI', collection: Sequence, *args, **kwargs):
def batches_support_wrapper(self: 'EntrezAPI', ids: Sequence, *args, **kwargs):
size = self._batch_size
interval = self._batch_sleep_interval
if size is not None:
assert isinstance(size, int)
by_batch = {}

for i, batch in enumerate(tqdm(batches(collection, size=size))):
for i, batch in enumerate(tqdm(batches(ids, size=size))):
done = False

while not done:
Expand All @@ -62,7 +62,7 @@ def batches_support_wrapper(self: 'EntrezAPI', collection: Sequence, *args, **kw
sleep(interval)
return by_batch
else:
return func(self, collection, *args, **kwargs)
return func(self, ids, *args, **kwargs)

if not batches_support_wrapper.__doc__:
batches_support_wrapper.__doc__ = ''
Expand Down
15 changes: 13 additions & 2 deletions tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
'easy-entrez-test',
'[email protected]',
return_type='json',
# 2 seconds interval as these tests are less urgent than any actual research
minimal_interval=2
# 3 seconds interval as these tests are less urgent than any actual research
minimal_interval=3
)


Expand Down Expand Up @@ -41,3 +41,14 @@ def test_fetch():

with raises(ValueError, match='Received str but a list-like container of identifiers was expected'):
entrez_api.fetch('4', max_results=1, database='snp')


def test_link():
# https://github.com/krassowski/easy-entrez/issues/2
result = entrez_api.link(
database=None,
ids=[15718680, 157427902],
database_from='protein',
command='acheck'
)
assert result.data