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

feat: add CLI #1560

Merged
merged 3 commits into from
Jan 30, 2025
Merged

feat: add CLI #1560

merged 3 commits into from
Jan 30, 2025

Conversation

gventuri
Copy link
Collaborator

@gventuri gventuri commented Jan 29, 2025

Important

Introduces a new CLI for dataset management with commands for creating, pulling, pushing datasets, and API key login, along with comprehensive tests.

  • CLI Features:
    • Introduces a new CLI in pandasai/cli/main.py with commands: create, login, pull, and push.
    • create: Guides user to create a dataset, validates path, and saves schema.
    • login: Validates API key format and updates .env file.
    • pull and push: Load and transfer datasets using DatasetLoader.
  • Validation:
    • Adds validate_api_key() to check API key format.
    • Adds get_validated_dataset_path() to validate dataset paths.
  • Testing:
    • Adds tests/test_cli.py to test CLI commands and validation functions.
    • Tests include valid and invalid scenarios for API key and dataset path validation.
  • Configuration:
    • Updates pyproject.toml to include CLI entry point under [tool.poetry.scripts].

This description was created by Ellipsis for bc94a0b. It will automatically update as commits are pushed.

Copy link

codecov bot commented Jan 29, 2025

Codecov Report

Attention: Patch coverage is 95.31250% with 3 lines in your changes missing coverage. Please review.

Project coverage is 82.18%. Comparing base (99cd23f) to head (ce3c617).

Files with missing lines Patch % Lines
pandasai/cli/main.py 95.31% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1560      +/-   ##
==========================================
+ Coverage   81.81%   82.18%   +0.36%     
==========================================
  Files          63       64       +1     
  Lines        2321     2385      +64     
