8000 fix: run hooks when no_poll is True by ocervell · Pull Request #686 · freelabz/secator · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: run hooks when no_poll is True #686

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

Merged
merged 1 commit into from
Jun 6, 2025
Merged

fix: run hooks when no_poll is True #686

merged 1 commit into from
Jun 6, 2025

Conversation

ocervell
Copy link
Contributor
@ocervell ocervell commented Jun 6, 2025

Summary by CodeRabbit

  • New Features

    • Task configuration details now include a description, proxy-related options, and command fields, providing richer metadata for each task.
  • Bug Fixes

    • Improved logic for enabling hooks during task execution, ensuring hooks are enabled based on updated criteria.

Copy link
Contributor
coderabbitai bot commented Jun 6, 2025

Walkthrough

The updates enhance task configuration metadata in the loader by including additional descriptive and proxy-related fields. In the runner base, the logic controlling the activation of hooks is adjusted to no longer depend on the no_poll flag, affecting when hooks are enabled during runner initialization.

Changes

File(s) Change Summary
secator/loader.py Expanded task configuration dictionaries with description, proxy flags, and command attributes.
secator/runners/_base.py Modified Runner initialization logic to decouple enable_hooks from the no_poll flag.

Poem

In loader fields, new tales unfold,
With proxies, docs, and commands bold.
The runner now, with hooks anew,
Ignores the poll, as rabbits do.
Code hops ahead, both fast and neat—
These little tweaks make tasks complete!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this 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.

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.

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.

@ocervell ocervell merged commit 32e8dba into main Jun 6, 2025
8 of 9 checks passed
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: 1

🧹 Nitpick comments (1)
secator/loader.py (1)

43-43: Consider handling cases where docstring is None.

While most classes should have docstrings, it's safer to handle cases where cls.__doc__ might be None.

-			'description': cls.__doc__,
+			'description': cls.__doc__ or '',
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8b8cafb and 2fb14ce.

📒 Files selected for processing (2)
  • secator/loader.py (1 hunks)
  • secator/runners/_base.py (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
secator/loader.py (2)
secator/template.py (1)
  • TemplateLoader (11-55)
secator/output_types/_base.py (1)
  • get_name (97-98)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: integration (3.11, ubuntu-latest)
  • GitHub Check: Analyze (python)
🔇 Additional comments (1)
secator/loader.py (1)

40-51: LGTM! Enhanced task metadata provides useful configuration details.

The addition of task description, proxy configuration flags, and command attributes enriches the task configuration metadata. The use of getattr() with sensible defaults (True for proxy flags) is appropriate for handling optional class attributes.

@@ -132,7 +132,7 @@ def __init__(self, config, inputs=[], results=[], run_opts={}, hooks={}, validat
self.enable_duplicate_check = self.run_opts.get('enable_duplicate_check', True)
self.enable_profiles = self.run_opts.get('enable_profiles', True)
self.enable_reports = self.run_opts.get('enable_reports', not self.sync) and not self.dry_run and not self.no_process and not self.no_poll # noqa: E501
self.enable_hooks = self.run_opts.get('enable_hooks', True) and not self.dry_run and not self.no_process and not self.no_poll # noqa: E501
self.enable_hooks = self.run_opts.get('enable_hooks', True) and not self.dry_run and not self.no_process # noqa: E501
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Verify the logical consistency with the no_process flag.

While this change correctly removes the direct dependency on no_poll for hook enablement, there may still be an indirect dependency. When no_poll=True, the yielder() method sets no_process=True (lines 703-706), which would still disable hooks due to the and not self.no_process condition here and additional checks in the run_hooks() method (lines 769-783).

Please run the following script to verify the hook execution behavior when no_poll=True:


🏁 Script executed:

#!/bin/bash
# Description: Verify hook execution logic when no_poll is True

# Search for all places where no_process affects hook execution
echo "=== Hook enabling logic ==="
rg -A 3 -B 3 "enable_hooks.*no_process"

echo -e "\n=== Hook execution checks ==="
rg -A 5 -B 2 "no_process.*hook"

echo -e "\n=== Where no_process gets set based on no_poll ==="
rg -A 3 -B 3 "no_process.*=.*True"

Length of output: 6245


Ensure hooks aren’t disabled by no_process when no_poll=True

We verified that although the direct no_poll check was removed from enable_hooks, the yielder() method still sets self.no_process = True when no_poll=True, and both the enable_hooks flag (line 135) and the run_hooks() skip logic (lines 769–783) honor no_process, effectively preventing hooks from running.

Please update the no_poll branch in secator/runners/_base.py to stop setting no_process and only disable reports:

--- a/secator/runners/_base.py
@@ 703,8 +703,7 @@ class BaseRunner:
         # Runner process options
         self.no_poll = self.run_opts.get('no_poll', False)
         self.no_process = not self.run_opts.get('process', True)
@@ -703,8 +703,7 @@ class BaseRunner:
         elif isinstance(item, str):
             # …
 
-        if self.no_poll:
-            self.enable_reports = False
-            self.no_process = True
-            return
+        if self.no_poll:
+            self.enable_reports = False
+            return

This will allow hooks to run under no_poll=True as intended.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
self.enable_hooks = self.run_opts.get('enable_hooks', True) and not self.dry_run and not self.no_process # noqa: E501
# Runner process options
self.no_poll = self.run_opts.get('no_poll', False)
self.no_process = not self.run_opts.get('process', True)
if self.no_poll:
self.enable_reports = False
return
🤖 Prompt for AI Agents
In secator/runners/_base.py at line 135, the enable_hooks flag is set to False
when no_process is True, but no_process is currently set to True in the
yielder() method when no_poll=True, which unintentionally disables hooks. To fix
this, modify the no_poll branch in the yielder() method (around lines 703-706)
to stop setting self.no_process = True and instead only disable reports. This
change will ensure that hooks are not disabled when no_poll=True, allowing them
to run as intended while still disabling reports.

ocervell added a commit that referenced this pull request Jun 6, 2025
🤖 I have created a release *beep* *boop*
---


##
[0.16.2](v0.16.1...v0.16.2)
(2025-06-06)


### Bug Fixes

* run hooks when no_poll is True
([#686](#686))
([32e8dba](32e8dba))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **Documentation**
- Added a changelog entry for version 0.16.2, documenting a bug fix
related to hook execution with the `no_poll` flag.
- **Chores**
  - Updated the project version to 0.16.2.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
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
0