amesa-cli 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. amesa_cli-0.1.0/MANIFEST.in +6 -0
  2. amesa_cli-0.1.0/PKG-INFO +49 -0
  3. amesa_cli-0.1.0/README.md +27 -0
  4. amesa_cli-0.1.0/amesa_cli/template/agent_amesa/agent.py +90 -0
  5. amesa_cli-0.1.0/amesa_cli/template/agent_docker/agent.py +99 -0
  6. amesa_cli-0.1.0/amesa_cli/template/agent_local/agent.py +96 -0
  7. amesa_cli-0.1.0/amesa_cli/template/perceptor/README.md +67 -0
  8. amesa_cli-0.1.0/amesa_cli/template/perceptor/pyproject.toml +15 -0
  9. amesa_cli-0.1.0/amesa_cli/template/perceptor/{{NAME_MODULE}}/__init__.py +3 -0
  10. amesa_cli-0.1.0/amesa_cli/template/perceptor/{{NAME_MODULE}}/perceptor.py +34 -0
  11. amesa_cli-0.1.0/amesa_cli/template/selector_controller/README.md +67 -0
  12. amesa_cli-0.1.0/amesa_cli/template/selector_controller/pyproject.toml +12 -0
  13. amesa_cli-0.1.0/amesa_cli/template/selector_controller/{{NAME_MODULE}}/__init__.py +3 -0
  14. amesa_cli-0.1.0/amesa_cli/template/selector_controller/{{NAME_MODULE}}/controller.py +52 -0
  15. amesa_cli-0.1.0/amesa_cli/template/selector_teacher/README.md +67 -0
  16. amesa_cli-0.1.0/amesa_cli/template/selector_teacher/pyproject.toml +12 -0
  17. amesa_cli-0.1.0/amesa_cli/template/selector_teacher/{{NAME_MODULE}}/__init__.py +3 -0
  18. amesa_cli-0.1.0/amesa_cli/template/selector_teacher/{{NAME_MODULE}}/teacher.py +70 -0
  19. amesa_cli-0.1.0/amesa_cli/template/sim/README.md +39 -0
  20. amesa_cli-0.1.0/amesa_cli/template/sim/pyproject.toml +20 -0
  21. amesa_cli-0.1.0/amesa_cli/template/sim/{{NAME_MODULE}}/__init__.py +3 -0
  22. amesa_cli-0.1.0/amesa_cli/template/sim/{{NAME_MODULE}}/sim.py +253 -0
  23. amesa_cli-0.1.0/amesa_cli/template/sim/{{NAME_MODULE}}/sim_impl.py +115 -0
  24. amesa_cli-0.1.0/amesa_cli/template/sim_docker/Dockerfile +45 -0
  25. amesa_cli-0.1.0/amesa_cli/template/sim_docker/README.md +17 -0
  26. amesa_cli-0.1.0/amesa_cli/template/sim_docker/docker/sim-start.sh +14 -0
  27. amesa_cli-0.1.0/amesa_cli/template/sim_docker/main.py +55 -0
  28. amesa_cli-0.1.0/amesa_cli/template/sim_docker/module/README.md +39 -0
  29. amesa_cli-0.1.0/amesa_cli/template/sim_docker/module/pyproject.toml +20 -0
  30. amesa_cli-0.1.0/amesa_cli/template/sim_docker/module/{{NAME_MODULE}}/__init__.py +3 -0
  31. amesa_cli-0.1.0/amesa_cli/template/sim_docker/module/{{NAME_MODULE}}/sim.py +253 -0
  32. amesa_cli-0.1.0/amesa_cli/template/sim_docker/module/{{NAME_MODULE}}/sim_impl.py +115 -0
  33. amesa_cli-0.1.0/amesa_cli/template/skill_controller/README.md +67 -0
  34. amesa_cli-0.1.0/amesa_cli/template/skill_controller/pyproject.toml +12 -0
  35. amesa_cli-0.1.0/amesa_cli/template/skill_controller/{{NAME_MODULE}}/__init__.py +3 -0
  36. amesa_cli-0.1.0/amesa_cli/template/skill_controller/{{NAME_MODULE}}/controller.py +40 -0
  37. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_population/README.md +67 -0
  38. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_population/pyproject.toml +12 -0
  39. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_population/{{NAME_MODULE}}/__init__.py +3 -0
  40. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_population/{{NAME_MODULE}}/coach.py +70 -0
  41. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_set/README.md +67 -0
  42. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_set/pyproject.toml +12 -0
  43. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_set/{{NAME_MODULE}}/__init__.py +3 -0
  44. amesa_cli-0.1.0/amesa_cli/template/skill_coordinated_set/{{NAME_MODULE}}/coach.py +70 -0
  45. amesa_cli-0.1.0/amesa_cli/template/skill_teacher/README.md +67 -0
  46. amesa_cli-0.1.0/amesa_cli/template/skill_teacher/pyproject.toml +12 -0
  47. amesa_cli-0.1.0/amesa_cli/template/skill_teacher/{{NAME_MODULE}}/__init__.py +3 -0
  48. amesa_cli-0.1.0/amesa_cli/template/skill_teacher/{{NAME_MODULE}}/teacher.py +70 -0
  49. amesa_cli-0.1.0/amesa_cli.egg-info/PKG-INFO +49 -0
  50. amesa_cli-0.1.0/amesa_cli.egg-info/SOURCES.txt +74 -0
  51. amesa_cli-0.1.0/amesa_cli.egg-info/dependency_links.txt +1 -0
  52. amesa_cli-0.1.0/amesa_cli.egg-info/entry_points.txt +2 -0
  53. amesa_cli-0.1.0/amesa_cli.egg-info/requires.txt +11 -0
  54. amesa_cli-0.1.0/amesa_cli.egg-info/top_level.txt +1 -0
  55. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/__init__.c +4967 -0
  56. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli.c +8336 -0
  57. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_agent.c +12155 -0
  58. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_benchmark.c +9862 -0
  59. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_debug.c +8653 -0
  60. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_historian.c +10805 -0
  61. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_job.c +16388 -0
  62. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_main.c +13995 -0
  63. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_perceptor.c +14946 -0
  64. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_selector.c +15354 -0
  65. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_sim.c +27114 -0
  66. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_skill.c +15342 -0
  67. amesa_cli-0.1.0/dist/build_cython/amesa_cli/cli/cli_version.c +8649 -0
  68. amesa_cli-0.1.0/dist/build_cython/amesa_cli/k8s/k8s_train.c +13749 -0
  69. amesa_cli-0.1.0/dist/build_cython/amesa_cli/k8s/util.c +8368 -0
  70. amesa_cli-0.1.0/dist/build_cython/amesa_cli/main/agent.c +8664 -0
  71. amesa_cli-0.1.0/dist/build_cython/amesa_cli/main/perceptor.c +11939 -0
  72. amesa_cli-0.1.0/dist/build_cython/amesa_cli/main/selector.c +12266 -0
  73. amesa_cli-0.1.0/dist/build_cython/amesa_cli/main/sim.c +11905 -0
  74. amesa_cli-0.1.0/dist/build_cython/amesa_cli/main/skill.c +12336 -0
  75. amesa_cli-0.1.0/pyproject.toml +116 -0
  76. amesa_cli-0.1.0/setup.cfg +4 -0
