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 command line interface #72

Merged
merged 7 commits into from
Jul 14, 2024
Merged

feat: add command line interface #72

merged 7 commits into from
Jul 14, 2024

Conversation

njzjz
Copy link
Member

@njzjz njzjz commented Jul 14, 2024

Summary by CodeRabbit

  • New Features

    • Introduced a command-line interface (CLI) for argument checking in Python programs.
    • Added a script entry point for the CLI in project configuration.
    • Enhanced documentation with a new section on CLI usage.
  • Bug Fixes

    • Updated type annotations and added default arguments to improve the robustness of the check function.
  • Documentation

    • Added CLI module documentation.
    • Updated module references for better documentation rendering.
  • Tests

    • Added test cases to validate the new CLI functionality.
    • Introduced new unit tests for CLI command verification.

Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Copy link
Contributor

coderabbitai bot commented Jul 14, 2024

Walkthrough

Walkthrough

The changes introduce enhancements to the dargs package, including type annotations, new default arguments, and improved handling in the check function. A command-line interface (CLI) is added, along with corresponding documentation and tests. Additionally, the package configuration and Sphinx documentation are updated to support these new features and dependencies.

Changes

Files Change Summaries
dargs/check.py Updated check function with type annotations, new default arguments, and enhanced docstring.
dargs/cli.py Introduced CLI functions (main_parser, main, and check_cli) for argument checking.
dargs/sphinx.py Removed _test_arguments function.
pyproject.toml Added dargs script under [project.scripts].
docs/cli.rst, docs/index.rst Added new documentation for CLI and updated index.
docs/requirements.txt Added sphinx-argparse dependency.
docs/sphinx.rst Updated module and function references from dargs.sphinx to dargs._test.
docs/conf.py Added "sphinxarg.ext" extension to Sphinx configuration.
tests/test_arguments.json Introduced new JSON file with test cases.
tests/test_cli.py Added unit tests for CLI functionality.

Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between a8d538c and 4eda21a.

Files selected for processing (2)
  • dargs/cli.py (1 hunks)
  • tests/test_cli.py (1 hunks)
Additional context used
GitHub Check: codecov/patch
dargs/cli.py

[warning] 1-1: dargs/cli.py#L1
Added line #L1 was not covered by tests


[warning] 3-6: dargs/cli.py#L3-L6
Added lines #L3 - L6 were not covered by tests


[warning] 8-9: dargs/cli.py#L8-L9
Added lines #L8 - L9 were not covered by tests


[warning] 12-12: dargs/cli.py#L12
Added line #L12 was not covered by tests


[warning] 20-20: dargs/cli.py#L20
Added line #L20 was not covered by tests


[warning] 23-24: dargs/cli.py#L23-L24
Added lines #L23 - L24 were not covered by tests


[warning] 29-29: dargs/cli.py#L29
Added line #L29 was not covered by tests


[warning] 36-36: dargs/cli.py#L36
Added line #L36 was not covered by tests


[warning] 43-43: dargs/cli.py#L43
Added line #L43 was not covered by tests


[warning] 49-49: dargs/cli.py#L49
Added line #L49 was not covered by tests


[warning] 55-55: dargs/cli.py#L55
Added line #L55 was not covered by tests


[warning] 58-59: dargs/cli.py#L58-L59
Added lines #L58 - L59 were not covered by tests


[warning] 62-62: dargs/cli.py#L62
Added line #L62 was not covered by tests


[warning] 64-65: dargs/cli.py#L64-L65
Added lines #L64 - L65 were not covered by tests


[warning] 67-67: dargs/cli.py#L67
Added line #L67 was not covered by tests


[warning] 70-70: dargs/cli.py#L70
Added line #L70 was not covered by tests


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

codecov bot commented Jul 14, 2024

Codecov Report

Attention: Patch coverage is 0% with 54 lines in your changes missing coverage. Please review.

Project coverage is 78.49%. Comparing base (5f73f2b) to head (4eda21a).
Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
dargs/cli.py 0.00% 35 Missing ⚠️
dargs/check.py 0.00% 8 Missing ⚠️
dargs/_test.py 0.00% 6 Missing ⚠️
dargs/__main__.py 0.00% 4 Missing ⚠️
dargs/sphinx.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master      #72      +/-   ##
==========================================
- Coverage   84.15%   78.49%   -5.67%     
==========================================
  Files           5        9       +4     
  Lines         707      758      +51     
==========================================
  Hits          595      595              
- Misses        112      163      +51     

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

pre-commit-ci bot and others added 2 commits July 14, 2024 04:52
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
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: 3

dargs/cli.py Outdated Show resolved Hide resolved
dargs/cli.py Outdated Show resolved Hide resolved
njzjz added 2 commits July 14, 2024 01:01
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
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: 3

dargs/cli.py Outdated Show resolved Hide resolved
dargs/cli.py Outdated Show resolved Hide resolved
njzjz added 2 commits July 14, 2024 03:21
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
Signed-off-by: Jinzhe Zeng <jinzhe.zeng@rutgers.edu>
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: 3

Outside diff range, codebase verification and nitpick comments (2)
tests/test_cli.py (2)

12-22: Enhance test coverage by verifying command output.

Currently, the test only checks if the command runs without errors. It would be more comprehensive to verify the output of the command.

+        result = subprocess.run(
+            [
+                "dargs",
+                "check",
+                "-f",
+                "dargs._test.test_arguments",
+                str(this_directory / "test_arguments.json"),
+                str(this_directory / "test_arguments.json"),
+            ],
+            capture_output=True,
+            text=True
+        )
+        self.assertIn("expected_output", result.stdout)

12-44: Improve robustness by handling potential exceptions.

Consider adding exception handling to make the test more robust.

+        try:
+            subprocess.check_call(
+                [
+                    "dargs",
+                    "check",
+                    "-f",
+                    "dargs._test.test_arguments",
+                    str(this_directory / "test_arguments.json"),
+                    str(this_directory / "test_arguments.json"),
+                ]
+            )
+        except subprocess.CalledProcessError as e:
+            self.fail(f"subprocess.check_call failed with {e}")

dargs/cli.py Show resolved Hide resolved
dargs/cli.py Show resolved Hide resolved
dargs/cli.py Show resolved Hide resolved
@njzjz njzjz merged commit 17e7d61 into deepmodeling:master Jul 14, 2024
7 checks 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.

1 participant