Skip to content

Commit

Permalink
cEP-0030: Next Generation Action System
Browse files Browse the repository at this point in the history
Closes #181
  • Loading branch information
akshatkarani committed May 11, 2019
1 parent 93c7cce commit d39d989
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions cEP-0030.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Next Generation Action System

| Metadata | |
| -------- | -----------------------------------------------|
| cEP | 30 |
| Version | 1.0 |
| Title | Next Generation Action System |
| Authors | Akshat Karani <mailto: [email protected]> |
| Status | Proposed |
| Type | Process |

# Abstract

This cEP describes the details about Next Generation Action System which
will allow bears to define their own actions as a part of [GSoC'19 project].(https: // summerofcode.withgoogle.com / projects / # 5450946933424128)

# Introduction

Bears run some analysis and output is in form of a `Result` object. Then some action from a predefined set of actions is applied to that `Result` object. This system is a bit restrictive as action from predefined set of actions can be taken. If there is a system which will support bears defining their own actions, then it will make bears more useful.
This project is about changing the current action system so that bears can define their own actions. This involves changing the current `Result` class and also modifying the existing action classes.

# Implementation

## Changing the `Result` class

1. The first step is to change the Result class so that it facilitates bears defining their own actions. A new attribute `applicable_actions` is added to Result class. This is a list of all the actions applicable to this Result object.
2. The `__init__` method of `Result` class is also changed so the when bears yield a result, a list of bear specific actions can be passed. Then in `__init__` method we can add applicable actions from bear specific action and predefined actions to `Result.applicable_actions`.

```python
class Result:
def __init__(actions=[], ..):
self.applicable_actions=[]
for action in actions:
if action.is_applicable():
self.applicable_actions.append(action)
for action in cli_actions:
if action(..).is_applicable():
self.applicable_actions.append(action)
```

## Modifying the existing action classes

Currently, we need to pass Result object as an argument for methods of Action classes and Action classes access attributes of that Result object. Now that we are defining action objects inside a result object, action are modified. `__init__` method is added to all the action classes and while instantiating necessary arguments are passed. Then the methods of action objects are changed accordingly.

0 comments on commit d39d989

Please sign in to comment.