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:delayed_padatious_training #29

Merged
merged 6 commits into from
Dec 9, 2024
Merged

feat:delayed_padatious_training #29

merged 6 commits into from
Dec 9, 2024

Conversation

JarbasAl
Copy link
Member

@JarbasAl JarbasAl commented Dec 9, 2024

add config option to train after skills loaded, not on every skill

Summary by CodeRabbit

  • New Features

    • Enhanced thread safety for the training process.
    • Improved logging for training operations, including insights on training data.
    • New methods for intent and entity registration, as well as handling detachments.
  • Bug Fixes

    • Adjusted logic to ensure accurate completion messaging after training.
  • Deprecations

    • Marked the padatious_config property as deprecated with a warning for direct access.
    • Added warnings for deprecated parameters in the training process.

Copy link

coderabbitai bot commented Dec 9, 2024

Warning

Rate limit exceeded

@JarbasAl has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 5 minutes and 7 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

Reviewing files that changed from the base of the PR and between 1f7c6cc and b64e591.

📒 Files selected for processing (2)
  • ovos_padatious/opm.py (5 hunks)
  • ovos_padatious/training_manager.py (2 hunks)

Walkthrough

The changes in this pull request focus on enhancing the PadatiousPipeline and PadatiousMatcher classes within the ovos_padatious/opm.py file. Key modifications include the introduction of thread safety through an RLock, improvements to logging during the training process, and updates to method signatures. Several new methods have been added to handle intent registration and management. The padatious_config property has been deprecated, encouraging direct access to configuration settings.

Changes

File Change Summary
ovos_padatious/opm.py - Added RLock for thread safety in PadatiousPipeline.
- Updated train method for debug logging and thread safety.
- Simplified internal logic of train method.
- Modified register_intent to reset finished_initial_train flag.
- Deprecated padatious_config with a warning.
- Added multiple new methods for intent and entity management, including __detach_intent, handle_detach_intent, register_intent, and others.
ovos_padatious/simple_intent.py - Removed explicit inheritance from object in SimpleIntent class.
- Added logging for positive and negative sample counts in train method.
ovos_padatious/training_manager.py - Enhanced logging in add method for intent loading.
- Added warnings for deprecated parameters in train method.

Possibly related PRs

  • feat/opm_pipeline #2: The changes in the PadatiousPipeline class, including updates to the train method and the addition of new methods, are directly related to the modifications made in the same class in the main PR.
  • std lang codes #13: The updates to the register_intent and calc_intent methods in the PadatiousPipeline class in both PRs indicate a direct relationship, as they involve similar modifications to method signatures and logic.
  • drop threading #19: The removal of threading in the train method in the IntentContainer class aligns with the main PR's focus on enhancing thread safety in the PadatiousPipeline class's training process.
  • fix:expand #26: The emphasis on retraining intents when loading from cache in this PR complements the main PR's updates to the train method in the PadatiousPipeline, which also focuses on ensuring proper training logic.

Suggested labels

breaking

🐇 In the pipeline where intents reside,
A lock was added, side by side.
With logs that sing of training's start,
We simplify, we play our part.
Deprecated paths now take a bow,
In Padatious, we flourish now! 🌟


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>, 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 @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 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 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 generate docstrings to generate docstrings for this PR. (Experiment)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration 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.

@github-actions github-actions bot added feature and removed feature labels Dec 9, 2024
Copy link

@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: 1

🧹 Outside diff range and nitpick comments (2)
ovos_padatious/opm.py (2)

195-195: Remove unnecessary f prefix in log message

The log message on line 195 does not contain any placeholders, so the f prefix is unnecessary.

Apply this diff to remove the extraneous f:

-    LOG.debug(f"Nothing new to train for padatious")
+    LOG.debug("Nothing new to train for padatious")
🧰 Tools
🪛 Ruff (0.8.0)

195-195: f-string without any placeholders

Remove extraneous f prefix

(F541)


206-206: Remove unnecessary f prefix in log message

