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

Optionally skip failed question claimings #586

Merged
merged 2 commits into from
Jan 20, 2025
Merged

Conversation

kongzii
Copy link
Contributor

@kongzii kongzii commented Jan 20, 2025

deploy please

Copy link

coderabbitai bot commented Jan 20, 2025

Walkthrough

The changes modify the claim_bonds_on_realitio_questions function in the Omen market resolving module to introduce a new skip_failed parameter. This parameter provides enhanced error handling capabilities, allowing the function to optionally continue processing remaining questions even if an exception occurs during bond claiming for a specific question. The modification improves the function's resilience by giving callers more control over error handling behavior.

Changes

File Change Summary
prediction_market_agent_tooling/markets/omen/omen_resolving.py - Added skip_failed parameter to claim_bonds_on_realitio_questions function
- Implemented try-except block for bond claiming
- Added conditional exception handling based on skip_failed value

Sequence Diagram

sequenceDiagram
    participant Caller
    participant ClaimBondsFunction
    participant RealitioQuestion
    
    Caller->>ClaimBondsFunction: Call with questions and skip_failed flag
    loop For each question
        ClaimBondsFunction->>RealitioQuestion: Attempt to claim bond
        alt Claim Successful
            ClaimBondsFunction->>ClaimBondsFunction: Record successful claim
        else Claim Failed
            alt skip_failed is True
                ClaimBondsFunction->>ClaimBondsFunction: Log error, continue
            else skip_failed is False
                ClaimBondsFunction->>Caller: Raise exception
            end
        end
    end
    ClaimBondsFunction->>Caller: Return results
Loading
✨ Finishing Touches
  • 📝 Generate Docstrings (Beta)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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

@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: 0

🧹 Nitpick comments (1)
prediction_market_agent_tooling/markets/omen/omen_resolving.py (1)

50-55: Consider enhancing error logging for better debugging.

The error logging could be improved to include more context about the exception type and provide structured logging for better error tracking.

-            logger.error(
-                f"Failed to claim bond for {question.url=}, {question.questionId=}: {e}"
-            )
+            logger.error(
+                "Failed to claim bond",
+                extra={
+                    "error_type": type(e).__name__,
+                    "error_message": str(e),
+                    "question_url": question.url,
+                    "question_id": question.questionId.hex(),
+                }
+            )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d4e9097 and a6f2cc1.

⛔ Files ignored due to path filters (1)
  • pyproject.toml is excluded by !**/*.toml
📒 Files selected for processing (1)
  • prediction_market_agent_tooling/markets/omen/omen_resolving.py (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (6)
  • GitHub Check: pytest - Python 3.12.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.12.x - Unit Tests
  • GitHub Check: pytest - Python 3.11.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.11.x - Unit Tests
  • GitHub Check: pytest - Python 3.10.x - Integration with Local Chain
  • GitHub Check: pytest - Python 3.10.x - Unit Tests
🔇 Additional comments (3)
prediction_market_agent_tooling/markets/omen/omen_resolving.py (3)

37-37: LGTM! Well-designed parameter addition.

The new skip_failed parameter is well-named, properly typed, and maintains backward compatibility with its default value.


45-49: LGTM! Robust error handling implementation.

The try-except block is well-structured with proper placement of the success tracking inside the try block.


37-55: Verify error handling consistency across related operations.

The new error handling pattern for bond claiming operations should be consistent with other critical financial operations in the codebase.

✅ Verification successful

Error handling implementation is consistent with the codebase design

The skip_failed pattern is correctly implemented only in the bulk operation function, while individual transaction functions maintain strict error handling for safety. This is the intended design pattern across the codebase.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for similar error handling patterns in related functions

# Look for similar financial operations that might benefit from the same error handling pattern
rg -B 2 -A 2 "def \w*claim\w*|def \w*withdraw\w*|def \w*resolve\w*" --type py

# Check for existing try-except patterns in financial operations
rg -B 2 -A 5 "try:.*?except.*?Exception" --type py --multiline

Length of output: 16609


Script:

#!/bin/bash
# Search for the implementation of critical financial operations
ast-grep --pattern 'def claim_bonds_on_realitio_questions($$$)'
ast-grep --pattern 'def claim_bonds_on_realitio_question($$$)'
ast-grep --pattern 'def resolve_markets($$$)'

# Also check for similar skip_failed patterns
rg -B 5 -A 5 "skip_failed.*?=.*?(True|False)" --type py

Length of output: 1248


Script:

#!/bin/bash
# Get complete implementations of critical functions
rg -B 10 -A 30 "^def (resolve_markets|claim_bonds_on_realitio_question|omen_resolve_market_tx)" --type py

# Look for any other error handling patterns in financial operations
rg -B 5 -A 10 "try:.*?(claim|resolve|withdraw)" --type py --multiline

Length of output: 14458

Comment on lines +54 to +55
f"Failed to claim bond for {question.url=}, {question.questionId=}: {e}"
)
Copy link
Contributor

Choose a reason for hiding this comment

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

According to GCP, here's the error

eb3.exceptions.ContractLogicError: ('execution reverted: History input provided did not match the expected hash', 

I imagine there's a bug with the history input?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No there isn't. That question has just 1 answer, not much to get wrong there. On localhost, it also failed a few times on "already claimed". And then it suddenly passed 🤷 Weird times!

@kongzii kongzii merged commit 8c436a7 into main Jan 20, 2025
16 checks passed
@kongzii kongzii deleted the peter/skipfailedbonds branch January 20, 2025 13:52
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