Skip to content

Post Action Plugin Infrastructure - #277

Open
amd-benprice wants to merge 7 commits into
developmentfrom
ben_post_actions
Open

Post Action Plugin Infrastructure#277
amd-benprice wants to merge 7 commits into
developmentfrom
ben_post_actions

Conversation

@amd-benprice

@amd-benprice amd-benprice commented Aug 31, 2026

Copy link
Copy Markdown
Collaborator

Summary

This PR adds post-actions, which is a method of running more plugins based on the granular results of prior plugins. Post actions can be specified only through the plugin configuration JSON file. The README is updated with the specific semantics of how post actions can be configured. Any plugin can be used as a post-action plugin. This PR also adds unit tests for post actions, and updates one existing unit test.

This PR also contains a bugfix that prevented OS detection during remote execution. The fix was to not make a pydantic model copy of system_info in pluginexecutor.py, and instead use the pre-existing instance of the model. The copy would be update with the correct OS family, but the original, which was then passed to the plugins themselves, was not updated, which caused all plugins to not run.

Test plan

  • pytest test/unit
  • pytest test/functional (if applicable)
  • pre-commit run --all-files

Checklist

  • Added/updated tests (or explained why not)
  • Updated docs/README if behavior changed
  • No secrets or credentials committed

@amd-benprice amd-benprice self-assigned this Aug 31, 2026
@github-actions github-actions Bot added documentation Improvements or additions to documentation tests framework labels Aug 31, 2026

@alexandraBara alexandraBara left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Couple things to consider:

  1. currently nothing prevents the same plugin from appearing twice in post actions with diff conditions
  2. PluginConfig.merge() drops post-actions in pluginrecipe.py. What do we do with this? do we allow postconditions in recipes?
  3. This merges post_actions_plugins: PluginExecutor.merge_configs() but this one does not: PluginConfig.merge() (recipes)

#
# MIT License
#
# Copyright (c) 2025 Advanced Micro Devices, Inc.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

new files must have 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 3cc2d56 and b845a9d

"""If set, only inspect the PluginResult whose ``source`` matches this name.
If None, all results are candidates."""

status: Optional[str] = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this type should be ExecutionStatus

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 3cc2d56

Accepts any :class:`~nodescraper.enums.ExecutionStatus` name
(e.g. ``"WARNING"``, ``"ERROR"``, ``"EXECUTION_FAILURE"``)."""

event_category: Optional[str] = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

this should also be EventPriority not str

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Assuming you meant event_priority with this comment, which is fixed in 3cc2d56

"""If set, only inspect the PluginResult whose ``source`` matches this name.
If None, all results are candidates."""

status: Optional[str] = None

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Suggested change
status: Optional[str] = None
status: Optional[ExecutionStatus] = None

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 3cc2d56

Comment on lines +94 to +106
def _matches_result(self, result: PluginResult) -> bool:
"""Return True if *result* satisfies all specified fields (AND logic).

Each field that is not None must be satisfied; unset fields are skipped.
"""
# --- status check ---
if self.status is not None:
try:
status_threshold = ExecutionStatus[self.status.upper()]
except KeyError:
return False
if result.status < status_threshold:
return False

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

once the correct type is set for status this function can probably just be:

Suggested change
def _matches_result(self, result: PluginResult) -> bool:
"""Return True if *result* satisfies all specified fields (AND logic).
Each field that is not None must be satisfied; unset fields are skipped.
"""
# --- status check ---
if self.status is not None:
try:
status_threshold = ExecutionStatus[self.status.upper()]
except KeyError:
return False
if result.status < status_threshold:
return False
def _matches_result(self, result: PluginResult) -> bool:
"""Return True if *result* satisfies all specified fields (AND logic).
if self.status is not None and result.status < self.status:
return False

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 3cc2d56

Comment thread test/unit/framework/test_post_action_condition.py
event_description_contains: Optional[str] = None
"""If set, at least one event's description must contain this substring
(case-sensitive)."""

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Once the types are fixed, i recommend you add these too:

    @field_validator("status", mode="before")
    @classmethod
    def _coerce_status(cls, v):
        # mirror TaskResult.validate_status
        ...
    @field_validator("event_priority", mode="before")
    @classmethod
    def _coerce_priority(cls, v):
        # mirror Event.validate_priority (or import shared helper)
        ...

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 3cc2d56

}
"""

plugin: str

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

i think this needs a @field_validator to sanitize input like "" or " ". Maybe something like:

@field_validator("plugin")
@classmethod
def _strip_and_require_plugin(cls, v: str) -> str:
    v = v.strip()
    if not v:
        raise ValueError("plugin name must not be empty")
    return v

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 3cc2d56

Comment thread nodescraper/models/postactionpluginconfig.py
@amd-benprice

Copy link
Copy Markdown
Collaborator Author

Couple things to consider:

  1. currently nothing prevents the same plugin from appearing twice in post actions with diff conditions
  2. PluginConfig.merge() drops post-actions in pluginrecipe.py. What do we do with this? do we allow postconditions in recipes?
  3. This merges post_actions_plugins: PluginExecutor.merge_configs() but this one does not: PluginConfig.merge() (recipes)

For 1, I think this is fine, since users could also just specify the same plugin multiple times in their config with different args, so I think this fits that same usage model.

For 2+3, post actions should be allowed in recipes in my opinion, and I have made the changes you suggested to allow for this, and added some tests in 3cc2d56

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation framework tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants