Added CLI for potpie
added pytest_cach and poitre.pid in the .gitignore added tabulate and pytest in the requirements.txt
Currently, there is an internal error in the neo4j while in the knowledge graph. If I use return like we did then I will get error in the messaging. I think I don't handle it perfectly with the stream because the message is not working.
Docs
Poitre CLI Tool
A command-line interface (CLI) tool to manage and interact with the Poitre application, including managing servers, parsing repositories, listing projects, and interacting with conversations.
Usage
The CLI provides multiple commands for managing the application. Below is a list of commands and their functionalities.
Global Help
python -m app.poitre --help
Displays the list of available commands and their descriptions.
Server Commands
Start the Server
python -m app.poitre start
- Starts the server and all related services, including Docker containers, database migrations, and the Celery worker.
Stop the Server
python -m app.poitre stop
- Stops the server and all related services.
Project Management
Parse a Repository
python -m app.poitre parse <repository_path> --branch <branch_name>
- Parses a local repository for the specified branch.
- Arguments:
repository_path: Path to the repository on the local machine.--branch: (Optional) Name of the branch to parse (default:main).
List Projects
python app.poitre projects
- Lists all projects with their ID, name, and status.
Delete a Project
python -m app.poitre projects --delete
- Prompts the user to select and delete a project.
Conversation Management
List Conversations
python -m app.poitre conversation list
- Lists all active conversations.
Create a Conversation
python -m app.poitre conversation create <title>
- Starts a new conversation with a project and an agent.
- Arguments:
title: Title of the conversation.
Message an Agent
python -m app.poitre conversation message
- Interact with a selected agent in a specific conversation.
Logging
- Logs are stored in the current working directory:
celery.log: Logs from the Celery worker.celery_error.log: Error logs from the Celery worker.server.log: Logs from the server.server_error.log: Error logs from the server.
Improvement
Logging and poitre.pid file needs improvement.
Summary by CodeRabbit
- New Features
- Introduced a versatile CLI tool offering commands to start/stop the server, manage projects, and handle conversations with agents.
- Enhanced API integration supports real-time interactions, project listings, and streamlined conversation management.
- Added support for managing logs and configuration paths through a new Utility class.
- Specified the Python version for the project.
- Documentation
- Added comprehensive guides detailing CLI usage, contribution steps, and configuration instructions.
- Updated legal and project metadata information.
- Chores
- Improved file ignore settings and dependency declarations for cleaner project maintenance.
- Tests
- Expanded unit testing across API interactions, utilities, and server management for increased reliability.
Walkthrough
This pull request introduces updates to ignore patterns, dependency management, configuration, and documentation files. New configuration files and metadata have been added for project setup, alongside comprehensive enhancements to the API wrapper, utility functions, and server management components. A Click-based CLI tool is provided with commands for starting/stopping the server, parsing repositories, managing projects, and handling conversations. Additionally, a suite of new unit tests ensures robust error handling and functionality across these components.
Changes
| File(s) | Change Summary |
|---|---|
.gitignore, cli/.gitignore |
Added extensive ignore patterns for Python bytecode, virtual environments, logs, caches, and temporary files (e.g., __pycache__, .venv, *.log, etc.). |
requirements.txt |
Reformatted dependency line for pydantic; added new dependencies: agentops==0.3.23, pydantic==2.10.3, and pytest==8.3.4. |
cli/.python-version, cli/LICENSE, cli/README.md, cli/contributing.md, cli/pyproject.toml |
Introduced project configuration and documentation files including Python version specification, Apache License text update, CLI tool documentation with usage instructions, contributing guidelines, and complete project metadata. |
cli/src/.../api_wrapper.py, cli/src/.../utility.py |
Developed an API wrapper with synchronous and asynchronous methods for project, conversation, and agent management; added a Utility class for log file and configuration path management using environment variables. |
cli/src/.../server_manager.py |
Implemented a ServerManager class with structured error handling (custom exceptions) and methods for environment checks, Docker/Postgres management, server and Celery worker orchestration, and graceful shutdown handling. |
cli/src/.../main.py |
Created a Click-based CLI tool with commands for starting/stopping the server, parsing repositories, listing/deleting projects, and managing conversations (create, list, message), including a loading animation for long operations. |
cli/test/... |
Added comprehensive pytest-based tests for the API wrapper, Utility, and ServerManager covering success and error scenarios using fixtures, parameterization, and monkeypatching. |
Sequence Diagram(s)
sequenceDiagram
participant U as User
participant C as CLI
participant SM as ServerManager
participant D as Docker/Postgres
participant UT as Utility
U->>C: Execute "start" command
C->>SM: start_server()
SM->>UT: check_environment()
UT-->>SM: Environment OK
SM->>D: is_docker_installed() & start_docker()
D-->>SM: Docker ready
SM->>D: check_postgres()
D-->>SM: Postgres available
SM->>SM: run_migrations(), run_server(), run_celery()
SM-->>C: Server running
C-->>U: Display success message
Poem
I'm a bunny in the code meadow, hopping through lines so bright,
With new CLI commands and tests, I bring structure and delight.
Server magic and API tricks, all woven into a neat array,
Logs and migrations in every hop, guiding the project’s way.
Happy hops and bytes galore—coding is an egg-cellent day! 🐇💻
✨ 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?
🪧 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR. (Beta)@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere in the PR title to generate the title automatically.
CodeRabbit Configuration File (.coderabbit.yaml)
- You can programmatically configure CodeRabbit by adding a
.coderabbit.yamlfile 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.
@dhirenmathur I think there is some error, is it internal or fine let me know.
#224
@DeepeshKalura can we simplify :
python -m app.poitre parse <repository_path> --branch <branch_name>
to something like
potpie parse <repository_path> --branch <branch_name>
@DeepeshKalura can we simplify :
python -m app.poitre parse <repository_path> --branch <branch_name>to something like
potpie parse <repository_path> --branch <branch_name>
@dhirenmathur There are multiple ways to create a CLI tool in Python, each with its own advantages and trade-offs.
1. Bash Script Wrapper (Simplest Approach) One easy way to create a CLI is by writing a simple bash script that wraps around your Python module. This method works but is not the standard way to build Python CLIs today, has issue with the different scripts like cmd, powershell bash, fish and zsh we have confiure all.
Therfore, CLIs are not created like that.
2. setuptools (setup.py) – The Old Way (2005-2010) In older Python packaging workflows (Python 2.x era), setuptools was widely used to create CLI tools. It would generate a wheel file (.whl), which could be installed and executed globall
this still works i think but now people use prefer pyproject.toml instead.
3. Modern Approach – pyproject.toml (Recommended Today) Today, Python projects use pyproject.toml instead of setup.py. This is the official standard for packaging and defining CLI tools.
Yeah in this approach we generally don't have requirement.txt file but we can work with both
@dhirenmathur Since you didn’t respond in a timely manner, I will proceed with managing this aspect accordingly.
For reference, you can review the official documentation on Python packaging:
🔗 [Python Packaging Guide](https://packaging.python.org/en/latest/tutorials/packaging-projects/)
Key Issue:
You intend to use potpie, which requires a wheel or another Python package format. However, your source code lacks proper package management, which is necessary for building and installing the package correctly.
Next Steps:
Since you hadn’t previously mentioned the need for a package but require it now, I want to confirm the approach. I am opting for Option 3, which involves:
- Creating a structured Python package with sub-modularity for CLI.
- Setting up a dedicated CLI folder with its own
.venvenvironment. - Treating the CLI as a separate project to ensure better maintainability.
Thanks @DeepeshKalura third option sounds good.
@dhirenmathur I thoroughly checked the CLI, and I think it's good to go.
Documentation
This docs helps developer to setup cli tool asap
Setting Up the Development Environment
1. Create a Virtual Environment
Before installing dependencies, create a virtual environment:
python -m venv venv
Activate the virtual environment:
- On macOS/Linux:
source venv/bin/activate - On Windows:
venv\Scripts\activate
2. Install Dependencies
Install the package in editable mode along with development dependencies:
pip install -e .[dev]
3. Build the Package
Once dependencies are installed, build the package:
python -m build
4. Install the CLI tool in a Core Package Place
After building the package, install it:
pip install cli/dist/python-package
5. Using the Package in Docs and Examples
You can now import and use the package in your documentation and examples:
potpie start
@nndn can you review this PR please
Hi @DeepeshKalura , thank you so much for your efforts on this PR, but currently we have decided to not go ahead with the CLI, so I will be closing this PR. It was fun working with you on this! Thank you again.
