Skip to content

✨ Create iterator for paginated server methods #62

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

Conversation

bisgaard-itis
Copy link
Collaborator

What do these changes do?

Introduce a python wrapper for the osparc.SolversApi.get_jobs_page method which allows the user to get a single iterator to all items in a list, even if the http method is paginated. I have introduces a general function which can be used for the other paginated http methods as soon as they have been implemented on the server side.

Related issue/s

How to test

@bisgaard-itis bisgaard-itis added the enhancement New feature or request label Aug 3, 2023
@bisgaard-itis bisgaard-itis added this to the Sundae milestone Aug 3, 2023
@bisgaard-itis bisgaard-itis self-assigned this Aug 3, 2023
@bisgaard-itis bisgaard-itis requested a review from pcrespov as a code owner August 3, 2023 13:27
@bisgaard-itis bisgaard-itis requested a review from sanderegg August 3, 2023 13:27
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice!
So I can call now with this something like

for job in get_jobs():
  ...

??

Then a few questions

@bisgaard-itis
Copy link
Collaborator Author

bisgaard-itis commented Aug 4, 2023

very nice! So I can call now with this something like

for job in get_jobs():
  ...

??

Then a few questions

Yes, I just made a few changes so that this is possible. Now if you do job_iter = api_client.get_jobs(<solver_key>, <solver_version>) you can do

  • len(job_iter) which will return the number of elements the generator/iterator can produce
  • for job in job_iter:

@bisgaard-itis bisgaard-itis requested a review from sanderegg August 4, 2023 08:37
Copy link
Member

@sanderegg sanderegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very nice! thanks for the change. in the end the linter did something ;)

@bisgaard-itis bisgaard-itis merged commit 37a765b into ITISFoundation:master Aug 4, 2023
@bisgaard-itis bisgaard-itis deleted the iterate-paginate-solver-jobs-page branch August 4, 2023 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants