-
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.
fix: reloading relative imports on plugin updates
- Loading branch information
1 parent
5c4be8f
commit cb55577
Showing
16 changed files
with
284 additions
and
51 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
29 changes: 29 additions & 0 deletions
29
...n_runner/tests/fixtures/plugins/test_module_forbidden_imports_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": "test_module_forbidden_imports_plugin", | ||
"description": "Edit the description in CANVAS_MANIFEST.json", | ||
"components": { | ||
"protocols": [ | ||
{ | ||
"class": "test_module_forbidden_imports_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
...in_runner/tests/fixtures/plugins/test_module_forbidden_imports_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 @@ | ||
========================== | ||
test_module_forbidden_imports_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.
10 changes: 10 additions & 0 deletions
10
...n_runner/tests/fixtures/plugins/test_module_forbidden_imports_plugin/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,10 @@ | ||
import os | ||
|
||
from logger import log | ||
|
||
log.info(f"This is a forbidden import. {os}") | ||
|
||
|
||
def import_me() -> str: | ||
"""Test method.""" | ||
return "Successfully imported!" |
Empty file.
18 changes: 18 additions & 0 deletions
18
...nner/tests/fixtures/plugins/test_module_forbidden_imports_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 test_module_forbidden_imports_plugin.other_module.base import import_me | ||
|
||
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) | ||
|
||
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=import_me())] |
29 changes: 29 additions & 0 deletions
29
.../tests/fixtures/plugins/test_module_forbidden_imports_runtime_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": "test_module_forbidden_imports_runtime_plugin", | ||
"description": "Edit the description in CANVAS_MANIFEST.json", | ||
"components": { | ||
"protocols": [ | ||
{ | ||
"class": "test_module_forbidden_imports_runtime_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
...r/tests/fixtures/plugins/test_module_forbidden_imports_runtime_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 @@ | ||
========================== | ||
test_module_forbidden_imports_runtime_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.
10 changes: 10 additions & 0 deletions
10
.../tests/fixtures/plugins/test_module_forbidden_imports_runtime_plugin/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,10 @@ | ||
import os | ||
|
||
from logger import log | ||
|
||
log.info(f"This is a forbidden import. {os}") | ||
|
||
|
||
def import_me() -> str: | ||
"""Test method.""" | ||
return "Successfully imported!" |
Empty file.
18 changes: 18 additions & 0 deletions
18
...ts/fixtures/plugins/test_module_forbidden_imports_runtime_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) | ||
|
||
def compute(self) -> list[Effect]: | ||
"""This method gets called when an event of the type RESPONDS_TO is fired.""" | ||
from test_module_forbidden_imports_runtime_plugin.other_module.base import import_me | ||
|
||
return [Effect(type=EffectType.LOG, payload=import_me())] |
Oops, something went wrong.