Commit d4c2451c95675cee84b75e4a4b9eb7a6abfe5707

Authored by Alain Klotz
2 parents a4da134a c6af49bf
Exists in dev

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

config/pyros_observatory/general/schemas/schema_observatory-2.0.yml
... ... @@ -525,6 +525,9 @@ schema;schema_UNIT:
525 525 home:
526 526 type: str
527 527 required: True
  528 + duskelev:
  529 + type: str
  530 + required: True
528 531 horizon:
529 532 type: map
530 533 required: True
... ...
docker/docker-compose.yml
... ... @@ -133,7 +133,7 @@ services:
133 133 resources:
134 134 limits:
135 135 cpus: '1'
136   - memory: 8GB
  136 + memory: 32GB
137 137 #pids: 1
138 138 # create network to allow images to communicate with other images within the same network
139 139 # networks:
... ...
src/core/pyros_django/majordome/agent/Agent.py
... ... @@ -154,7 +154,8 @@ import config.old_config as config_old
154 154 #from config import *
155 155  
156 156 from majordome.models import AgentSurvey, AgentCmd, AgentLogs
157   -from user_mgmt.models import Period, Quota
  157 +from user_mgmt.models import Period
  158 +from scp_mgmt.models import Quota
158 159  
159 160 from vendor.guitastro.src.guitastro import Ephemeris
160 161 import pickle
... ... @@ -3551,21 +3552,21 @@ class Agent:
3551 3552 # --- Check if durations.pickle file exists
3552 3553 rootdir = self._oc['config'].fn.rootdir
3553 3554 filename = os.path.join(rootdir, period_id, "durations.pickle")
3554   - self.dprint(f"Read {filename=}")
  3555 + log.info(f"Read {filename=}")
3555 3556 if os.path.exists(filename):
3556 3557 self._oc['config'].fn.fcontext = fcontext0
3557 3558 return pickle.load(open(filename, "wb"))
3558 3559  
3559 3560 # --- Get the period limit dates jd1, jd2
3560   - self.dprint(f"{dir(operiod)=}")
  3561 + log.info(f"{dir(operiod)=}")
3561 3562 d = operiod.start_date.isoformat()
3562 3563 night_start = d[0:4]+d[5:7]+d[8:10]
3563 3564 jd1, _ = self.config.fn.night2date(night_start)
3564 3565 d = operiod.end_date.isoformat()
3565 3566 night_end = d[0:4]+d[5:7]+d[8:10]
3566 3567 jd2, _ = self.config.fn.night2date(night_end)
3567   - self.dprint(f"{night_start=} {night_end=}")
3568   - self.dprint(f"{jd1=} {jd2=}")
  3568 + log.info(f"{night_start=} {night_end=}")
  3569 + log.info(f"{jd1=} {jd2=}")
3569 3570  
3570 3571 # --- Loop over dates of the period to create ephems
3571 3572 targets = ['sun', 'moon']
... ... @@ -3576,10 +3577,11 @@ class Agent:
3576 3577 d_cur = 0
3577 3578 d_total = 0
3578 3579 night_info = {}
  3580 + self._duskelev = self.config.getDuskElev()
3579 3581 while jd < jd2:
3580 3582 night = self._oc['config'].fn.date2night(jd)
3581 3583 for target in targets:
3582   - self.dprint(f"{night=} {target=}")
  3584 + log.info(f"{night=} {target=}")
3583 3585 ephem = self.ephem_target2night(target, jd)
3584 3586 if target == "sun":
3585 3587 ks = np.where(ephem['alt'] < self._duskelev)
... ...
src/core/pyros_django/obs_config/obsconfig_class.py
... ... @@ -1239,6 +1239,16 @@ class OBSConfig:
1239 1239 """
1240 1240 home = self.get_unit_by_name(self.unit_name).get("home")
1241 1241 return home
  1242 +
  1243 + def getDuskElev(self)->float:
  1244 + """
  1245 + Return duskelev of current unit
  1246 +
  1247 + Returns:
  1248 + float: string reprensenting duskelev of unit
  1249 + """
  1250 + duskelev = float(self.get_unit_by_name(self.unit_name).get("duskelev"))
  1251 + return duskelev
1242 1252  
1243 1253 def get_agent_path_data_root(self, agent_name:str, computer_hostname=None) -> str:
1244 1254 """
... ...
src/core/pyros_django/scp_mgmt/A_SCP_Manager.py
... ... @@ -58,9 +58,8 @@ class A_SCP_Manager(Agent):
58 58 super().__init__()
59 59 next_period = Period.objects.next_period()
60 60 period = next_period
61   - self.pconfig = self._oc['pyros_config']
62   - self._fn = self.config.fn
63 61 self.config = self._oc['config']
  62 + self._fn = self.config.fn
64 63 self._fn.pathnaming("PyROS.seq.1")
65 64  
66 65 # @override
... ... @@ -259,7 +258,7 @@ class A_SCP_Manager(Agent):
259 258  
260 259 def set_quota_for_SP(self, id_period):
261 260 period = Period.objects.get(id=id_period)
262   - for sp_period in SP_Period.objects.filter(period=period)
  261 + for sp_period in SP_Period.objects.filter(period=period):
263 262 sp = sp_period.scientific_program
264 263 institute = sp.institute
265 264 institute_quota = institute.quota
... ...