The log message on line 206 does not require an f prefix as it contains no placeholders.

Apply this diff to correct the log statement:

-    LOG.debug(f"Training complete for padatious!")
+    LOG.debug("Training complete for padatious!")
🧰 Tools
🪛 Ruff (0.8.0)

206-206: f-string without any placeholders

Remove extraneous f prefix

(F541)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between e901fc8 and 86ee30e.

📒 Files selected for processing (1)
  • ovos_padatious/opm.py (5 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
ovos_padatious/opm.py

195-195: f-string without any placeholders

Remove extraneous f prefix

(F541)


206-206: f-string without any placeholders

Remove extraneous f prefix

(F541)

🔇 Additional comments (4)
ovos_padatious/opm.py (4)

18-18: Importing RLock for thread safety

The addition of RLock from the threading module is appropriate for ensuring thread-safe operations during training.


93-93: Initializing self.lock with RLock

Initializing self.lock = RLock() ensures that access to shared resources is thread-safe within the PadatiousPipeline class.


124-124: Registering the 'padatious:train' event handler

Adding the event handler for 'padatious:train' allows the system to trigger training externally, which enhances flexibility.


200-208: Ensuring thread-safe training with self.lock

Wrapping the training loop with self.lock ensures that the training process is thread-safe, preventing potential race conditions.

🧰 Tools
🪛 Ruff (0.8.0)

206-206: f-string without any placeholders

Remove extraneous f prefix

(F541)

ovos_padatious/opm.py Show resolved Hide resolved
@github-actions github-actions bot added feature and removed feature labels Dec 9, 2024
Copy link

@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: 1

🧹 Outside diff range and nitpick comments (1)
ovos_padatious/training_manager.py (1)

Line range hint 1-150: Architecture feedback on training optimization

The changes effectively support delayed training by:

  1. Adding comprehensive logging throughout the training pipeline
  2. Maintaining backward compatibility while deprecating single-threaded parameters
  3. Preserving core training logic while improving visibility

Consider adding structured logging with additional metadata (e.g., training duration, model size) to facilitate monitoring and debugging in production environments.

🧰 Tools
🪛 Ruff (0.8.0)

93-93: Do not use bare except

(E722)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 86ee30e and 1f7c6cc.

📒 Files selected for processing (2)
  • ovos_padatious/simple_intent.py (4 hunks)
  • ovos_padatious/training_manager.py (2 hunks)
🧰 Additional context used
🪛 Ruff (0.8.0)
ovos_padatious/training_manager.py

93-93: Do not use bare except

(E722)

🔇 Additional comments (3)
ovos_padatious/simple_intent.py (2)

29-29: LGTM: Modern Python class definition

The removal of explicit object inheritance aligns with Python 3 conventions.


72-74: LGTM: Enhanced training visibility with debug logging

The addition of sample counting and debug logging provides valuable insights into the training process:

  • Tracks positive and negative training samples
  • Logs training start and completion

Also applies to: 121-121, 128-128

ovos_padatious/training_manager.py (1)

76-76: LGTM: Improved debugging visibility

The added debug logging statements provide clear visibility into the intent loading and training process:

  • Loading from cache
  • Queuing for training

Also applies to: 91-91, 97-97

ovos_padatious/training_manager.py Outdated Show resolved Hide resolved
JarbasAl and others added 2 commits December 9, 2024 18:34
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@@ -264,7 +270,9 @@ def _register_object(self, message, object_name, register_func):

register_func(name, samples)

self.train(message)
self.finished_initial_train = False
if self.config.get("instant_train", True):
Copy link
Member Author

@JarbasAl JarbasAl Dec 9, 2024

Choose a reason for hiding this comment

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

for backwards compat, but we might want to consider changing this default value in next breaking change release, this impacts thread safety and should likely be False

@coderabbitai open an issue

@JarbasAl JarbasAl merged commit c95686e into dev Dec 9, 2024
4 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Dec 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant