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

Bump PMAT and small niches #548

Merged
merged 1 commit into from
Nov 11, 2024
Merged

Bump PMAT and small niches #548

merged 1 commit into from
Nov 11, 2024

Conversation

kongzii
Copy link
Contributor

@kongzii kongzii commented Nov 11, 2024

No description provided.

Copy link
Contributor

coderabbitai bot commented Nov 11, 2024

Walkthrough

This pull request includes changes to several files, primarily focusing on updating the import statements for the logger from loguru to a custom logger from prediction_market_agent_tooling.loggers. Additionally, an entry in the RunnableAgent enum has been removed, affecting the mapping in the RUNNABLE_AGENTS dictionary. The core functionality of the classes and methods remains unchanged, with no alterations to their logic or structure.

Changes

File Path Change Summary
prediction_market_agent/agents/microchain_agent/blockchain/contract_class_converter.py Updated logger import from loguru to prediction_market_agent_tooling.loggers.
prediction_market_agent/db/pinecone_handler.py Updated logger import from loguru to prediction_market_agent_tooling.loggers.
prediction_market_agent/run_agent.py Removed prophet_gpt4_kelly entry from RunnableAgent enum, affecting the RUNNABLE_AGENTS mapping.

Possibly related PRs

  • 329 register solidity python functions on general agent wxdai #330: The changes in contract_class_converter.py and code_interpreter.py both involve modifications to the handling of smart contracts and their associated classes, indicating a potential relationship in how contract interactions are structured.
  • Use our logger in Prophet agent app #404: The addition of the logger parameter in the PredictionProphetAgent instantiation in deploy.py aligns with the changes in the main PR where the logger import was modified, suggesting a common focus on improving logging practices.
  • Remove kelly-specific deployed agents #434: The removal of the KellyBettingStrategy and related classes in deploy.py reflects a broader restructuring that may relate to the changes in the main PR, which also involves adjustments to agent functionalities.
  • Using latest PMAT with db_cache #536: The removal of the tavily_storage parameter in both the main PR and this PR indicates a shift in how data management is approached, suggesting a direct connection in the evolution of the codebase.
  • Add prophet-gpt4o agent that trades on new markets #537: The introduction of a new agent that trades on new markets in deploy.py may relate to the overall enhancements in agent functionalities discussed in the main PR, particularly in how agents interact with market data.

Suggested reviewers

  • evangriffiths

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

@kongzii
Copy link
Contributor Author

kongzii commented Nov 11, 2024

I will merge this PR as hotifx for our agents, because there are too many connections to the database. This PR is uncontroversial (just PMAT bump mostly), but I'll leave gnosis/prediction-market-agent-tooling#547 open for a proper review and after that, I'll open a new PR here to switch to the proper (non-dev) version of PMAT.

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

🧹 Outside diff range and nitpick comments (2)
prediction_market_agent/agents/microchain_agent/blockchain/contract_class_converter.py (2)

Line range hint 156-158: Consider enhancing the "from" keyword replacement logic.

The current approach of replacing "from" with "sender" might be fragile if the contract's ABI uses these terms inconsistently or if "from" appears as part of another word.

Consider using a more robust approach:

-        if "from" in function_code:
-            function_code = function_code.replace("from", "sender")
+        import re
+        function_code = re.sub(r'\bfrom\b', 'sender', function_code)

Line range hint 102-112: Enhance type mapping error messages.

The warning messages for type mapping failures could be more informative by including the actual type that failed.

Consider enhancing the error messages:

-                logger.warning(
-                    f"Type mapping for {abi_item.name} has failed. Check inputs {abi_item.inputs}"
-                )
+                logger.warning(
+                    f"Type mapping for function '{abi_item.name}' failed. Unsupported input type: {input.type}. "
+                    f"Available types: {list(TYPE_MAPPING.keys())}"
+                )
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 5f90658 and 7c6e7aa.

