-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
319 additions
and
40 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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
============= | ||
Class Example | ||
============= | ||
|
||
.. code-block:: python | ||
from time import sleep | ||
from collegamento import FileClient, Request | ||
class MyClient: | ||
def __init__(self): | ||
self.context = FileClient({"MyClientFunc": self.split_str}) | ||
self.context.update_file("user_file", "") | ||
def change_file(self, new_contents: str) -> None: | ||
self.context.update_file("user_file", new_contents) | ||
def request_split(self) -> None: | ||
self.context.request({"command": "MyClientFunc", "file": "user_file"}) | ||
def check_split(self) -> list[str] | None: | ||
output = self.context.get_response("MyClientFunc") | ||
if output is not None: | ||
return output["result"] # type: ignore | ||
return output | ||
def split_str(self, arg: Request) -> list[str]: | ||
file = arg["file"] # type: ignore | ||
return file.split(" ") | ||
def main(): | ||
mc = MyClient() | ||
mc.change_file("Test File") | ||
mc.request_split() | ||
sleep(1) | ||
output = mc.check_split() | ||
print(output) | ||
if __name__ == "__main__": | ||
main() | ||
See the file example file `here <https://github.com/salve-org/albero/blob/master/examples/class_example.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,35 @@ | ||
============ | ||
File Example | ||
============ | ||
|
||
.. code-block:: python | ||
from time import sleep | ||
from collegamento import USER_FUNCTION, FileClient, Request, Response | ||
def split_str(arg: Request) -> list[str]: | ||
file = arg["file"] # type: ignore | ||
return file.split(" ") | ||
def main(): | ||
commands: dict[str, USER_FUNCTION] = {"test": split_str} | ||
context = FileClient(commands) | ||
context.update_file("test", "test contents") | ||
context.request({"command": "test", "file": "test"}) | ||
sleep(1) | ||
output: Response | None = context.get_response("test") | ||
print(output) | ||
context.kill_IPC() | ||
if __name__ == "__main__": | ||
main() | ||
See the file example file `here <https://github.com/salve-org/albero/blob/master/examples/file_example.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,37 @@ | ||
============== | ||
Simple Example | ||
============== | ||
|
||
.. code-block:: python | ||
from time import sleep | ||
from collegamento import USER_FUNCTION, Request, Response, SimpleClient | ||
def foo(bar: Request) -> bool: | ||
if bar["command"] == "test": | ||
return True | ||
return False | ||
def main(): | ||
commands: dict[str, USER_FUNCTION] = {"test": foo} | ||
context = SimpleClient(commands) | ||
context.request({"command": "test"}) | ||
sleep(1) | ||
output: Response | None = context.get_response("test") | ||
if output is not None and output["result"] == True: # type: ignore | ||
print("Yippee! It worked!") | ||
else: | ||
print("Aww, maybe your compute is just a little slow?") | ||
context.kill_IPC() | ||
if __name__ == "__main__": | ||
main() | ||
See the file example file `here <https://github.com/salve-org/albero/blob/master/examples/simple_example.py>`_. |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.