==========================================
+ Hits         1899     1960      +61     
- Misses        422      425       +3     
Flag Coverage Δ
unittests 82.18% <95.31%> (+0.36%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

❌ Changes requested. Reviewed everything up to ff3c0f1 in 1 minute and 46 seconds

More details
  • Looked at 336 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 10 drafted comments based on config settings.
1. pandasai/cli/__init__.py:1
  • Draft comment:
    Add a newline at the end of the file.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The code is missing a newline at the end of the file, which is a common best practice for text files.
2. tests/unit/cli/__init__.py:1
  • Draft comment:
    Add a newline at the end of the file.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The code is missing a newline at the end of the file, which is a common best practice for text files.
3. pandasai/cli/main.py:142
  • Draft comment:
    Add a newline at the end of the file.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The code is missing a newline at the end of the file, which is a common best practice for text files.
4. tests/unit/cli/test_main.py:154
  • Draft comment:
    Add a newline at the end of the file.
  • Reason this comment was not posted:
    Confidence changes required: 10%
    The code is missing a newline at the end of the file, which is a common best practice for text files.
5. pandasai/cli/main.py:18
  • Draft comment:
    Error messages should be more user-friendly and consistent. Consider rephrasing to:
raise ValueError("The path must be in the format: organization/dataset.")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error messages in the code are clear and concise, but they can be improved for better clarity and consistency. Additionally, the error messages should be formatted to be more user-friendly.
6. pandasai/cli/main.py:25
  • Draft comment:
    Error messages should be more user-friendly and consistent. Consider rephrasing to:
raise ValueError("The organization name must be lowercase and can include hyphens.")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error messages in the code are clear and concise, but they can be improved for better clarity and consistency. Additionally, the error messages should be formatted to be more user-friendly.
7. pandasai/cli/main.py:27
  • Draft comment:
    Error messages should be more user-friendly and consistent. Consider rephrasing to:
raise ValueError("The dataset name must be lowercase and can include hyphens.")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error messages in the code are clear and concise, but they can be improved for better clarity and consistency. Additionally, the error messages should be formatted to be more user-friendly.
8. pandasai/cli/main.py:66
  • Draft comment:
    Error messages should be more user-friendly and consistent. Consider rephrasing to:
click.echo(f"❌ Error: A dataset already exists at the path: {path}.")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error messages in the code are clear and concise, but they can be improved for better clarity and consistency. Additionally, the error messages should be formatted to be more user-friendly.
9. pandasai/cli/main.py:124
  • Draft comment:
    Error messages should be more user-friendly and consistent. Consider rephrasing to:
click.echo(f"❌ Error: Failed to pull dataset: {str(e)}")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error messages in the code are clear and concise, but they can be improved for better clarity and consistency. Additionally, the error messages should be formatted to be more user-friendly.
10. pandasai/cli/main.py:138
  • Draft comment:
    Error messages should be more user-friendly and consistent. Consider rephrasing to:
click.echo(f"❌ Error: Failed to push dataset: {str(e)}")
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The error messages in the code are clear and concise, but they can be improved for better clarity and consistency. Additionally, the error messages should be formatted to be more user-friendly.

Workflow ID: wflow_5hVKFbeDX0r8vsIE


Want Ellipsis to fix these issues? Tag @ellipsis-dev in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on cd31539 in 14 seconds

More details
  • Looked at 31 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. pandasai/cli/main.py:12
  • Draft comment:
    Since get_validated_dataset_path has been moved to a different module, ensure that the documentation and tests are updated to reflect this change.
  • Reason this comment was not posted:
    Comment did not seem useful.

Workflow ID: wflow_mjPtqYxSYU2cd6o2


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on ce3c617 in 34 seconds

More details
  • Looked at 30 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 2 drafted comments based on config settings.
1. pandasai/cli/main.py:12
  • Draft comment:
    The import of get_validated_dataset_path is correct and simplifies the code by removing the redundant function definition.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The import statement for get_validated_dataset_path was moved from its original location to be imported directly from pandasai.helpers.path. This change is correct as it simplifies the code by removing the redundant function definition in this file.
2. pandasai/cli/main.py:12
  • Draft comment:
    Since get_validated_dataset_path has been moved to a different module, ensure that the documentation and tests are updated to reflect this change.
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    Since this is a library code change (moving a function to a different module), checking for updated documentation and tests is important per the additional rules. However, the comment is phrased as "ensure that..." which violates the base rules about not asking for verification. Additionally, we can't see the destination file or tests, so we can't verify if documentation/tests were already updated.
    I might be too strict about the "ensure that" phrasing rule. The underlying concern about documentation and tests for moved library code is valid.
    While the concern is valid, the comment's phrasing makes it non-actionable, and without seeing the destination file, we can't verify if this is already handled.
    Delete the comment because it's phrased as a verification request and we lack context to verify if documentation/tests were already updated.

Workflow ID: wflow_v4FIO7jM8h28qrpA


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a comment

Choose a reason for hiding this comment

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

👍 Looks good to me! Incremental review on bc94a0b in 49 seconds

More details
  • Looked at 175 lines of code in 3 files
  • Skipped 0 files when reviewing.
  • Skipped posting 4 drafted comments based on config settings.
1. pandasai/cli/main.py:18
  • Draft comment:
    Consider compiling the regex pattern outside the function for better performance if this function is called frequently.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The validate_api_key function uses a regular expression to validate the API key format. This is a common practice and seems correct based on the pattern provided.
2. pandasai/cli/main.py:127
  • Draft comment:
    Consider adding exception handling for file operations to prevent crashes if file access fails.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The login command writes to a .env file. It's important to ensure that file operations handle potential exceptions.
3. tests/test_cli.py:39
  • Draft comment:
    Consider adding a check to verify that the .env file is created with secure permissions.
  • Reason this comment was not posted:
    Confidence changes required: 33%
    The test for the login command checks for a successful message but does not verify if the file permissions are secure.
4. pandasai/cli/main.py:108
  • Draft comment:
    The error message can be improved for clarity and conciseness.
            "❌ Invalid API key format. Expected: PAI-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
  • Reason this comment was not posted:
    Decided after close inspection that this draft comment was likely wrong and/or not actionable:
    The suggestion removes the word "format" which makes the message slightly more concise without losing meaning. However, the improvement is very minor and doesn't significantly impact usability or understanding. The existing message is already clear and well-formatted.
    The current message is already clear and professional. The suggested change is so minor it may not be worth the effort of changing.
    While the suggestion is valid, it falls into the category of being too minor to warrant a comment.
    Delete this comment as it suggests an extremely minor wording change that doesn't significantly improve the user experience or code quality.

Workflow ID: wflow_mTI1FmDmoABcrZxS


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@gventuri gventuri merged commit 58e6f5b into main Jan 30, 2025
1 check passed
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