bondzai-bootstrap-framework 0.0.35__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 (20) hide show
  1. bondzai_bootstrap_framework-0.0.35/NOTICE +13 -0
  2. bondzai_bootstrap_framework-0.0.35/PKG-INFO +22 -0
  3. bondzai_bootstrap_framework-0.0.35/README.md +5 -0
  4. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/__init__.py +8 -0
  5. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/bootstrap.py +135 -0
  6. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/dvs_agent.py +715 -0
  7. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/dvs_com.py +564 -0
  8. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/dvs_config.py +441 -0
  9. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/file_handler.py +118 -0
  10. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/logger.py +13 -0
  11. bondzai_bootstrap_framework-0.0.35/bondzai/bootstrap_framework/self_test.py +644 -0
  12. bondzai_bootstrap_framework-0.0.35/bondzai_bootstrap_framework.egg-info/PKG-INFO +22 -0
  13. bondzai_bootstrap_framework-0.0.35/bondzai_bootstrap_framework.egg-info/SOURCES.txt +19 -0
  14. bondzai_bootstrap_framework-0.0.35/bondzai_bootstrap_framework.egg-info/dependency_links.txt +1 -0
  15. bondzai_bootstrap_framework-0.0.35/bondzai_bootstrap_framework.egg-info/namespace_packages.txt +1 -0
  16. bondzai_bootstrap_framework-0.0.35/bondzai_bootstrap_framework.egg-info/requires.txt +3 -0
  17. bondzai_bootstrap_framework-0.0.35/bondzai_bootstrap_framework.egg-info/top_level.txt +2 -0
  18. bondzai_bootstrap_framework-0.0.35/bondzai_bootstrap_framework.egg-info/zip-safe +1 -0
  19. bondzai_bootstrap_framework-0.0.35/pyproject.toml +4 -0
  20. bondzai_bootstrap_framework-0.0.35/setup.cfg +37 -0
