Skip to content

Async client#65

Merged
robmck1995 merged 7 commits intomainfrom
rob
Jan 23, 2025
Merged

Async client#65
robmck1995 merged 7 commits intomainfrom
rob

Conversation

@robmck1995
Copy link
Copy Markdown
Contributor

@robmck1995 robmck1995 commented Jan 23, 2025

Description

  • Implemented AsyncLsproxy class to support asynchronous interactions with the lsproxy API, enhancing the SDK's capabilities.
  • Updated the README to include usage instructions for the new AsyncLsproxy class, providing both synchronous and asynchronous examples.
  • Bumped the project version to 0.2.3 to reflect the new features and documentation updates.

Changes walkthrough

Relevant files
Enhancement
__init__.py
Add AsyncLsproxy to module exports                                                         

lsproxy/init.py

  • Added import for AsyncLsproxy.
  • Updated __all__ to include AsyncLsproxy.
  • +2/-0     
    async_client.py
    Implement AsyncLsproxy for asynchronous API interactions             

    lsproxy/async_client.py

  • Implemented AsyncLsproxy class for async API interactions.
  • Added methods for symbol and file operations.
  • Included error handling and initialization with Modal.
  • +187/-0 
    Documentation
    README.md
    Update README with AsyncLsproxy usage instructions                         

    README.md

  • Added instructions for using AsyncLsproxy.
  • Updated Modal usage section with async examples.
  • Clarified usage instructions for local server and Modal.
  • +52/-0   
    Configuration changes
    pyproject.toml
    Update project version to 0.2.3                                                               

    pyproject.toml

    • Bumped version from 0.2.2 to 0.2.3.
    +1/-1     
    💡 Usage Guide

    Checking Your Pull Request

    Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

    Talking to CodeAnt AI

    Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

    @codeant-ai ask: Your question here
    

    This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

    Retrigger review

    Ask CodeAnt AI to review the PR again, by typing:

    @codeant-ai: review
    

    Check Your Repository Health

    To analyze the health of your code repository, visit our dashboard at app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

    @robmck1995 robmck1995 merged commit 8366fd6 into main Jan 23, 2025
    @codeant-ai codeant-ai Bot added the size:L This PR changes 100-499 lines, ignoring generated files label Jan 23, 2025
    @codeant-ai
    Copy link
    Copy Markdown

    codeant-ai Bot commented Jan 23, 2025

    Pull Request Feedback 🔍

    🔒 No security issues identified
    ⚡ Recommended areas for review

    Error Handling
    The _request method in AsyncLsproxy class has basic error handling for HTTP status errors, but it might be beneficial to include more detailed logging or handling for other exceptions that could occur during the request.

    Timeout Handling
    The initialize_with_modal method uses a fixed timeout of 3 minutes for server startup. Consider making this timeout configurable to allow flexibility in different environments.

    Comment thread lsproxy/async_client.py
    Comment on lines +139 to +143
    for attempt in range(180):
    if await client.check_health():
    break
    await asyncio.sleep(1)
    else:
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

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

    Suggestion: Consider using exponential backoff strategy for retrying requests in _request method to avoid overwhelming the server with requests in case of temporary failures. [performance]

    Suggested change
    for attempt in range(180):
    if await client.check_health():
    break
    await asyncio.sleep(1)
    else:
    for attempt in range(180):
    if await client.check_health():
    break
    await asyncio.sleep(min(2 ** attempt, 60))

    Comment thread lsproxy/async_client.py
    Comment on lines +26 to +27
    base_url: str = "http://localhost:4444/v1",
    timeout: float = 60.0,
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

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

    Suggestion: Validate the base_url parameter in the __init__ method to ensure it is a valid URL, preventing potential runtime errors. [possible issue]

    Suggested change
    base_url: str = "http://localhost:4444/v1",
    timeout: float = 60.0,
    base_url: str = "http://localhost:4444/v1",
    if not base_url.startswith(('http://', 'https://')):
    raise ValueError("Invalid base_url, must start with 'http://' or 'https://'")

    Comment thread README.md
    # Synchronous usage
    lsp = Lsproxy.initialize_with_modal(
    repo_url="https://github.com/username/repo",
    git_token="your-github-token", # Optional, for private repos
    Copy link
    Copy Markdown

    Choose a reason for hiding this comment

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

    Suggestion: Ensure that the git_token parameter is securely managed and not hardcoded in the code to prevent unauthorized access to private repositories. [security]

    Suggested change
    git_token="your-github-token", # Optional, for private repos
    git_token=os.getenv("GITHUB_TOKEN"), # Optional, for private repos

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    size:L This PR changes 100-499 lines, ignoring generated files

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants