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

Event history refactor #71

Merged
merged 11 commits into from
Jul 12, 2024
Merged

Event history refactor #71

merged 11 commits into from
Jul 12, 2024

Conversation

eriktaubeneck
Copy link
Member

@eriktaubeneck eriktaubeneck commented Jul 10, 2024

this moves all the status related elements into it's own directory, and adds tests for those elements.

currently set up to compare against #70 , so review that first, and make sure to change the base before merging.

Summary by CodeRabbit

  • New Features

    • Introduced StatusHistory for improved tracking and management of query statuses.
    • Added status history management and status enums to enhance query processing.
  • Bug Fixes

    • Adjusted import paths for Status to ensure consistency across different modules.
  • Chores

    • Updated .gitignore to exclude .coverage* files.
    • Configured pre-commit hooks to include pytest and coverage tools.
  • Tests

    • Added comprehensive test cases for the StatusHistory class to ensure reliable functionality.

Copy link

vercel bot commented Jul 10, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
draft ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 12, 2024 11:04pm

Copy link
Contributor

coderabbitai bot commented Jul 10, 2024

Warning

Rate limit exceeded

@eriktaubeneck has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 44 seconds before requesting another review.

How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

Commits

Files that changed from the base of the PR and between 7f6e5a7 and 9328cde.

Walkthrough

This update brings substantive improvements to the sidecar application, focusing on enhancing status tracking and unit testing. Key changes include converting the Query class to use a new StatusHistory mechanism, updating import paths, introducing pytest and coverage tools in the pre-commit configuration, and expanding .gitignore to include coverage files. Additionally, new tests for StatusHistory ensure robust status management.

Changes

File(s) Summary
.github/workflows/pre-commit.yaml Changed dependency installation to use editable mode (pip install -e .).
.gitignore Added .coverage* to ignore coverage-related files.
.pre-commit-config.yaml Added configurations for pytest and coverage. Modified pyre-check to include a fail-under threshold.
.pyre_configuration Updated source_directories to a dictionary format with import_root and source keys.
pyproject.toml Added pytest and pytest-cov dependencies. Updated pylint and pytest configurations.
sidecar/app/query/base.py Major revision of Query class for status handling using StatusHistory.
sidecar/app/query/status.py Introduced new file for managing status history with Status, StatusChangeEvent, and StatusHistory classes.
sidecar/app/query/step.py Removed local Status enum and imported it from the new status.py.
sidecar/app/routes/start.py Updated import path for Status to the new status.py.
sidecar/app/routes/stop.py Updated import path for Status to the new status.py.
sidecar/app/routes/websockets.py Updated import path for Status to the new status.py.
sidecar/cli/cli.py Updated import paths for Command, start_commands_parallel, and Role.
sidecar/tests/app/query/test_status.py Introduced new test file with multiple tests for the StatusHistory class.

Poem

In the code where queries dance,
Status now takes a stronger stance.
With histories clear and tests to boot,
Bugs and errors we shall root.
Editable installs and coverage files,
Make our work worthwhile with smiles.
Hip-hop, sidecar, on your way,
Stronger and better every day! 🚀🐇


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
Collaborator

Choose a reason for hiding this comment

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

do we need this empty file?

Copy link
Member Author

Choose a reason for hiding this comment

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

@eriktaubeneck
Copy link
Member Author

well this is fun. pre-commit working locally but not on GH. I'll debug

@eriktaubeneck eriktaubeneck mentioned this pull request Jul 11, 2024
Base automatically changed from status-events to main July 12, 2024 22:48
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

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8b6b38d and 7f6e5a7.

Files selected for processing (13)
  • .github/workflows/pre-commit.yaml (1 hunks)
  • .gitignore (1 hunks)
  • .pre-commit-config.yaml (1 hunks)
  • .pyre_configuration (1 hunks)
  • pyproject.toml (2 hunks)
  • sidecar/app/query/base.py (7 hunks)
  • sidecar/app/query/status.py (1 hunks)
  • sidecar/app/query/step.py (1 hunks)
  • sidecar/app/routes/start.py (1 hunks)
  • sidecar/app/routes/stop.py (1 hunks)
  • sidecar/app/routes/websockets.py (1 hunks)
  • sidecar/cli/cli.py (1 hunks)
  • sidecar/tests/app/query/test_status.py (1 hunks)
Files skipped from review due to trivial changes (7)
  • .github/workflows/pre-commit.yaml
  • .gitignore
  • pyproject.toml
  • sidecar/app/routes/start.py
  • sidecar/app/routes/stop.py
  • sidecar/app/routes/websockets.py
  • sidecar/cli/cli.py