@@ -0,0 +1,13 @@
1
+ Copyright 2023 Bondzai
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,22 @@
1
+ Metadata-Version: 2.1
2
+ Name: bondzai_bootstrap_framework
3
+ Version: 0.0.35
4
+ Summary: Bondzai Bootstrap Framework
5
+ Home-page: UNKNOWN
6
+ Author: Bondzai
7
+ License: Apache License 2.0
8
+ Keywords: davinsy,bondzai
9
+ Platform: UNKNOWN
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: Apache Software License
12
+ Classifier: Operating System :: OS Independent
13
+ Description-Content-Type: text/markdown
14
+ License-File: NOTICE
15
+
16
+ ## Bondzai BootStrap Framework
17
+
18
+ #### Description
19
+
20
+ Bondzai BootStrap Framework is a framework used to create bootstrap for the DavinSy agent
21
+
22
+
@@ -0,0 +1,5 @@
1
+ ## Bondzai BootStrap Framework
2
+
3
+ #### Description
4
+
5
+ Bondzai BootStrap Framework is a framework used to create bootstrap for the DavinSy agent
@@ -0,0 +1,8 @@
1
+ from .bootstrap import Bootstrap
2
+ from .dvs_agent import DvsAgent
3
+ from .dvs_config import DvsConfig
4
+ from .dvs_com import DvsCom
5
+ from .self_test import SelfTest
6
+ from .file_handler import Tar, handle_binary_file_data
7
+
8
+ __version__ = "0.0.35"
@@ -0,0 +1,135 @@
1
+ ##############################################
2
+ # _ __
3
+ # | \ _ o __ (_ \/
4
+ # |_/(_|\_/ | | |__) /
5
+ #
6
+ ###############################################
7
+ # This is DavinSy boot script
8
+ # The script is executed at the very beginning of the boot sequence
9
+ # At this time DavinSy is not ready to handle any command, still you can
10
+ # do some pure python initialization
11
+ #
12
+ # Then, if this is the first time the system boot
13
+ # the boot function is called with 0 as a parameter
14
+ # At this time you should populate the database.
15
+ #
16
+ # Later on the boot function is called again with 1 as a parameter
17
+ # just before the application starts.
18
+ #
19
+ # And one time again with 2 as a parameter just after the application started
20
+ # At this time you should start running you simulation script/
21
+ # ########################################################
22
+
23
+ from pathlib import Path
24
+ import importlib
25
+ import importlib.util
26
+
27
+ from .dvs_agent import DvsAgent
28
+ from .logger import logger
29
+ from .dvs_com import DvsCom
30
+ from .self_test import SelfTest
31
+
32
+ class Bootstrap:
33
+ _instance: "Bootstrap" = None
34
+
35
+ @classmethod
36
+ def get_instance(cls):
37
+ if not cls._instance:
38
+ logger.debug("Bootstrap creating singleton")
39
+ cls._instance = cls()
40
+ return cls._instance
41
+
42
+ def __init__(self):
43
+ self.agent = DvsAgent(link=self.configure_communication())
44
+ self.callbacks = {}
45
+ self.custom_ops = {}
46
+
47
+ def pre_boot(self,ini_path:Path = None):
48
+ self.agent.pre_boot(ini_path)
49
+
50
+ # super seed for FOREIGN
51
+ def configure_communication(self):
52
+ return DvsCom()
53
+
54
+ def set_data_path(self,data_path):
55
+ return self.agent.set_data_path(data_path)
56
+
57
+ def set_max_nb_raw_data (self,max_nb_raw_data:int):
58
+ self.agent.set_max_nb_raw_data(max_nb_raw_data)
59
+
60
+ def set_agent_id(self,agent_id):
61
+ self.agent.set_agent_id(agent_id)
62
+
63
+ def enable_reload_raw_data(self):
64
+ self.agent.enable_reload_raw_data()
65
+
66
+ def disable_reload_raw_data(self):
67
+ self.agent.disable_reload_raw_data()
68
+
69
+ def register_external_op(self,opId,operation):
70
+ self.custom_ops[opId] = operation
71
+
72
+ def register_callbacks(self,step,callbackfunction:callable):
73
+
74
+ if step in self.callbacks:
75
+ logger.warning(f" bootstrap callback already defined for {step}, replaced")
76
+ self.callbacks[step] = callbackfunction
77
+
78
+ def boot_init(self):
79
+
80
+ self.agent.init_and_load()
81
+
82
+ data_path = self.agent.get_data_path()
83
+ functions_file = data_path / "operations" / "functions.py"
84
+
85
+ if Path.exists(functions_file) :
86
+ spec = importlib.util.spec_from_file_location("functions", functions_file)
87
+ functions = importlib.util.module_from_spec(spec)
88
+ spec.loader.exec_module(functions)
89
+ table_association = functions.get_association() # use get_association() if import directly the function
90
+ for op_id in table_association:
91
+ func_str = table_association.get(op_id)
92
+ module_str, name = func_str.rsplit(".", 1)
93
+ if module_str != "functions":
94
+ raise Exception(f"Trying to import private operation {name} from outside of 'functions' module")
95
+ func = getattr(functions,name)
96
+ self.register_external_op(op_id,func)
97
+
98
+ self.agent.register_custom_ops_in_agent(self.custom_ops)
99
+
100
+ if self.agent.lifecycle == 1 :
101
+ # ---- LOAD INITIAL self.dataset ----
102
+ self.agent.load_initial_data()
103
+ logger.info("==> ending the init sequence")
104
+ #self.agent.link.end_init()
105
+
106
+ def boot_start(self):
107
+ self.agent.configure_agent_id()
108
+
109
+ def boot_ready(self):
110
+ if self.agent.config.is_selftest():
111
+ selftest = SelfTest.get_instance()
112
+ selftest.on_boot_done(self.agent,self.agent.get_data_path(),self.agent.config.get_selftest_options())
113
+
114
+ return
115
+
116
+ def boot(self, step):
117
+ try :
118
+ if step == 0:
119
+ self.boot_init()
120
+ elif step == 1:
121
+ self.boot_start()
122
+ elif step == 2:
123
+ self.boot_ready()
124
+ elif step == -1:
125
+ logger.debug("==> starting the init sequence")
126
+ #self.pre_boot()
127
+
128
+ if step in self.callbacks:
129
+ self.callbacks[step]()
130
+ except Exception as e :
131
+ logger.error(" Exception during boot step "+str(step)+ " because " + str(e))
132
+
133
+
134
+ def boot(step):
135
+ Bootstrap.get_instance().boot(step)