mgnipy.V2.mgnifier.query_executor module

mgnipy.V2.mgnifier.query_executor module#

class QueryExecutor(query_set, client=None)[source]#

Bases: object

Responsible for executing the queries defined in a QuerySet, handling pagination, concurrency limits, and result caching.

This class provides both synchronous and asynchronous methods to retrieve metadata pages from the MGnify API, with built-in support for concurrency control to protect the server. It also tracks successful page retrievals and allows for resuming or continuing iterations based on previously retrieved pages.

The QueryExecutor is designed to work closely with a QuerySet, using its query definitions and caching mechanisms to efficiently retrieve and store results. It includes helper methods for initializing API clients, parsing responses, and managing iteration state.

Parameters:
async arequest_page(page_num)[source]#

Async fetch for a single page.

Parameters:

page_num (int )

Return type:

dict [int , list [dict ]] | None

request_page(page_num)[source]#

Retrieve a specific page of metadata for the current resource and parameters. This method allows the user to retrieve metadata one page at a time, which can be useful for previewing data or for manual pagination control.

Parameters:

page_num (int ) – The page number to retrieve (1-based index).

Returns:

A dictionary containing the metadata from the specified page of results, or None if the page is not found.

Return type:

Optional[dict [int , list [dict ]]]