Additional comments not posted (31)
.pyre_configuration (1)

4-4: LGTM!

The modification of source_directories to a dictionary format is correct and aligns with the JSON structure.

.pre-commit-config.yaml (3)

22-28: Additions for pytest configuration look good.

The configuration for pytest is correctly added and will enhance testing.


29-35: Additions for coverage configuration look good.

The configuration for coverage is correctly added and will enhance coverage reporting.


35-35: Verify the pyre-check configuration.

Ensure that the modified pyre-check configuration works as expected.

sidecar/app/query/step.py (1)

11-11: LGTM!

The import statement for Status is correct and aligns with the refactoring.

sidecar/app/query/status.py (1)

1-83: LGTM!

The new functionality for managing status history is well-structured and aligns with the refactoring objectives.

However, ensure that the logic for adding status and managing status history works as expected.

sidecar/tests/app/query/test_status.py (10)

10-17: Fixture setup looks good.

The _status_history_fixture correctly sets up a StatusHistory instance with a temporary file path and a logger.


20-33: Fixture setup looks good.

The _full_status_history_fixture correctly sets up a StatusHistory instance with a sequence of status events.


36-46: Test function looks good.

The test_status_history_add function correctly tests adding status events and verifies the current status event.


49-55: Test function looks good.

The test_status_history_add_write_to_file function correctly tests writing status events to a file and verifies the file contents.


57-63: Test function looks good.

The test_status_history_add_load_from_file function correctly tests loading status events from a file and verifies the loaded StatusHistory instance.


65-69: Test function looks good.

The test_status_history_cannot_add_when_locked function correctly tests that status events cannot be added when the StatusHistory instance is locked.


71-80: Test function looks good.

The test_status_history_cannot_add_lower_status function correctly tests that lower status events cannot be added to the StatusHistory instance.


82-85: Test function looks good.

The test_status_history_current_status_event function correctly tests retrieving the current status event from the StatusHistory instance.


88-89: Test function looks good.

The test_status_history_current_status function correctly tests retrieving the current status from the StatusHistory instance.


92-115: Test function looks good.

The test_status_history_status_event_json function correctly tests retrieving the status event in JSON format from the StatusHistory instance.

sidecar/app/query/base.py (15)

33-42: Method implementation looks good.

The __post_init__ method correctly initializes the StatusHistory instance, creates status directories, and sets up logging.


55-57: Property implementation looks good.

The _log_dir property correctly returns the path to the log directory.


64-65: Property implementation looks good.

The started property correctly checks the status to determine if the query has started.


68-69: Property implementation looks good.

The finished property correctly checks the status to determine if the query has finished.


90-90: Property implementation looks good.

The status property correctly retrieves the current status from the StatusHistory instance.


94-95: Setter implementation looks good.

The status setter correctly adds a new status to the StatusHistory instance if the status has changed and is less than or equal to Status.COMPLETE.


97-99: Property implementation looks good.

The status_event_json property correctly retrieves the status event in JSON format from the StatusHistory instance.


111-112: Property implementation looks good.

The steps property correctly yields steps built from the query.


Line range hint 114-127:
Method implementation looks good.

The start method correctly initiates the steps, handles exceptions, and updates the status.


Line range hint 129-135:
Method implementation looks good.

The finish method correctly updates the status to Status.COMPLETE, logs the completion, and performs cleanup.


142-146: Method implementation looks good.

The kill method correctly updates the status to Status.KILLED, logs the termination, and performs cleanup.


150-154: Method implementation looks good.

The crash method correctly updates the status to Status.CRASHED, logs the crash, and performs cleanup.


156-162: Method implementation looks good.

The _cleanup method correctly resets the current step, removes the logger, and deletes the query from the dictionary.

Tools
Ruff

159-162: Use contextlib.suppress(ValueError) instead of try-except-pass

Replace with contextlib.suppress(ValueError)

(SIM105)


164-166: Property implementation looks good.

The cpu_usage_percent property correctly retrieves the CPU usage percentage from the current step.


Line range hint 168-170:
Property implementation looks good.

The memory_rss_usage property correctly retrieves the memory RSS usage from the current step.

Tools
Ruff

159-162: Use contextlib.suppress(ValueError) instead of try-except-pass

Replace with contextlib.suppress(ValueError)

(SIM105)

@eriktaubeneck eriktaubeneck merged commit 771b88e into main Jul 12, 2024
3 checks passed
@eriktaubeneck eriktaubeneck deleted the event-history-refactor branch July 12, 2024 23:09
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.

2 participants