Skip to content

Conversation

MichaelC1999
Copy link
Contributor

-poll_callback_on_data method for executing a callback on receiving each row of poll data
-poll_return_first_dict method for returning and stopping the polling function upon the first block after start_block with applicable data. Ideal for recursively calling from front end
-Basic error handling

In this Pull Request, there are two new methods in addition to the poll method: poll_callback_on_data and poll_return_first_dict. Both of these methods have similar functionality to the original "poll" method in that they run the substream in an attempt to receive their data, but the difference is in the behavior upon data received. While the original poll method gets the data from all blocks between the start_block and end_block and then returns a pandas data frame, these new methods execute logic each time a block has an applicable tx/event. poll_return_first_dict returns a dict of the data on the first applicable block after start block. The idea is that this function will be recursively called from the front end so that streamlit/whatever library can update its state and then restart the streaming on the successive block. One useful feature of this method is that you can define the end_block past chain head and it will return data in real time as each block finalizes. The other method poll_callback_on_data receives a callback as an argument from the front end and executes it after receiving a row of data.

Copy link
Contributor

@rysuds rysuds left a comment

Choose a reason for hiding this comment

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

Because all three poll functions share a lot of core logic, rather than having poll_call_back_on_data and poll_return_first_dict, I think we can have boolean input params on poll() like return_first_dict AND call_back_on_data to determine poll()'s functionality.

Also many of these print() statements seem to be mainly for debugging purposes, so unless we need them propagated to the user, lets remove them

Copy link
Contributor Author

@MichaelC1999 MichaelC1999 left a comment

Choose a reason for hiding this comment

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

-Combined poll functions, conditional depending on provided parameters
-Removed unnecessary logging

@MichaelC1999 MichaelC1999 requested a review from rysuds January 4, 2023 01:00
Copy link
Contributor

@rysuds rysuds left a comment

Choose a reason for hiding this comment

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

Looks sensible to me! I think there are bits of repeated logic that could be trimmed down, but for the sake of saving time in the short term will approve. Just test all three poll use cases manually before merging and its G2G!

@MichaelC1999 MichaelC1999 merged commit 8b87893 into messari:master Jan 5, 2023
@MichaelC1999 MichaelC1999 deleted the Additional-Functions branch January 5, 2023 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants