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

refactor(agent): unify treatment of output and other events #332

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

boukeas
Copy link
Contributor

@boukeas boukeas commented Aug 16, 2024

Description

Even though there is currently only a single event (output) that can be subscribed to on CommandRunner, there are two different methods for subscribing:

  • a generic subscribe_event method for registering handlers for events
  • a specific register_output_handler method for registering handlers for output events

Likewise, there are two different methods for notifying the handlers that an event has taken place:

  • a generic post_event method for events
  • a specific post_output method for output events

This PR unifies the treatment of output events and general events, i.e. output events are treated no differently than any other event. This makes the CommandRunner interface slimmer and more consistent but also allows for extensibility when additional event types might be added. Event handlers are still callables but now expect the event as their argument (carrying all necessary information to handle the event, e.g. the output, within the passed argument).

Resolved issues

This PR is not linked to a specific issue.

Documentation

No changes required to the documentation.

Web service API changes

No changes to the Web service API

Tests

All existing tests are still passing (following a couple of minor modifications to reflect the PR changes). No additional functionality has been added and hence no additional tests have been introduced.

@boukeas boukeas requested review from val500 and plars August 16, 2024 12:15
Copy link
Contributor

@nadzyah nadzyah left a comment

Choose a reason for hiding this comment

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

sorry, just a small nitpick

self.stop_condition_checkers: List[StopConditionType] = []
self.process: Optional[subprocess.Popen] = None
self.cwd = cwd
self.env = os.environ.copy()
# a mapping of event names to lists of registered event handlers
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
# a mapping of event names to lists of registered event handlers
# A mapping of event names to lists of registered event handlers

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