Commit 9348fd8141e446b9b927a4e1fdff4d5b0fbbd055

Authored by Alain Klotz
2 parents 950fd6a3 9db4ef71
Exists in dev

Merge branch 'dev' of https://gitlab.irap.omp.eu/pyros-irap/pyros into dev

CHANGELOG
1   -21-07-2023 (AKo): V0.6.27.0
  1 +28-07-2023 (AKo): V0.6.28.0
  2 + - Add command in A_SCP_Manager to generate ephemeris files of sun & moon for a period
  3 + - Fix AgentSST start one agent
  4 + - Fix config_pyros paths
  5 + - Fix JS of agent_detail
  6 +
  7 +26-07-2023 (AKo): V0.6.27.0
  8 + - Remove private & privatedev folder
  9 +
  10 +24-07-2023 (AKo): V0.6.27.0
2 11 - install_observatory now copy default observatory if repository doesn't exists
3 12 - fix error on update due to package version for doc generation
4 13 - update dockerfile (can't copy outside build context)
... ...
src/core/pyros_django/dashboard/config_pyros.py
... ... @@ -4,8 +4,12 @@ import sys
4 4 import time
5 5 import pykwalify.core
6 6 from pykwalify.errors import SchemaError
7   -sys.path.append("../../../")
  7 +
  8 +sys.path.append(os.environ.get("PROJECT_ROOT_PATH", "../../../../"))
  9 +
8 10 from vendor.guitastro.src.guitastro import FileNames
  11 +
  12 +
9 13 class ConfigPyros:
10 14  
11 15 def check_and_return_config(self, yaml_file: str, schema_file: str) -> dict:
... ... @@ -32,7 +36,7 @@ class ConfigPyros:
32 36 time.sleep(0.5)
33 37  
34 38 c = pykwalify.core.Core(source_file=yaml_file, schema_files=[
35   - self.config_path+"/"+schema_file])
  39 + os.path.join(self.config_path, schema_file)])
36 40 return c.validate(raise_exception=True)
37 41 except SchemaError:
38 42 for error in c.errors:
... ... @@ -80,8 +84,8 @@ class ConfigPyros:
80 84 return None
81 85  
82 86 def __init__(self, pyros_config_file):
83   - self.config_path = os.path.abspath(os.path.join(
84   - os.environ.get("DJANGO_PATH"), "../../../config/"))
  87 + self.config_path = os.path.join(
  88 + os.environ.get("PROJECT_ROOT_PATH", "../../../") , "config/")
85 89 if pyros_config_file is None:
86 90 pyros_config_file = "config_pyros_default.yml"
87 91 self.pyros_config = self.read_and_check_config_file(pyros_config_file)
... ... @@ -100,19 +104,20 @@ class ConfigPyros:
100 104 self.fn = fn
101 105 def main():
102 106 os.environ["DJANGO_PATH"] = "../../src/core/pyros_django"
103   - cp = ConfigPyros("config_pyros.yml")
  107 + os.environ["PROJECT_ROOT_PATH"] = "../../../../"
  108 + cp = ConfigPyros(os.path.join(os.environ["PROJECT_ROOT_PATH"], "config", "config_pyros_default.yml"))
104 109 cp.fn.fcontext = "pyros_seq"
105 110 print(cp.fn)
106   - file_fullname = "../../data/sequences_pickle/P1/20230319/16.p"
107   - param = cp.fn.naming_get(file_fullname)
108   - print(param)
109   - cp.fn.fname = cp.fn.naming_set(param)
110   - print(cp.fn.fname)
111   - #cp.fn.subdir = cp.fn.subdir_from_filename(file_fullname)
112   - print(type(cp.fn.fname))
113   - out_fullname = cp.fn.join()
114   - print(os.getcwd())
115   - print(out_fullname)
  111 + # file_fullname = "../../data/sequences_pickle/P1/20230319/16.p"
  112 + # param = cp.fn.naming_get(file_fullname)
  113 + # print(param)
  114 + # cp.fn.fname = cp.fn.naming_set(param)
  115 + # print(cp.fn.fname)
  116 + # #cp.fn.subdir = cp.fn.subdir_from_filename(file_fullname)
  117 + # print(type(cp.fn.fname))
  118 + # out_fullname = cp.fn.join()
  119 + # print(os.getcwd())
  120 + # print(out_fullname)
116 121 if __name__ == "__main__":
117 122  
118 123 main()
119 124 \ No newline at end of file
... ...
src/core/pyros_django/majordome/agent/A_SST.py
... ... @@ -135,7 +135,6 @@ class A_SST(Agent):
135 135 obs_config = self.get_config()
136 136 test_mode = " -t"
137 137  
138   -
139 138 if agent_name:
140 139 agent = agent_name
141 140 protocol_script_name = ""
... ... @@ -156,7 +155,8 @@ class A_SST(Agent):
156 155 else:
157 156 # general agent of PyROS
158 157 for general_agent in self._general_agents:
159   - if agent in general_agent:
  158 + general_agent_name = os.path.splitext(os.path.basename(general_agent))
  159 + if general_agent_name[0] in agent:
160 160 protocol_folder_abs_path = os.path.abspath(os.path.dirname(general_agent))
161 161 protocol_script_name = os.path.basename(general_agent)
162 162 break
... ... @@ -208,6 +208,7 @@ class A_SST(Agent):
208 208 # general agent of PyROS
209 209 for general_agent in self._general_agents:
210 210 general_agent_name = os.path.splitext(os.path.basename(general_agent))
  211 + print("GENERAL AGENT NAME , AGENT : ",general_agent_name[0], agent)
211 212 if general_agent_name[0] in agent:
212 213 protocol = os.path.join(os.getcwd(),general_agent)
213 214 protocol_script_name = os.path.basename(general_agent)
... ...
src/core/pyros_django/misc/static/js/agent_detail/websocket_agent_detail.js
... ... @@ -117,7 +117,7 @@ var app = new Vue({
117 117 }
118 118 });
119 119 */
120   -var app = Vue.createApp({
  120 +var app_agent_cmds = Vue.createApp({
121 121 data(){
122 122 return {
123 123 commands: [],
... ...
src/core/pyros_django/scp_mgmt/A_SCP_Manager.py
... ... @@ -16,10 +16,9 @@ for short_path in short_paths:
16 16 sys.path.insert(0, path)
17 17  
18 18 # Project imports
19   -from src.core.pyros_django.user_mgmt.models import PyrosUser
20   -from seq_submit.models import Period, SP_Period, SP_Period_Guest, SP_PeriodWorkflow, ScientificProgram,SP_Period_User, ScienceTheme
21   -from src.core.pyros_django.majordome.agent.Agent import Agent, build_agent
22   -from vendor.guitastro.src.guitastro import guitastro
  19 +from majordome.agent.Agent import Agent, build_agent
  20 +from user_mgmt.models import PyrosUser, SP_Period, Period, SP_Period, SP_Period_Guest, SP_PeriodWorkflow
  21 +import vendor.guitastro.src.guitastro as guitastro
23 22  
24 23 # Django imports
25 24 from django.shortcuts import reverse
... ... @@ -47,7 +46,7 @@ class A_SCP_Manager(Agent):
47 46 _AGENT_SPECIFIC_COMMANDS = {
48 47 # Format : “cmd_name” : (timeout, exec_mode, tooltip)
49 48  
50   - "generate_ephem_moon_and_sun_for_period": (3, Agent.EXEC_MODE.SEQUENTIAL, 'generate ephem of moon & sun for a period'),
  49 + "do_generate_ephem_moon_and_sun_for_period": (3, Agent.EXEC_MODE.SEQUENTIAL, 'generate ephem of moon & sun for a period'),
51 50 }
52 51  
53 52 # new init with obsconfig
... ... @@ -59,6 +58,10 @@ class A_SCP_Manager(Agent):
59 58 super().__init__()
60 59 next_period = Period.objects.next_period()
61 60 period = next_period
  61 + self.pconfig = self._oc['pyros_config']
  62 + self._fn = self.pconfig.fn
  63 + self.config = self._oc['config']
  64 + self._fn.pathnaming("PyROS.seq.1")
62 65  
63 66 # @override
64 67 def _init(self):
... ... @@ -240,19 +243,26 @@ class A_SCP_Manager(Agent):
240 243 for n in range(int((end_date - start_date).days)):
241 244 yield start_date + timedelta(n)
242 245  
243   - def generate_ephem_moon_and_sun_for_period(self,period):
  246 + def do_generate_ephem_moon_and_sun_for_period(self, period_id:int):
  247 + period = Period.objects.get(id=period_id)
244 248 period_start_date = period.start_date
245 249 period_end_date = period.end_date
  250 +
246 251 root_path = os.environ.get("PROJECT_ROOT_PATH")
247 252 os.chdir(root_path)
248   - ephem_data_night_folder = os.path.join(root_path, "data")
  253 +
  254 + home = guitastro.Home(self._oc["config"].getHome())
  255 + self._fn.longitude(home.longitude)
  256 +
  257 + ephem_data_night_folder = self._fn.rootdir
249 258 if os.path.exists(ephem_data_night_folder):
250 259 period_id = str(period.id)
251 260 # form correct period string
252 261 if len(str(period.id)) < 3:
253 262 while len(period_id) < 3:
254 263 period_id = "0" + period_id
255   - ephem_data_night_folder = os.path.join(root_path, "data", period_id)
  264 + period_id = "P" + period_id
  265 + ephem_data_night_folder = os.path.join(ephem_data_night_folder, period_id)
256 266 if not os.path.exists(ephem_data_night_folder):
257 267 os.makedirs(ephem_data_night_folder, exist_ok=True)
258 268 for single_date in self.daterange(period_start_date, period_end_date):
... ... @@ -261,15 +271,18 @@ class A_SCP_Manager(Agent):
261 271 eph = guitastro.Ephemeris()
262 272 target_sun = "sun"
263 273 ephem_sun = eph.target2night(target_sun, current_date, None, None)
264   - file_name_sun = f"ephem_sun_{current_date}.p"
265   - file_name_moon = f"ephem_moon_{current_date}.p"
  274 + file_name_sun = f"ephem_sun_{current_date}"
  275 + file_name_moon = f"ephem_moon_{current_date}"
266 276 os.chdir(ephem_data_night_folder)
267 277 pickle.dump(ephem_sun, open(f"{file_name_sun}.f","wb"))
268 278 target_moon = "moon"
269 279 ephem_moon = eph.target2night(target_moon, current_date, None, None)
270 280 pickle.dump(ephem_moon, open(f"{file_name_moon}.f","wb"))
271 281  
272   -
  282 + # lire tous les fichiers sun de la period et appliquer le sky_elev pour déterminer le quota total de période
  283 + # prendre le champ alt &
  284 + # -> prendre tous les éléments en dessous de duskelev (cf l412 d'A_Sheduler, exemple 14 des éphémérides pour trier ces éléménts) et faire un sum
  285 +
273 286 if __name__ == "__main__":
274 287  
275 288 # with thread
... ...