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/pagination next key #333

Merged
merged 3 commits into from
Jun 12, 2024
Merged

Fix/pagination next key #333

merged 3 commits into from
Jun 12, 2024

Conversation

aarmoa
Copy link
Collaborator

@aarmoa aarmoa commented Jun 11, 2024

  • Solved issue when processing the PaginationOption next page key. Now it is correctly decoded before creating the PageRequest
  • Added new example on how to use the next_key in the PaginationOption class

Fixes CHAIN-123

Summary by CodeRabbit

  • New Features

    • Introduced an example for making paginated requests using an async client to fetch total supply data.
  • Bug Fixes

    • Fixed an error related to pagination responses.
  • Refactor

    • Renamed key parameter to encoded_page_key in pagination-related functionalities for better clarity.
  • Tests

    • Added tests for the PaginationOption class to validate pagination request creation and handle various scenarios.
  • Chores

    • Updated project version to 1.5.3.

@aarmoa aarmoa requested a review from nicolasbaum June 11, 2024 20:21
Copy link
Contributor

coderabbitai bot commented Jun 11, 2024

Important

Review skipped

Review was skipped due to path filters

Files ignored due to path filters (1)
  • poetry.lock is excluded by !**/*.lock

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

The recent update to version 1.5.3 of the project includes several key changes. The key parameter in the PaginationOption class was renamed to encoded_page_key, and the handling of pagination keys was adjusted to improve functionality. A new example file demonstrates making paginated requests with an async client, and tests were added to ensure the correct behavior of pagination features. Additionally, the project's version was updated in the configuration file.

Changes

File Path Change Summary
CHANGELOG.md Documented changes for version 1.5.3, including modifications to PaginationOption and pagination error fixes.
examples/chain_client/9_PaginatedRequestExample.py Introduced a new example for making paginated requests using an async client.
pyinjective/async_client.py Modified pagination key handling in initialize_tokens_from_chain_denoms method.
pyinjective/client/model/pagination.py Renamed key parameter to encoded_page_key in PaginationOption class and updated related logic.
pyproject.toml Updated project version from 1.5.2 to 1.5.3.
tests/client/chain/grpc/test_chain_grpc_auth_api.py Renamed key parameter to encoded_page_key in PaginationOption instantiation.
tests/client/model/test_pagination.py Added new tests for PaginationOption class.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant ExampleScript as 9_PaginatedRequestExample.py
    participant AsyncClient as async_client.py
    participant PaginationOption as pagination.py
    participant Network as network.py

    User->>ExampleScript: Run script
    ExampleScript->>Network: Setup network
    ExampleScript->>AsyncClient: Fetch total supply (initial)
    AsyncClient->>PaginationOption: Create pagination request
    PaginationOption->>AsyncClient: Return paginated request
    AsyncClient->>ExampleScript: Return initial result
    loop Fetch subsequent pages
        ExampleScript->>AsyncClient: Fetch total supply (next page)
        AsyncClient->>PaginationOption: Create pagination request
        PaginationOption->>AsyncClient: Return paginated request
        AsyncClient->>ExampleScript: Return next page result
    end
    ExampleScript->>User: Display total supply data
Loading

Poem

In code we trust, with keys anew,
Paginated dreams come true,
Async flows and tests that gleam,
Version bumped, a coder's dream.
From Rabbit's warren, changes sprout,
A better path, there's no doubt.
🐇✨


Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Outside diff range and nitpick comments (1)
tests/client/chain/grpc/test_chain_grpc_auth_api.py (1)

Line range hint 159-159: Replace Yoda condition with len(response_accounts) == 1.

- assert 1 == len(response_accounts)
+ assert len(response_accounts) == 1
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ece0283 and 6a6b31c.

Files selected for processing (7)
  • CHANGELOG.md (1 hunks)
  • examples/chain_client/9_PaginatedRequestExample.py (1 hunks)
  • pyinjective/async_client.py (2 hunks)
  • pyinjective/client/model/pagination.py (4 hunks)
  • pyproject.toml (1 hunks)
  • tests/client/chain/grpc/test_chain_grpc_auth_api.py (1 hunks)
  • tests/client/model/test_pagination.py (1 hunks)
Files skipped from review due to trivial changes (1)
  • pyproject.toml
Additional context used
Ruff
tests/client/chain/grpc/test_chain_grpc_auth_api.py

159-159: Yoda conditions are discouraged, use len(response_accounts) == 1 instead (SIM300)

Replace Yoda condition with len(response_accounts) == 1

LanguageTool
CHANGELOG.md

[duplication] ~6-~6: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...this file. ## [1.5.3] - 2024-06-12 ### Changed - Changed parameter key from the PaginationOpti...


[duplication] ~32-~32: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...ed methods ## [1.4.0] - 2024-03-11 ### Added - Added support for all queries and messages in...


[duplication] ~56-~56: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...n` message ## [1.1.0] - 2024-01-15 ### Added - Added new functions in all Market classes to ...


[duplication] ~65-~65: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...ion files ## [1.0.1] - 2024-01-08 ### Added - Added low level API components for all module...


[uncategorized] ~66-~66: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL)
Context: ... [1.0.1] - 2024-01-08 ### Added - Added low level API components for all modules (chain, ...


[uncategorized] ~72-~72: If this is a compound adjective that modifies the following noun, use a hyphen. (EN_COMPOUND_ADJECTIVE_INTERNAL)
Context: ... chain, exchange and explorer using the low level API components - Marked old function si...


[duplication] ~77-~77: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...nt functions ## [1.0] - 2023-11-01 ### Added - Added logic to support use of Client Order ID...

Markdownlint
CHANGELOG.md

90-90: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


93-93: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


96-96: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


99-99: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


102-102: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


105-105: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


108-108: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


111-111: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


112-112: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


115-115: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


118-118: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


121-121: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


124-124: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


125-125: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


128-128: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


129-129: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


130-130: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


131-131: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


135-135: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


138-138: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


141-141: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


144-144: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


147-147: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


148-148: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


151-151: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


152-152: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


153-153: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


154-154: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


155-155: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


156-156: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


157-157: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


158-158: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


161-161: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


164-164: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


167-167: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


170-170: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


173-173: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


176-176: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


179-179: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


182-182: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


185-185: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


188-188: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


191-191: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


192-192: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


195-195: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


196-196: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


199-199: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


202-202: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


203-203: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


204-204: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


207-207: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


210-210: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


213-213: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


216-216: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


219-219: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


222-222: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


223-223: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


226-226: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


229-229: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


232-232: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


235-235: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


238-238: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


239-239: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


242-242: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


245-245: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


248-248: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


249-249: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


250-250: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


251-251: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


254-254: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


255-255: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


258-258: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


261-261: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


264-264: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


265-265: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


268-268: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


271-271: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


274-274: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


277-277: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


280-280: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


283-283: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


286-286: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


289-289: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


290-290: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


291-291: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


294-294: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


295-295: Expected: dash; Actual: asterisk (MD004, ul-style)
Unordered list style


63-63: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


133-133: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


5-5: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


6-6: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


6-6: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


10-10: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


11-11: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


11-11: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


14-14: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


15-15: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


15-15: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


18-18: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


19-19: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


19-19: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


23-23: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


24-24: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


24-24: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


27-27: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


28-28: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


28-28: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


31-31: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


32-32: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


37-37: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


38-38: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


38-38: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


41-41: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


42-42: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


42-42: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


45-45: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


46-46: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


46-46: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


51-51: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


52-52: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


52-52: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


55-55: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


56-56: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


56-56: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


59-59: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


64-64: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


65-65: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


65-65: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


70-70: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


76-76: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


77-77: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


77-77: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


81-81: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


89-89: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


92-92: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


95-95: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


98-98: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


101-101: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


104-104: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


107-107: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


110-110: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


114-114: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


117-117: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


120-120: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


123-123: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


127-127: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


134-134: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


137-137: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


140-140: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


143-143: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


146-146: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


150-150: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


160-160: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


163-163: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


166-166: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


169-169: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


172-172: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


175-175: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


178-178: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


181-181: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


184-184: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


187-187: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


190-190: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


194-194: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


198-198: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


201-201: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


206-206: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


209-209: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


212-212: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


215-215: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


218-218: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


221-221: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


225-225: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


228-228: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


231-231: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


234-234: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


237-237: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


241-241: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


244-244: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


247-247: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


253-253: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


257-257: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


260-260: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


263-263: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


267-267: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


270-270: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


273-273: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


276-276: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


279-279: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


282-282: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


285-285: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


288-288: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


293-293: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


172-172: null (MD024, no-duplicate-heading)
Multiple headings with the same content


279-279: null (MD024, no-duplicate-heading)
Multiple headings with the same content


7-7: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


12-12: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


16-16: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


20-20: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


25-25: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


29-29: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


33-33: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


39-39: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


43-43: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


47-47: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


53-53: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


57-57: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


60-60: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


66-66: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


71-71: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


78-78: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


82-82: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


90-90: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


93-93: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


96-96: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


99-99: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


102-102: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


105-105: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


108-108: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


111-111: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


115-115: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


118-118: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


121-121: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


124-124: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


128-128: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


135-135: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


138-138: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


141-141: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


144-144: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


147-147: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


151-151: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


161-161: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


164-164: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


167-167: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


170-170: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


173-173: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


176-176: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


179-179: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


182-182: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


185-185: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


188-188: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


191-191: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


195-195: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


199-199: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


202-202: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


207-207: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


210-210: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


213-213: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


216-216: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


219-219: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


222-222: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


226-226: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


229-229: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


232-232: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


235-235: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


238-238: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


242-242: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


245-245: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


248-248: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


254-254: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


258-258: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


261-261: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


264-264: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


268-268: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


271-271: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


274-274: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


277-277: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


280-280: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


283-283: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


286-286: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


289-289: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


294-294: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines


297-297: null (MD036, no-emphasis-as-heading)
Emphasis used instead of a heading

Additional comments not posted (8)
examples/chain_client/9_PaginatedRequestExample.py (2)

11-17: LGTM! The initial pagination setup and request are correctly implemented.


8-10: Ensure proper error handling for network and client initialization.

tests/client/model/test_pagination.py (2)

6-28: Comprehensive test coverage for pagination request creation. Good use of assertions to validate the behavior.


29-35: Excellent handling of edge cases with empty encoded page keys.

pyinjective/client/model/pagination.py (1)

Line range hint 1-21: Constructor correctly initializes all fields. Good use of optional typing.

tests/client/chain/grpc/test_chain_grpc_auth_api.py (1)

148-148: Correct usage of the encoded_page_key in the pagination setup.

CHANGELOG.md (1)

5-9: Ensure the changelog entries are accurate and reflect the significant changes made in the PR.

The changelog correctly summarizes the changes made to the PaginationOption class and the fix related to the next page key. It's important that the changelog remains a reliable source of project history.

Tools
LanguageTool

[duplication] ~6-~6: Possible typo: you repeated a word (ENGLISH_WORD_REPEAT_RULE)
Context: ...this file. ## [1.5.3] - 2024-06-12 ### Changed - Changed parameter key from the PaginationOpti...

Markdownlint

5-5: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


6-6: Expected: 1; Actual: 0; Above (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


6-6: Expected: 1; Actual: 0; Below (MD022, blanks-around-headings)
Headings should be surrounded by blank lines


7-7: null (MD032, blanks-around-lists)
Lists should be surrounded by blank lines

pyinjective/async_client.py (1)

3066-3069: Pagination handling improved by correctly decoding the next_key.

Comment on lines +40 to +41
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
Copy link
Contributor

Choose a reason for hiding this comment

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

Consider using asyncio.run(main()) for a more modern approach to running asyncio programs.

- asyncio.get_event_loop().run_until_complete(main())
+ asyncio.run(main())
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if __name__ == "__main__":
asyncio.get_event_loop().run_until_complete(main())
if __name__ == "__main__":
asyncio.run(main())

Comment on lines +22 to +37
for i in range(5):
if next_page_key == "":
break

next_request_pagination = PaginationOption(
limit=pagination.limit,
count_total=pagination.count_total,
encoded_page_key=next_page_key,
)

next_result = await client.fetch_total_supply(
pagination=next_request_pagination,
)
print(f"Page {i+2} result:\n{next_result}")

next_page_key = next_result["pagination"]["nextKey"]
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize the pagination loop to handle potential exceptions and ensure robustness.

- for i in range(5):
-     if next_page_key == "":
-         break
+ for i in range(5):
+     try:
+         if next_page_key == "":
+             break
+     except Exception as e:
+         print(f"Error during pagination: {e}")
+         break

Committable suggestion was skipped due to low confidence.

Comment on lines +34 to +36
if self.encoded_page_key is not None and self.encoded_page_key != "":
page_key = base64.b64decode(self.encoded_page_key)
page_request.key = page_key
Copy link
Contributor

@coderabbitai coderabbitai bot Jun 11, 2024

Choose a reason for hiding this comment

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

Tip

Codebase Verification

The create_pagination_request method was found in pyinjective/client/model/pagination.py, but there is no evidence of exception handling around the base64 decoding within this method.

  • File: pyinjective/client/model/pagination.py
  • Lines: 34-36

Please ensure to handle potential exceptions from incorrect base64 strings to avoid runtime errors.

Analysis chain

Proper handling of base64 decoding for the page key. Ensure to handle potential exceptions from incorrect base64 strings.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify exception handling for base64 decoding in `create_pagination_request`.

# Test: Search for exception handling patterns around base64 decoding.
ast-grep --lang python --pattern $'def create_pagination_request($_) {
  try {
    $$$
    base64.b64decode($_)
    $$$
  } catch ($_){
    $$$
  }
}'

Length of output: 496



Script:

#!/bin/bash
# Description: Locate the `create_pagination_request` method and check for exception handling around base64 decoding.

# Step 1: Locate the `create_pagination_request` method.
ast-grep --lang python --pattern 'def create_pagination_request($_) {
  $$$
}' > create_pagination_request_location.txt

# Step 2: Check for try-except blocks within the `create_pagination_request` method.
if [ -s create_pagination_request_location.txt ]; then
  # Extract the file path from the location result
  file_path=$(head -n 1 create_pagination_request_location.txt | cut -d: -f1)
  
  # Search for try-except blocks within the located method
  ast-grep --lang python --pattern 'def create_pagination_request($_) {
    $$$
    try:
      $$$
    except $_:
      $$$
  }' $file_path
else
  echo "Method create_pagination_request not found."
fi

Length of output: 695



Script:

#!/bin/bash
# Description: Locate the `create_pagination_request` method and check for exception handling around base64 decoding.

# Step 1: Locate the `create_pagination_request` method.
ast-grep --lang python --pattern 'def create_pagination_request($_):' > create_pagination_request_location.txt

# Step 2: Check for try-except blocks within the `create_pagination_request` method.
if [ -s create_pagination_request_location.txt ]; then
  # Extract the file path from the location result
  file_path=$(head -n 1 create_pagination_request_location.txt | cut -d: -f1)
  
  # Search for try-except blocks within the located method
  ast-grep --lang python --pattern 'try:
  $$$
except $_:
  $$$' $file_path
else
  echo "Method create_pagination_request not found."
fi

Length of output: 220



Script:

#!/bin/bash
# Description: Search for the `create_pagination_request` method and inspect for exception handling around base64 decoding.

# Step 1: Search for the `create_pagination_request` method definition.
rg 'def create_pagination_request' > create_pagination_request_location.txt

# Step 2: Check for try-except blocks within the located method.
if [ -s create_pagination_request_location.txt ]; then
  # Extract the file path from the location result
  file_path=$(head -n 1 create_pagination_request_location.txt | cut -d: -f1)
  
  # Search for try-except blocks within the located method
  rg -A 10 'def create_pagination_request' $file_path | rg 'try:|except'
else
  echo "Method create_pagination_request not found."
fi

Length of output: 307

Choose a reason for hiding this comment

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

This is a fair point, but wonder how could this happen. Think it's better to crash if some of these exceptions are risen

Copy link
Contributor

Choose a reason for hiding this comment

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

@nicolasbaum, I understand your perspective on preferring the application to crash in cases where exceptions like incorrect base64 strings occur, as it makes such issues more visible and likely to be fixed promptly.

However, it's also worth considering the user experience, especially in a production environment where such crashes could lead to disruptions in service. An alternative approach could be to log these errors comprehensively while still allowing the application to continue running. This way, the issues are documented and can be addressed without immediately impacting end users.

Would you like to explore setting up detailed logging for these exceptions, or would you prefer to proceed with the current approach where the application will crash under these circumstances? This decision can be aligned with how critical the stability of this feature is and the expected stability of the input data.

Let me know how you'd like to proceed or if there's any other aspect of the implementation you'd like to discuss!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I don't think this is a fair point. If there was an error in the base64 encoded string, the error would have happened before, when the response was converted into its JSON representation. Since we reached this point, we are sure the encoded pagination key can be decoded without issues.

Copy link
Contributor

Choose a reason for hiding this comment

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

Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!

Copy link

@nicolasbaum nicolasbaum left a comment

Choose a reason for hiding this comment

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

wunderbar

@aarmoa aarmoa merged commit a93aab1 into master Jun 12, 2024
12 checks passed
@aarmoa aarmoa deleted the fix/pagination_next_key branch June 12, 2024 12:37
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