def _load_parset(self, obs_config): """ Load the observation parset :param dict obs_config: Observation config :return: parset as dict """ if self.host_type == 'master': # encoded parset is already in config on master node # decode the parset raw_parset = util.decode_parset(obs_config['parset']) # convert to dict and store parset = util.parse_parset(raw_parset) else: # Load the parset from the master parset file master_config_file = os.path.join(obs_config['master_dir'], 'parset', 'darc_master.parset') try: # Read raw config with open(master_config_file) as f: master_config = f.read().strip() # Convert to dict master_config = util.parse_parset(master_config) # extract obs parset and decode raw_parset = util.decode_parset(master_config['parset']) parset = util.parse_parset(raw_parset) except Exception as e: self.logger.warning( "Failed to load parset from master config file {}, setting parset to None: {}" .format(master_config_file, e)) parset = None return parset
def _load_parset(self, obs_config): """ Load the observation parset :param dict obs_config: Observation config :return: parset as dict """ try: # encoded parset is already in config on master node # decode the parset raw_parset = util.decode_parset(obs_config['parset']) # convert to dict and store parset = util.parse_parset(raw_parset) except KeyError: self.logger.info( f"{obs_config['datetimesource']}: Observation parset not found in input config, " f"looking for master parset") # Load the parset from the master parset file master_config_file = os.path.join(obs_config['master_dir'], 'parset', 'darc_master.parset') try: # Read raw config with open(master_config_file) as f: master_config = f.read().strip() # Convert to dict master_config = util.parse_parset(master_config) # extract obs parset and decode raw_parset = util.decode_parset(master_config['parset']) parset = util.parse_parset(raw_parset) except Exception as e: self.logger.warning( "Failed to load parset from master config file {}, " "setting parset to None: {}".format(master_config_file, e)) parset = None return parset