⛔ Files ignored due to path filters (2)
  • poetry.lock is excluded by !**/*.lock, !**/*.lock
  • pyproject.toml is excluded by !**/*.toml
📒 Files selected for processing (3)
  • prediction_market_agent/agents/microchain_agent/blockchain/contract_class_converter.py (1 hunks)
  • prediction_market_agent/db/pinecone_handler.py (1 hunks)
  • prediction_market_agent/run_agent.py (0 hunks)
💤 Files with no reviewable changes (1)
  • prediction_market_agent/run_agent.py
✅ Files skipped from review due to trivial changes (1)
  • prediction_market_agent/db/pinecone_handler.py
🔇 Additional comments (2)
prediction_market_agent/agents/microchain_agent/blockchain/contract_class_converter.py (2)

9-9: LGTM! Verify logger interface compatibility.

The change to use the custom logger from prediction_market_agent_tooling.loggers aligns with the standardization effort across the codebase.

Let's verify that the custom logger provides the same interface as loguru for the warning level:

✅ Verification successful

Import change is consistent with codebase-wide pattern

The change to use prediction_market_agent_tooling.loggers is verified to be part of a consistent pattern across the entire codebase, with 28+ files using the same import. The file contains two logger.warning calls that follow this standardized approach.

Reasoning:

  1. The search results show widespread adoption of from prediction_market_agent_tooling.loggers import logger across multiple components
  2. This change aligns the file with the project's standardized logging approach
  3. The presence of logger.warning calls in the file confirms active usage of the logger interface
🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the custom logger interface matches loguru's interface
# Test 1: Check the custom logger implementation
rg -A 5 "class.*Logger" prediction_market_agent_tooling/loggers
# Test 2: Verify all warning calls are compatible
rg "logger\.warning" prediction_market_agent_tooling/

Length of output: 274


Script:

#!/bin/bash
# Let's try searching in the current repository
# Check if the logger module exists and its implementation
fd "loggers?.py$"

# Check the usage of logger.warning in the current file
rg "logger\.warning" prediction_market_agent/agents/microchain_agent/blockchain/contract_class_converter.py

# Look for other logger imports to understand the pattern
rg "from.*logger.*import" 

Length of output: 3597


Line range hint 144-146: Review exec() usage for security implications.

The use of exec() for dynamic function creation could be dangerous if the input is not properly sanitized. While the current usage appears safe as it's working with validated ABI data, it's worth documenting this security consideration.

Let's verify the ABI validation:

✅ Verification successful

Exec usage is properly secured through validated ABI data

The exec() usage is safe because:

  1. Input is validated through Pydantic's BaseModel (ABIMetadata, ArgMetadata)
  2. The function code is constructed using strictly controlled components:
    • Function name from validated ABI
    • Arguments from validated ArgMetadata
    • Fixed template strings for view/payable functions
    • Namespace is isolated with only the contract reference
  3. Python reserved keywords (e.g., "from") are properly handled
  4. The generated code only calls contract.call() or contract.send() with validated parameters

The security concern is adequately addressed through the validation chain and controlled code generation process.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Check for ABI validation before exec
# Test: Look for validation of ABI items
rg -B 5 "exec\(" .
rg "model_validate|validate" prediction_market_agent/agents/microchain_agent/blockchain/

Length of output: 1158


Script:

#!/bin/bash
# Let's check the ABIMetadata class definition and validation
ast-grep --pattern 'class ABIMetadata'

# Also check the function that generates the code being exec'd
ast-grep --pattern 'def create_function_code'

# And check how the namespace is prepared
rg -B 5 "namespace = {" .

Length of output: 206


Script:

#!/bin/bash
# Let's check the ABIMetadata class definition and validation with proper escaping
rg -A 10 "class ABIMetadata" .

# Check the function that generates the code being exec'd
rg -A 10 "def create_function_code" .

# And check how the namespace is prepared with proper escaping
rg -B 5 "namespace = \{" .

Length of output: 1508


Script:

#!/bin/bash
# Let's check the full context of where exec is used and how the function code is created
rg -B 20 -A 10 "exec\(" prediction_market_agent/agents/microchain_agent/blockchain/contract_class_converter.py

# Also check the ArgMetadata definition since it's part of the validation
rg -A 5 "class ArgMetadata" .

# And check the AbiItemTypeEnum and AbiItemStateMutabilityEnum
rg -A 5 "class AbiItem.*Enum" .

Length of output: 3022

@kongzii kongzii merged commit 0166254 into main Nov 11, 2024
9 checks passed
@kongzii kongzii deleted the peter/pmat-lower-connections branch November 11, 2024 08:22
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.

1 participant