Commit 820e5db56b695e04a6c6738173700d320e42c37c

Authored by Alexis Koralewski
1 parent b06742d0
Exists in dev

Adding new methods to get unit home and agent path_data_root. Adding data folder…

… and his README file, git will ignore all content inside this folder
@@ -59,6 +59,10 @@ client.log @@ -59,6 +59,10 @@ client.log
59 59
60 docker/*.env 60 docker/*.env
61 61
  62 +# Agents data
  63 +# Ignore everthing outside of README.md
  64 +data/*
  65 +!data/README.md
62 66
63 private/* 67 private/*
64 privatedev/config/*/history/ 68 privatedev/config/*/history/
  1 +23-06-2022 (AKo): v0.4.14.0
  2 + - Adding methods in obsconfig class to get home of unit and path_data_root of agent
  3 + - Adding data folder at root of project with an README. Git will ignore all content outside of this file in this folder
  4 +
1 20-06-2022 (AKo): v0.4.14.0 5 20-06-2022 (AKo): v0.4.14.0
2 - Fixing issues for PYROSW with Windows OS, Adding venv option actions (running pyros in actual venv) if there is one and we're not within docker's pyros container 6 - Fixing issues for PYROSW with Windows OS, Adding venv option actions (running pyros in actual venv) if there is one and we're not within docker's pyros container
3 - Fixing AgentSST (renaming method properly) 7 - Fixing AgentSST (renaming method properly)
data/README.md 0 → 100644
@@ -0,0 +1 @@ @@ -0,0 +1 @@
  1 +Folder to place Agents data
0 \ No newline at end of file 2 \ No newline at end of file
src/core/pyros_django/obsconfig/obsconfig_class.py
@@ -590,9 +590,10 @@ class OBSConfig: @@ -590,9 +590,10 @@ class OBSConfig:
590 computers = {} 590 computers = {}
591 for computer_id in range(len(self.obs_config["OBSERVATORY"]["INVENTORY"]["COMPUTERS"])): 591 for computer_id in range(len(self.obs_config["OBSERVATORY"]["INVENTORY"]["COMPUTERS"])):
592 computer = self.obs_config["OBSERVATORY"]["INVENTORY"]["COMPUTERS"][computer_id]["COMPUTER"] 592 computer = self.obs_config["OBSERVATORY"]["INVENTORY"]["COMPUTERS"][computer_id]["COMPUTER"]
593 - if("file" in computer.keys()): 593 + if "file" in computer.keys():
594 computer["computer_config"] = self.read_and_check_config_file( 594 computer["computer_config"] = self.read_and_check_config_file(
595 self.CONFIG_PATH+computer["file"])["COMPUTER"] 595 self.CONFIG_PATH+computer["file"])["COMPUTER"]
  596 + print(computer)
596 computers[computer["name"]] = computer 597 computers[computer["name"]] = computer
597 return computers 598 return computers
598 599
@@ -1116,6 +1117,29 @@ class OBSConfig: @@ -1116,6 +1117,29 @@ class OBSConfig:
1116 horizon = self.get_unit_by_name(unit_name).get("horizon") 1117 horizon = self.get_unit_by_name(unit_name).get("horizon")
1117 return horizon.get("line") 1118 return horizon.get("line")
1118 1119
  1120 + def getHome(self):
  1121 + """
  1122 + Return home of current unit
  1123 +
  1124 + Returns:
  1125 + str: string reprensenting home of unit
  1126 + """
  1127 + home = self.get_unit_by_name(self.unit_name).get("home")
  1128 + return home
  1129 +
  1130 + def get_agent_path_data_root(self, agent_name:str):
  1131 + """
  1132 + Return agent path_data_root
  1133 +
  1134 + Args:
  1135 + agent_name (str): _description_
  1136 +
  1137 + Returns:
  1138 + str|None: String reprensenting path_data_root
  1139 + """
  1140 + agent = self.get_agent_information(self.unit_name, agent_name)
  1141 + path_data_root = agent.get(path_data_root,None)
  1142 + return path_data_root
1119 1143
1120 class MissingMandatoryAgentException(Exception): 1144 class MissingMandatoryAgentException(Exception):
1121 """ 1145 """
src/core/pyros_django/observation_manager/AgentImagesProcessor.py
@@ -91,28 +91,19 @@ class AgentImagesProcessor(Agent): @@ -91,28 +91,19 @@ class AgentImagesProcessor(Agent):
91 agent_alias = self.__class__.__name__ 91 agent_alias = self.__class__.__name__
92 log.info(f"agent_alias = {agent_alias}") 92 log.info(f"agent_alias = {agent_alias}")
93 config = self._oc['config'] 93 config = self._oc['config']
94 - units = config.get_units()  
95 - kunits = list(units.keys())  
96 - kunit = kunits[0]  
97 - log.info(f"unit key = {kunit}")  
98 - unit = units[kunit]  
99 - self._unit = unit 94 + unit = self.config.unit_name
100 # log.info(f"unit = {unit}") 95 # log.info(f"unit = {unit}")
101 - agents = config.get_agents(kunit) 96 + agents = config.get_agents(unit)
102 # log.info(f"agents = {agents}") 97 # log.info(f"agents = {agents}")
103 - attrs = agents[agent_alias]  
104 - key = 'path_data_root'  
105 - if key in attrs:  
106 - self._path_data_root = attrs['path_data_root']  
107 - else: 98 + # get_agent_path_data_root return str value if path_data_root exists in obsconfig for this agent or None if not
  99 + self._path_data_root = self.config.get_agent_path_data_root(agent_alias)
  100 + if self.path_data_root = None:
108 # default with docker should be /home/pyros_user/app 101 # default with docker should be /home/pyros_user/app
109 self._path_data_root = os.environ['PROJECT_ROOT_PATH'] 102 self._path_data_root = os.environ['PROJECT_ROOT_PATH']
110 - if self._path_data_root == None:  
111 - self._path_data_root = os.environ['PROJECT_ROOT_PATH']  
112 log.info(f"path_data_root = {self._path_data_root}") 103 log.info(f"path_data_root = {self._path_data_root}")
113 # - prepare the variables to return 104 # - prepare the variables to return
114 - path_data_root = self._path_data_root  
115 - home = self._unit['home'] 105 + # Return home of current unit
  106 + home = self.config.getHome()
116 # return path_data_root, home 107 # return path_data_root, home
117 108
118 # === Define and create the directories for the images to process 109 # === Define and create the directories for the images to process