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 preloaded pool size #19

Merged
merged 5 commits into from
Dec 19, 2024
Merged

Conversation

bokobza
Copy link
Contributor

@bokobza bokobza commented Dec 12, 2024

No description provided.

@frol
Copy link
Collaborator

frol commented Dec 12, 2024

@bokobza Yeah, thanks for clarifying it in the original PR. This is the least intrusive change, but to make it completely nice, I suggest to introduce the blocks_preload_pool_size as additional parameter:

def __init__(…, preload_pool_size=None, blocks_preload_pool_size=200):
    self.blocks_preload_pool_size = blocks_preload_pool_size
    # Legacy compatibility to avoid breaking changes
    if preload_pool_size is not None:
        self.blocks_preload_pool_size = preload_pool_size

What do you think?

@race-of-sloths invite

@race-of-sloths
Copy link

@frol Thank you for calling!

@bokobza Thank you for the contribution! Join Race of Sloths by simply mentioning me in your comment/PRs description and start collecting Sloth Points through contributions to open source projects.

What is the Race of Sloths

Race of Sloths is a friendly competition where you can participate in challenges and compete with other open-source contributors within your normal workflow

For contributors:

  • Tag @race-of-sloths inside your pull requests
  • Wait for the maintainer to review and score your pull request
  • Check out your position in the Leaderboard
  • Keep weekly and monthly streaks to reach higher positions
  • Boast your contributions with a dynamic picture of your Profile

For maintainers:

  • Score pull requests that participate in the Race of Sloths and receive a reward
  • Engage contributors with fair scoring and fast responses so they keep their streaks
  • Promote the Race to the point where the Race starts promoting you
  • Grow the community of your contributors

Feel free to check our website for additional details!

Bot commands
  • For contributors
    • Include a PR: @race-of-sloths include to enter the Race with your PR
  • For maintainers:
    • Invite contributor @race-of-sloths invite to invite the contributor to participate in a race or include it, if it's already a runner.
    • Assign points: @race-of-sloths score [1/2/3/5/8/13] to award points based on your assessment.
    • Reject this PR: @race-of-sloths exclude to send this PR back to the drawing board.
    • Exclude repo: @race-of-sloths pause to stop bot activity in this repo until @race-of-sloths unpause command is called

@bokobza
Copy link
Contributor Author

bokobza commented Dec 12, 2024

I think it's better to do without the

# Legacy compatibility to avoid breaking changes
    if preload_pool_size is not None:
        self.blocks_preload_pool_size = preload_pool_size

Let me lay all the options out.

With my changes:

If a user was calling it like this:

 LakeConfig(
            network=self.network,
            start_block_height=starting_block_height,
            aws_access_key_id=aws_access_key_id,
            aws_secret_key=aws_secret_key
        )

the blocks pool size will be 200 as before, and if the user was calling it like this:

 LakeConfig(
            network=self.network,
            start_block_height=starting_block_height,
            aws_access_key_id=aws_access_key_id,
            aws_secret_key=aws_secret_key,
            preload_pool_size=75
        )

the blocks pool size will become 75. IT's fixed, but if the user was relying on this working as it should and they're happy with the 200 blocks they're getting, then I agree this may introduce an unwelcomed change.

With your change:

If a user was calling it like this:

 LakeConfig(
            network=self.network,
            start_block_height=starting_block_height,
            aws_access_key_id=aws_access_key_id,
            aws_secret_key=aws_secret_key
        )

the blocks pool size will be 200 as before, and if the user was calling it like this:

 LakeConfig(
            network=self.network,
            start_block_height=starting_block_height,
            aws_access_key_id=aws_access_key_id,
            aws_secret_key=aws_secret_key,
            preload_pool_size=75
        )

the blocks pool size will become 75, which is exactly the same as my change.

So in a nutshell, it's exactly the same, the only difference is that with your changes, we end up with 2 similar parameters.

better solution

def __init__(…, preload_pool_size=None, blocks_preload_pool_size=200):
    self.blocks_preload_pool_size = blocks_preload_pool_size
   ...  

with this changes:
If a user was calling it like this:

 LakeConfig(
            network=self.network,
            start_block_height=starting_block_height,
            aws_access_key_id=aws_access_key_id,
            aws_secret_key=aws_secret_key
        )

the blocks pool size will be 200 as before, and if the user was calling it like this:

 LakeConfig(
            network=self.network,
            start_block_height=starting_block_height,
            aws_access_key_id=aws_access_key_id,
            aws_secret_key=aws_secret_key,
            preload_pool_size=75
        )

the blocks pool size will still be 200, like it was before.
Then, the only way to specify the blocks pool size will be to do

 LakeConfig(
            network=self.network,
            start_block_height=starting_block_height,
            aws_access_key_id=aws_access_key_id,
            aws_secret_key=aws_secret_key,
            preload_pool_size=75,
            blocks_preload_pool_size= 100
        )

@frol
Copy link
Collaborator

frol commented Dec 12, 2024

@bokobza should we then warn users at runtime that preload_pool_size is noop?

@bokobza
Copy link
Contributor Author

bokobza commented Dec 13, 2024

We could add a warning log that says "The preload_pool_size argument is not used and will be deprecated in a future release. Use blocks_preload_pool_size instead."

@bokobza
Copy link
Contributor Author

bokobza commented Dec 16, 2024

@frol @frolvanya I think this is ready for review now.

@frolvanya frolvanya merged commit 2669803 into frolvanya:main Dec 19, 2024
1 check failed
@frolvanya
Copy link
Owner

@bokobza Thanks for your contribution!

@frolvanya
Copy link
Owner

I've updated pypi package: https://pypi.org/project/near-lake-framework/0.1.2/

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.

4 participants