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

Gabriel/resolved bets in agent market #300

Merged
merged 22 commits into from
Jul 9, 2024

Conversation

gabrielfior
Copy link
Contributor

Copy link

coderabbitai bot commented Jul 5, 2024

Important

Review skipped

Review was skipped due to path filters

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

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

Walkthrough

The changes primarily focus on adding new functionalities for resolving bets in the prediction_market_agent_tooling package. This includes introducing new methods and updating existing ones to handle resolved bets with corresponding updates in data models and APIs. A new ResolvedBet class has been introduced, along with functions to retrieve these resolved bets based on specific criteria. Additionally, several classes in the data models now have methods to return string representations for better logging and debugging.

Changes

Files/Path Change Summary
prediction_market_agent_tooling/markets/agent_market.py Added ResolvedBet entity, introduced get_resolved_bets_made_since method, and updated get_bets_made_since to raise NotImplementedError.
prediction_market_agent_tooling/markets/data_models.py Added methods __str__ to Currency, TokenAmount, Bet, ResolvedBet classes and imported HexAddress.
prediction_market_agent_tooling/markets/manifold/api.py Updated manifold_to_generic_resolved_bet to include market_id with HexAddress and imported necessary modules.
prediction_market_agent_tooling/markets/omen/data_models.py Updated to_bet and to_generic_resolved_bet methods to include market_id field.
prediction_market_agent_tooling/markets/omen/omen.py Introduced get_resolved_bets_made_since method in Omen class.

Sequence Diagram(s)

sequenceDiagram
    actor User
    participant AgentMarket
    participant DataModels
    participant ManifoldAPI
    participant OmenDataModels
    participant Omen

    User ->> AgentMarket: Call get_resolved_bets_made_since()
    AgentMarket ->> Omen: Forward get_resolved_bets_made_since()
    Omen ->> OmenDataModels: Retrieve Resolved Bets
    OmenDataModels ->> Omen: Return List of ResolvedBets
    Omen ->> AgentMarket: Return List of ResolvedBets
    AgentMarket ->> User: Return List of ResolvedBets
Loading

Possibly related issues


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>.
    • 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

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8bbeb84 and 3be5f5f.

Files ignored due to path filters (3)
  • poetry.lock is excluded by !**/*.lock, !**/*.lock
  • pyproject.toml is excluded by !**/*.toml
  • scripts/example_tool_metadata.json is excluded by !**/*.json
Files selected for processing (5)
  • prediction_market_agent_tooling/markets/agent_market.py (2 hunks)
  • prediction_market_agent_tooling/markets/data_models.py (5 hunks)
  • prediction_market_agent_tooling/markets/manifold/api.py (2 hunks)
  • prediction_market_agent_tooling/markets/omen/data_models.py (2 hunks)
  • prediction_market_agent_tooling/markets/omen/omen.py (2 hunks)
Additional context used
Learnings (1)
prediction_market_agent_tooling/markets/agent_market.py (1)
Learnt from: kongzii
PR: gnosis/prediction-market-agent-tooling#224
File: prediction_market_agent_tooling/markets/markets.py:67-67
Timestamp: 2024-04-29T14:14:38.751Z
Learning: The function `have_bet_on_market_since` is suggested to be refactored into a method on the `AgentMarket` class, potentially reusing code from `DeployedAgent.get_resolved_bets`. This task is planned for future work, not within the scope of the current PR.
Additional comments not posted (9)
prediction_market_agent_tooling/markets/data_models.py (4)

16-17: Correct Implementation of __str__ Method.

The __str__ method correctly returns the string representation of the Currency enum.


31-32: Correct Implementation of __str__ Method.

The __str__ method correctly returns a formatted string representation of the TokenAmount instance.


44-47: Correct Implementation of market_id Field and __str__ Method.

The market_id field and the __str__ method are correctly implemented. The method provides a clear string representation of the Bet instance.


60-61: Correct Implementation of __str__ Method.

The __str__ method correctly returns a detailed string representation of the ResolvedBet instance.

prediction_market_agent_tooling/markets/manifold/api.py (1)

216-216: Correct Update to manifold_to_generic_resolved_bet Function.

The market_id parameter with a HexAddress value derived from HexStr(market.id) is correctly included in the manifold_to_generic_resolved_bet function.

prediction_market_agent_tooling/markets/agent_market.py (1)

167-171: Reminder: Implement the get_resolved_bets_made_since Method.

The get_resolved_bets_made_since method raises a NotImplementedError. Ensure this method is implemented in subclasses.

Do you want me to generate the implementation for this method or open a GitHub issue to track this task?

prediction_market_agent_tooling/markets/omen/data_models.py (2)

389-389: Correct Update to to_bet Method.

The market_id field is correctly included in the to_bet method.


403-403: Correct Update to to_generic_resolved_bet Method.

The market_id and market_outcome fields are correctly included in the to_generic_resolved_bet method.

prediction_market_agent_tooling/markets/omen/omen.py (1)

340-343: Ensure proper error handling for external calls.

The function get_resolved_bets_made_since relies on the OmenSubgraphHandler to fetch data. Ensure that potential errors from this external call are properly handled.

prediction_market_agent_tooling/markets/omen/omen.py Outdated Show resolved Hide resolved
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3be5f5f and 16b429b.

Files selected for processing (1)
  • prediction_market_agent_tooling/markets/data_models.py (4 hunks)
Files skipped from review as they are similar to previous changes (1)
  • prediction_market_agent_tooling/markets/data_models.py

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 16b429b and 33f94c1.

Files selected for processing (3)
  • prediction_market_agent_tooling/markets/agent_market.py (2 hunks)
  • prediction_market_agent_tooling/markets/manifold/api.py (2 hunks)
  • prediction_market_agent_tooling/markets/omen/omen.py (2 hunks)
Files skipped from review as they are similar to previous changes (3)
  • prediction_market_agent_tooling/markets/agent_market.py
  • prediction_market_agent_tooling/markets/manifold/api.py
  • prediction_market_agent_tooling/markets/omen/omen.py

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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 33f94c1 and 57a2ccf.

Files selected for processing (2)
  • prediction_market_agent_tooling/markets/agent_market.py (2 hunks)
  • prediction_market_agent_tooling/markets/omen/omen.py (2 hunks)
Files skipped from review as they are similar to previous changes (1)
  • prediction_market_agent_tooling/markets/omen/omen.py
Additional context used
Learnings (1)
prediction_market_agent_tooling/markets/agent_market.py (1)
Learnt from: evangriffiths
PR: gnosis/prediction-market-agent-tooling#300
File: prediction_market_agent_tooling/markets/omen/omen.py:344-352
Timestamp: 2024-07-08T07:05:58.507Z
Learning: The `get_resolved_bets_made_since` method in the `OmenAgentMarket` class should include an `end_time` argument to make it more flexible.
Additional comments not posted (2)
prediction_market_agent_tooling/markets/agent_market.py (2)

167-171: Confirm the correct method signature.

The method signature includes the end_time argument, which makes it more flexible. This aligns with the learning retrieved from long-term memory.


171-171: Implement the method functionality.

The method currently raises a NotImplementedError. Ensure that the functionality is implemented in subclasses.

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: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 57a2ccf and 9790d32.

Files selected for processing (2)
  • prediction_market_agent_tooling/markets/data_models.py (3 hunks)
  • prediction_market_agent_tooling/markets/manifold/api.py (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • prediction_market_agent_tooling/markets/manifold/api.py
Additional comments not posted (3)
prediction_market_agent_tooling/markets/data_models.py (3)

27-28: Consider using f-strings for consistency.

The __str__ method uses f-strings, which is consistent with modern Python practices.


42-43: Consider using f-strings for consistency.

The __str__ method uses f-strings, which is consistent with modern Python practices.


56-57: Consider using f-strings for consistency.

The __str__ method uses f-strings, which is consistent with modern Python practices.

@@ -34,6 +37,10 @@ class Bet(BaseModel):
outcome: bool
created_time: datetime
market_question: str
market_id: str
Copy link

Choose a reason for hiding this comment

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

Tip

Codebase Verification

Ensure market_id is correctly populated.

The new market_id field should be correctly populated wherever Bet and ResolvedBet instances are created. The following instances do not populate market_id:

  • prediction_market_agent_tooling/markets/omen/data_models.py
    • Line: 40
    • Line: 49
  • prediction_market_agent_tooling/markets/manifold/api.py
    • Line: 40

Please update these instances to include the market_id field.

Analysis chain

Ensure market_id is correctly populated.

The new market_id field should be correctly populated wherever Bet instances are created.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that `market_id` is correctly populated in all instances of the `Bet` class.

# Test: Search for the creation of `Bet` instances. Expect: All instances should correctly populate `market_id`.
rg --type python $'Bet('

Length of output: 84


Script:

#!/bin/bash
# Description: Verify that `market_id` is correctly populated in all instances of the `Bet` class.

# Test: Search for the creation of `Bet` instances. Expect: All instances should correctly populate `market_id`.
rg --type python 'Bet\('

Length of output: 57


Script:

#!/bin/bash
# Description: Verify that `market_id` is correctly populated in all instances of the `Bet` class.

# Test: Search for the creation of `Bet` instances. Expect: All instances should correctly populate `market_id`.
rg -t py 'Bet\('

Length of output: 602


Script:

#!/bin/bash
# Description: Verify that `market_id` is correctly populated in all instances of the `Bet` class and its subclasses.

# Search for the instantiation of Bet and ResolvedBet in the identified files.
rg -A 3 -B 3 'Bet\(' prediction_market_agent_tooling/markets/omen/data_models.py
rg -A 3 -B 3 'ResolvedBet\(' prediction_market_agent_tooling/markets/omen/data_models.py
rg -A 3 -B 3 'ResolvedBet\(' prediction_market_agent_tooling/markets/manifold/api.py

Length of output: 1556

@gabrielfior gabrielfior merged commit f198305 into main Jul 9, 2024
7 checks passed
@gabrielfior gabrielfior deleted the gabriel/resolved-bets-in-agent-market branch July 9, 2024 22:20
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.

3 participants