@@ -0,0 +1,6 @@
1
+ global-exclude *.py
2
+
3
+ recursive-include amesa_cli/template *.toml
4
+ recursive-include amesa_cli/template *.md
5
+ recursive-include amesa_cli/template *.sh
6
+ recursive-include amesa_cli/template *
@@ -0,0 +1,49 @@
1
+ Metadata-Version: 2.4
2
+ Name: amesa-cli
3
+ Version: 0.1.0
4
+ Summary: the Amesa CLI
5
+ Author-email: Hunter Park <hunter@amesa.com>
6
+ Requires-Python: >=3.10, <3.13
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: typer[all]==0.11.0
9
+ Requires-Dist: click<8.2.0
10
+ Requires-Dist: cython
11
+ Requires-Dist: docker
12
+ Requires-Dist: kubernetes
13
+ Requires-Dist: jinja2
14
+ Requires-Dist: amesa-core>=0.1.0
15
+ Requires-Dist: amesa-train>=0.1.0
16
+ Requires-Dist: amesa-api>=0.1.0
17
+ Requires-Dist: ruff
18
+ Requires-Dist: simple-term-menu
19
+ Dynamic: description
20
+ Dynamic: description-content-type
21
+ Dynamic: requires-python
22
+
23
+ # Amesa
24
+
25
+ Amesa helps you build Autonomous Agents! Through an easy SDK you get access to outscaled simulator training tools.
26
+
27
+ ## Licenses / Seats
28
+
29
+ Amesa is an enterprise platform and requires an API key to use.
30
+
31
+ We offer 3 types of licenses:
32
+
33
+ - **Enterprise:** for enterprise projects and agent creations
34
+ - **Personal:** for personal usage and testing (typically offered to System Integrators)
35
+ - **Trial:** validate the Amesa platform (requires sales contact person)
36
+
37
+ One key is needed per user (seat-based licensing)
38
+
39
+ You can request an API Key through the following methods:
40
+
41
+ - [Discord](https://discord.gg/EQ3BgJt9NC)
42
+ - [Mail](mailto:sales@amesa.com?subject=REQUEST%20API%20KEY%20-%20COMPANY_NAME%20-%20NAME&body=Hi%2C%0D%0A%0D%0AI%20would%20like%20to%20request%20an%20API%20key%20for%20my%20company%20to%20get%20started%20with%20Amesa.%0D%0A%0D%0A*%20Company%20Name%3A%20COMPANY_NAME%0D%0A*%20Seats%3A%20NO_OF_SEATS%0D%0A*%20License%20Type%3A%20Enterprise%20%7C%20Personal%20%7C%20Trial%20%28keep%20what%20is%20required%29%0D%0A%0D%0AKind%20Regards%2C%0D%0ANAME%0D%0AFUNCTION)
43
+
44
+ ## Getting Started
45
+
46
+ 1. Download the Amesa SDK: `pip install amesa`
47
+ 2. Request an API Key
48
+ 3. Get a simulator or use one of the [prebuilt ones](https://hub.docker.com/u/amesa)
49
+ 4. Create an Agent or see our [examples](https://github.com/Amesa/examples.amesa.com)
@@ -0,0 +1,27 @@
1
+ # Amesa
2
+
3
+ Amesa helps you build Autonomous Agents! Through an easy SDK you get access to outscaled simulator training tools.
4
+
5
+ ## Licenses / Seats
6
+
7
+ Amesa is an enterprise platform and requires an API key to use.
8
+
9
+ We offer 3 types of licenses:
10
+
11
+ - **Enterprise:** for enterprise projects and agent creations
12
+ - **Personal:** for personal usage and testing (typically offered to System Integrators)
13
+ - **Trial:** validate the Amesa platform (requires sales contact person)
14
+
15
+ One key is needed per user (seat-based licensing)
16
+
17
+ You can request an API Key through the following methods:
18
+
19
+ - [Discord](https://discord.gg/EQ3BgJt9NC)
20
+ - [Mail](mailto:sales@amesa.com?subject=REQUEST%20API%20KEY%20-%20COMPANY_NAME%20-%20NAME&body=Hi%2C%0D%0A%0D%0AI%20would%20like%20to%20request%20an%20API%20key%20for%20my%20company%20to%20get%20started%20with%20Amesa.%0D%0A%0D%0A*%20Company%20Name%3A%20COMPANY_NAME%0D%0A*%20Seats%3A%20NO_OF_SEATS%0D%0A*%20License%20Type%3A%20Enterprise%20%7C%20Personal%20%7C%20Trial%20%28keep%20what%20is%20required%29%0D%0A%0D%0AKind%20Regards%2C%0D%0ANAME%0D%0AFUNCTION)
21
+
22
+ ## Getting Started
23
+
24
+ 1. Download the Amesa SDK: `pip install amesa`
25
+ 2. Request an API Key
26
+ 3. Get a simulator or use one of the [prebuilt ones](https://hub.docker.com/u/amesa)
27
+ 4. Create an Agent or see our [examples](https://github.com/Amesa/examples.amesa.com)
@@ -0,0 +1,90 @@
1
+ # Copyright (C) Amesa, Inc - All Rights Reserved
2
+ # Unauthorized copying of this file, via any medium is strictly prohibited
3
+ # Proprietary and confidential
4
+
5
+ import os
6
+ from typing import Dict
7
+
8
+ from amesa import Agent, MaintainGoal, Sensor, Skill, Trainer
9
+
10
+ # Accept the EULA
11
+ os.environ["AMESA_EULA_AGREED"] = "1"
12
+
13
+ # Set the license
14
+ # os.environ["AMESA_LICENSE"] = "YOUR_LICENSE_KEY"
15
+
16
+
17
+ class BalanceTeacher(MaintainGoal):
18
+ def __init__(self, *args, **kwargs):
19
+ super().__init__(
20
+ "pole_theta", "Maintain pole to upright", target=0, stop_distance=0.418
21
+ )
22
+
23
+ # defaults the BL and BR
24
+
25
+ async def compute_action_mask(self, transformed_sensors: Dict, action):
26
+ # Cartpole might not use an action mask, so this can return None
27
+ return None
28
+
29
+ async def transform_sensors(self, sensors, action):
30
+ # For Cartpole, might just return sensors directly
31
+ return sensors
32
+
33
+ async def transform_action(self, transformed_sensors: Dict, action):
34
+ # No transformation needed for discrete action space
35
+ return action
36
+
37
+ async def filtered_sensor_space(self):
38
+ # Return relevant sensors
39
+ return ["cart_pos", "cart_vel", "pole_theta", "pole_alpha"]
40
+
41
+
42
+ def main():
43
+ # Create the agent
44
+ a = Agent()
45
+
46
+ # https://gymnasium.farama.org/environments/classic_control/cart_pole/#observation-space
47
+ a.add_sensors(
48
+ [
49
+ Sensor(
50
+ "cart_pos",
51
+ "The Cart Position between [-4.8, 4.8]",
52
+ lambda sensors: sensors[0],
53
+ ),
54
+ Sensor(
55
+ "cart_vel",
56
+ "The Cart Position between [-inf, inf]",
57
+ lambda sensors: sensors[1],
58
+ ),
59
+ Sensor(
60
+ "pole_theta",
61
+ "The Pole Angle [-0.418 rad, 0.418 rad]",
62
+ lambda sensors: sensors[2],
63
+ ),
64
+ Sensor(
65
+ "pole_alpha",
66
+ "The Pole Angular Velocity [-inf, inf]",
67
+ lambda sensors: sensors[3],
68
+ ),
69
+ ]
70
+ )
71
+
72
+ skill = Skill("pole-balance", BalanceTeacher)
73
+ a.add_skill(skill)
74
+
75
+ # Create trainer and train the agent
76
+ r = Trainer(
77
+ {
78
+ "target": {"amesa"},
79
+ "resources": {
80
+ "sim_count": 2,
81
+ },
82
+ }
83
+ )
84
+
85
+ r.train(a, train_cycles=5)
86
+ r.close()
87
+
88
+
89
+ if __name__ == "__main__":
90
+ main()
@@ -0,0 +1,99 @@
1
+ # Copyright (C) Amesa, Inc - All Rights Reserved
2
+ # Unauthorized copying of this file, via any medium is strictly prohibited
3
+ # Proprietary and confidential
4
+
5
+ import os
6
+ from typing import Dict
7
+
8
+ from amesa import Agent, MaintainGoal, Sensor, Skill, Trainer
9
+
10
+ # Accept the EULA
11
+ os.environ["AMESA_EULA_AGREED"] = "1"
12
+
13
+ # Set the license
14
+ # os.environ["AMESA_LICENSE"] = "YOUR_LICENSE_KEY"
15
+
16
+
17
+ class BalanceTeacher(MaintainGoal):
18
+ def __init__(self, *args, **kwargs):
19
+ super().__init__(
20
+ "pole_theta", "Maintain pole to upright", target=0, stop_distance=0.418
21
+ )
22
+
23
+ # defaults the BL and BR
24
+
25
+ async def compute_action_mask(self, transformed_sensors: Dict, action):
26
+ # Cartpole might not use an action mask, so this can return None
27
+ return None
28
+
29
+ async def transform_sensors(self, sensors, action):
30
+ # For Cartpole, might just return sensors directly
31
+ return sensors
32
+
33
+ async def transform_action(self, transformed_sensors: Dict, action):
34
+ # No transformation needed for discrete action space
35
+ return action
36
+
37
+ async def filtered_sensor_space(self):
38
+ # Return relevant sensors
39
+ return ["cart_pos", "cart_vel", "pole_theta", "pole_alpha"]
40
+
41
+
42
+ def main():
43
+ # Create the agent
44
+ a = Agent()
45
+
46
+ # https://gymnasium.farama.org/environments/classic_control/cart_pole/#observation-space
47
+ a.add_sensors(
48
+ [
49
+ Sensor(
50
+ "cart_pos",
51
+ "The Cart Position between [-4.8, 4.8]",
52
+ lambda sensors: sensors[0],
53
+ ),
54
+ Sensor(
55
+ "cart_vel",
56
+ "The Cart Position between [-inf, inf]",
57
+ lambda sensors: sensors[1],
58
+ ),
59
+ Sensor(
60
+ "pole_theta",
61
+ "The Pole Angle [-0.418 rad, 0.418 rad]",
62
+ lambda sensors: sensors[2],
63
+ ),
64
+ Sensor(
65
+ "pole_alpha",
66
+ "The Pole Angular Velocity [-inf, inf]",
67
+ lambda sensors: sensors[3],
68
+ ),
69
+ ]
70
+ )
71
+
72
+ skill = Skill("pole-balance", BalanceTeacher)
73
+ a.add_skill(skill)
74
+
75
+ # Create trainer and train the agent
76
+ r = Trainer(
77
+ {
78
+ "target": {"docker": {"image": "amesa/sim-cartpole-dev:latest"}},
79
+ "resources": {
80
+ "sim_count": 2,
81
+ },
82
+ "post_processing": {
83
+ "record": {
84
+ "is_enabled": True,
85
+ "file_path": "/tmp/amesa/recordings",
86
+ "avi_file_name": "output.avi",
87
+ "gif_file_name": "output.gif",
88
+ "max_frames": 24 * 5,
89
+ },
90
+ },
91
+ }
92
+ )
93
+
94
+ r.train(a, train_cycles=5)
95
+ r.close()
96
+
97
+
98
+ if __name__ == "__main__":
99
+ main()
@@ -0,0 +1,96 @@
1
+ # Copyright (C) Amesa, Inc - All Rights Reserved
2
+ # Unauthorized copying of this file, via any medium is strictly prohibited
3
+ # Proprietary and confidential
4
+
5
+ import os
6
+ from typing import Dict
7
+
8
+ from amesa import Agent, MaintainGoal, Sensor, Skill, Trainer
9
+
10
+ # Accept the EULA
11
+ os.environ["AMESA_EULA_AGREED"] = "1"
12
+
13
+ # Set the license
14
+ # os.environ["AMESA_LICENSE"] = "YOUR_LICENSE_KEY"
15
+
16
+
17
+ class BalanceTeacher(MaintainGoal):
18
+ def __init__(self, *args, **kwargs):
19
+ super().__init__(
20
+ "pole_theta", "Maintain pole to upright", target=0, stop_distance=0.418
21
+ )
22
+
23
+ # defaults the BL and BR
24
+
25
+ async def compute_action_mask(self, transformed_sensors: Dict, action):
26
+ # Cartpole might not use an action mask, so this can return None
27
+ return None
28
+
29
+ async def transform_sensors(self, sensors, action):
30
+ # For Cartpole, might just return sensors directly
31
+ return sensors
32
+
33
+ async def transform_action(self, transformed_sensors: Dict, action):
34
+ # No transformation needed for discrete action space
35
+ return action
36
+
37
+ async def filtered_sensor_space(self):
38
+ # Return relevant sensors
39
+ return ["cart_pos", "cart_vel", "pole_theta", "pole_alpha"]
40
+
41
+
42
+ def main():
43
+ # Create the agent
44
+ a = Agent()
45
+
46
+ # https://gymnasium.farama.org/environments/classic_control/cart_pole/#observation-space
47
+ a.add_sensors(
48
+ [
49
+ Sensor(
50
+ "cart_pos",
51
+ "The Cart Position between [-4.8, 4.8]",
52
+ lambda sensors: sensors[0],
53
+ ),
54
+ Sensor(
55
+ "cart_vel",
56
+ "The Cart Position between [-inf, inf]",
57
+ lambda sensors: sensors[1],
58
+ ),
59
+ Sensor(
60
+ "pole_theta",
61
+ "The Pole Angle [-0.418 rad, 0.418 rad]",
62
+ lambda sensors: sensors[2],
63
+ ),
64
+ Sensor(
65
+ "pole_alpha",
66
+ "The Pole Angular Velocity [-inf, inf]",
67
+ lambda sensors: sensors[3],
68
+ ),
69
+ ]
70
+ )
71
+
72
+ skill = Skill("pole-balance", BalanceTeacher)
73
+ a.add_skill(skill)
74
+
75
+ # Create trainer and train the agent
76
+ r = Trainer(
77
+ {
78
+ "target": {"local": {"address": "localhost:1337"}},
79
+ "post_processing": {
80
+ "record": {
81
+ "is_enabled": True,
82
+ "file_path": "/tmp/amesa/recordings",
83
+ "avi_file_name": "output.avi",
84
+ "gif_file_name": "output.gif",
85
+ "max_frames": 24 * 5,
86
+ },
87
+ },
88
+ }
89
+ )
90
+
91
+ r.train(a, train_cycles=5)
92
+ r.close()
93
+
94
+
95
+ if __name__ == "__main__":
96
+ main()
@@ -0,0 +1,67 @@
1
+ # README
2
+
3
+ This is a template for creating a new Perceptor. A Perceptor is a component that is responsible for processing data and returning a result. This can be used for example in a Machine Learning model, where the Perceptor is responsible for processing the data and returning the prediction.
4
+
5
+ ## Tree Structure
6
+
7
+ The template is structured as follows:
8
+
9
+ ```bash
10
+ my-perceptor/ # Root folder
11
+ ├── my_perceptor/ # Main package folder
12
+ │ ├── __init__.py # Package init file
13
+ │ └── perceptor.py # Main perceptor file
14
+ ├── pyproject.toml # Project configuration, containing [amesa]
15
+ ```
16
+
17
+ ## PyProject [amesa] Section
18
+
19
+ We add the `[amesa]` section to the `pyproject.toml` file to specify the type of component we are creating as well as its entrypoint. This is used by the Amesa CLI to determine the type of
20
+ component and how to handle it.
21
+
22
+ Example:
23
+
24
+ ```
25
+ [amesa]
26
+ type = "teacher"
27
+ entrypoint = "my_perceptor.perceptor:MyPerceptor"
28
+ ```
29
+
30
+ ## Development
31
+
32
+ To work on the Perceptor, you can simply create a temporary file or main file that starts up and executes the `compute` method of the portable Perceptor. Example, we can create a `test.py` file with:
33
+
34
+ ```python
35
+ from amesa_perceptor_my_perceptor.perceptor import MyPerceptor
36
+
37
+
38
+ async def start():
39
+ p = MyPerceptor()
40
+ res = await t.compute(None, [1.0])
41
+ print(res)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ import asyncio
46
+
47
+ asyncio.run(start())
48
+ ```
49
+
50
+ Which we can then run with
51
+
52
+ ```bash
53
+ # Install the module
54
+ pip install -e my-perceptor
55
+
56
+ # Run the test file
57
+ python my-perceptor/test.py
58
+ ```
59
+
60
+ ### Preparing for Upload
61
+
62
+ Once we are ready for uploading, we can create a `.tar.gz` file that contains the version. This can be done with the following command:
63
+
64
+ ```bash
65
+ # Tar GZ the plugin
66
+ tar -czvf my-perceptor-0.0.1.tar.gz my-perceptor
67
+ ```
@@ -0,0 +1,15 @@
1
+ [project]
2
+ name = "{{NAME}}"
3
+ version = "0.1.0"
4
+ description = "{{DESCRIPTION}}"
5
+ authors = [{ name = "John Doe", email = "john.doe@amesa.com" }]
6
+ dependencies = [
7
+ "amesa-core{{AMESA_DEV}}{{AMESA_CORE_VERSION}}",
8
+ ]
9
+
10
+ [amesa]
11
+ type = "perceptor"
12
+ variables = [
13
+ "counter_derived"
14
+ ]
15
+ entrypoint = "{{NAME_MODULE}}.perceptor:DemoPerceptor"
@@ -0,0 +1,3 @@
1
+ # Copyright (C) Amesa, Inc - All Rights Reserved
2
+ # Unauthorized copying of this file, via any medium is strictly prohibited
3
+ # Proprietary and confidential
@@ -0,0 +1,34 @@
1
+ # Copyright (C) Amesa, Inc - All Rights Reserved
2
+ # Unauthorized copying of this file, via any medium is strictly prohibited
3
+ # Proprietary and confidential
4
+
5
+ import time
6
+
7
+ from amesa_core import PerceptorImpl
8
+
9
+
10
+ class DemoPerceptor(PerceptorImpl):
11
+ def __init__(self, *args, **kwargs):
12
+ self.previous_value = None
13
+ self.previous_time = None
14
+
15
+ async def compute(self, obs_spec, obs):
16
+ current_value = obs["counter"]
17
+ current_time = time.time() # Get current time
18
+ value_derived = 0
19
+
20
+ # Only calculate derivative if we have a previous sensors values
21
+ if self.previous_value is not None and self.previous_time is not None:
22
+ time_delta = current_time - self.previous_time
23
+
24
+ if time_delta > 0: # Check to ensure time has passed
25
+ value_derived = (current_value - self.previous_value) / time_delta
26
+
27
+ # Update previous value and time for the next sensor values
28
+ self.previous_value = current_value
29
+ self.previous_time = current_time
30
+
31
+ return {"counter_derived": value_derived}
32
+
33
+ def filtered_sensor_space(self, obs):
34
+ return ["counter"]
@@ -0,0 +1,67 @@
1
+ # README
2
+
3
+ This is a template for creating a new Perceptor. A Perceptor is a component that is responsible for processing data and returning a result. This can be used for example in a Machine Learning model, where the Perceptor is responsible for processing the data and returning the prediction.
4
+
5
+ ## Tree Structure
6
+
7
+ The template is structured as follows:
8
+
9
+ ```bash
10
+ my-perceptor/ # Root folder
11
+ ├── my_perceptor/ # Main package folder
12
+ │ ├── __init__.py # Package init file
13
+ │ └── perceptor.py # Main perceptor file
14
+ ├── pyproject.toml # Project configuration, containing [amesa]
15
+ ```
16
+
17
+ ## PyProject [amesa] Section
18
+
19
+ We add the `[amesa]` section to the `pyproject.toml` file to specify the type of component we are creating as well as its entrypoint. This is used by the Amesa CLI to determine the type of
20
+ component and how to handle it.
21
+
22
+ Example:
23
+
24
+ ```
25
+ [amesa]
26
+ type = "teacher"
27
+ entrypoint = "my_perceptor.perceptor:MyPerceptor"
28
+ ```
29
+
30
+ ## Development
31
+
32
+ To work on the Perceptor, you can simply create a temporary file or main file that starts up and executes the `compute` method of the portable Perceptor. Example, we can create a `test.py` file with:
33
+
34
+ ```python
35
+ from amesa_perceptor_my_perceptor.perceptor import MyPerceptor
36
+
37
+
38
+ async def start():
39
+ p = MyPerceptor()
40
+ res = await t.compute(None, [1.0])
41
+ print(res)
42
+
43
+
44
+ if __name__ == "__main__":
45
+ import asyncio
46
+
47
+ asyncio.run(start())
48
+ ```
49
+
50
+ Which we can then run with
51
+
52
+ ```bash
53
+ # Install the module
54
+ pip install -e my-perceptor
55
+
56
+ # Run the test file
57
+ python my-perceptor/test.py
58
+ ```
59
+
60
+ ### Preparing for Upload
61
+
62
+ Once we are ready for uploading, we can create a `.tar.gz` file that contains the version. This can be done with the following command:
63
+
64
+ ```bash
65
+ # Tar GZ the plugin
66
+ tar -czvf my-perceptor-0.0.1.tar.gz my-perceptor
67
+ ```
@@ -0,0 +1,12 @@
1
+ [project]
2
+ name = "{{NAME}}"
3
+ version = "0.1.0"
4
+ description = "{{DESCRIPTION}}"
5
+ authors = [{ name = "John Doe", email = "john.doe@amesa.com" }]
6
+ dependencies = [
7
+ "amesa-core{{AMESA_DEV}}{{AMESA_CORE_VERSION}}",
8
+ ]
9
+
10
+ [amesa]
11
+ type = "selector-controller"
12
+ entrypoint = "{{NAME_MODULE}}.controller:Controller"
@@ -0,0 +1,3 @@
1
+ # Copyright (C) Amesa, Inc - All Rights Reserved
2
+ # Unauthorized copying of this file, via any medium is strictly prohibited
3
+ # Proprietary and confidential
@@ -0,0 +1,52 @@
1
+ # Copyright (C) Amesa, Inc - All Rights Reserved
2
+ # Unauthorized copying of this file, via any medium is strictly prohibited
3
+ # Proprietary and confidential
4
+
5
+ from typing import Dict, List
6
+
7
+ from amesa_core import SkillController
8
+
9
+
10
+ class Controller(SkillController):
11
+ """
12
+ We start at 10 reward and count down to 0 the goal is that the agent stays
13
+ above or equal to 0 this means it learned to cound +1 each time
14
+ """
15
+
16
+ def __init__(self, *args, **kwargs):
17
+ self.past_obs = None
18
+ self.counter = 10
19
+ self.sensor_name = "counter"
20
+
21
+ async def compute_action(self, transformed_sensors: Dict, action) -> List[float]:
22
+ """
23
+ Compute action in a programme selector is to select the best skill based in a rule or an optimization.
24
+ Let's supose that we have three skills:
25
+ 1 - Decrease counter
26
+ 2 - Increase counter
27
+ 3 - Stop
28
+ """
29
+ # return Skill 1 = decrease
30
+ if self.counter > 10:
31
+ return [0]
32
+ # return Skill 2 = increase
33
+ elif self.counter < 10:
34
+ return [1]
35
+ # return Skill 3 = stop
36
+ else:
37
+ return [3]
38
+
39
+ async def compute_success_criteria(self, transformed_sensors: Dict, action) -> bool:
40
+ return bool(transformed_sensors[self.sensor_name] >= 10)
41
+
42
+ async def compute_termination(self, transformed_sensors: Dict, action) -> bool:
43
+ return bool(transformed_sensors[self.sensor_name] <= -10)
44
+
45
+ async def transform_sensors(self, sensors, action) -> str:
46
+ return sensors
47
+
48
+ async def transform_action(self, transformed_sensors: Dict, action) -> float:
49
+ return action
50
+
51
+ async def filtered_sensor_space(self) -> List[str]:
52
+ return ["counter"]