-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(plugins): add support for importing other modules within a plugin (
#180)
- Loading branch information
1 parent
2ea51da
commit ac077fe
Showing
40 changed files
with
802 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
29 changes: 29 additions & 0 deletions
29
plugin_runner/tests/fixtures/plugins/example_plugin/CANVAS_MANIFEST.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"sdk_version": "0.1.4", | ||
"plugin_version": "0.0.1", | ||
"name": "example_plugin", | ||
"description": "Edit the description in CANVAS_MANIFEST.json", | ||
"components": { | ||
"protocols": [ | ||
{ | ||
"class": "example_plugin.protocols.my_protocol:Protocol", | ||
"description": "A protocol that does xyz...", | ||
"data_access": { | ||
"event": "", | ||
"read": [], | ||
"write": [] | ||
} | ||
} | ||
], | ||
"commands": [], | ||
"content": [], | ||
"effects": [], | ||
"views": [] | ||
}, | ||
"secrets": [], | ||
"tags": {}, | ||
"references": [], | ||
"license": "", | ||
"diagram": false, | ||
"readme": "./README.md" | ||
} |
12 changes: 12 additions & 0 deletions
12
plugin_runner/tests/fixtures/plugins/example_plugin/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
============== | ||
example_plugin | ||
============== | ||
|
||
## Description | ||
|
||
A description of this plugin | ||
|
||
### Important Note! | ||
|
||
The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it | ||
gets updated if you add, remove, or rename protocols. |
Empty file.
Empty file.
18 changes: 18 additions & 0 deletions
18
plugin_runner/tests/fixtures/plugins/example_plugin/protocols/my_protocol.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
from canvas_sdk.effects import Effect, EffectType | ||
from canvas_sdk.events import EventType | ||
from canvas_sdk.protocols import BaseProtocol | ||
|
||
|
||
class Protocol(BaseProtocol): | ||
""" | ||
You should put a helpful description of this protocol's behavior here. | ||
""" | ||
|
||
# Name the event type you wish to run in response to | ||
RESPONDS_TO = EventType.Name(EventType.UNKNOWN) | ||
|
||
NARRATIVE_STRING = "I was inserted from my plugin's protocol." | ||
|
||
def compute(self) -> list[Effect]: | ||
"""This method gets called when an event of the type RESPONDS_TO is fired.""" | ||
return [Effect(type=EffectType.LOG, payload="Hello, world!")] |
29 changes: 29 additions & 0 deletions
29
..._runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/CANVAS_MANIFEST.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ | ||
"sdk_version": "0.1.4", | ||
"plugin_version": "0.0.1", | ||
"name": "test_module_imports_outside_plugin_v1", | ||
"description": "Edit the description in CANVAS_MANIFEST.json", | ||
"components": { | ||
"protocols": [ | ||
{ | ||
"class": "test_module_imports_outside_plugin_v1.protocols.my_protocol:Protocol", | ||
"description": "A protocol that does xyz...", | ||
"data_access": { | ||
"event": "", | ||
"read": [], | ||
"write": [] | ||
} | ||
} | ||
], | ||
"commands": [], | ||
"content": [], | ||
"effects": [], | ||
"views": [] | ||
}, | ||
"secrets": [], | ||
"tags": {}, | ||
"references": [], | ||
"license": "", | ||
"diagram": false, | ||
"readme": "./README.md" | ||
} |
12 changes: 12 additions & 0 deletions
12
...n_runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
========================== | ||
test_module_imports_outside_plugin_v1 | ||
========================== | ||
|
||
## Description | ||
|
||
A description of this plugin | ||
|
||
### Important Note! | ||
|
||
The CANVAS_MANIFEST.json is used when installing your plugin. Please ensure it | ||
gets updated if you add, remove, or rename protocols. |
Empty file.
3 changes: 3 additions & 0 deletions
3
..._runner/tests/fixtures/plugins/test_module_imports_outside_plugin_v1/other_module/base.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
def import_me() -> str: | ||
"""Test method.""" | ||
return "Successfully imported!" |
Empty file.
Oops, something went wrong.