def write_qa_prod(outroot, qaprod): """Write QA for a given production Args: outroot : str filename without format extension qa_prod : QA_Prod object Returns: outfile or odict : str or dict """ from desiutil.io import combine_dicts outfile = outroot+'.yaml' outfile = makepath(outfile, 'qa') # Loop on exposures odict = {} for qaexp in qaprod.qa_exps: # Get the exposure dict idict = write_qa_exposure('foo', qaexp, ret_dict=True) odict = combine_dicts(odict, idict) ydict = yamlify(odict) # Simple yaml with open(outfile, 'w') as yamlf: yamlf.write( yaml.dump(ydict))#, default_flow_style=True) ) log.info('Wrote QA_Prod file: {:s}'.format(outfile)) return outfile
def write_qa_prod(outroot, qaprod, indent=True): """Write QA for a given production Args: outroot : str filename without format extension qa_prod : QA_Prod object Returns: outfile: str output filename """ from desiutil.io import combine_dicts log = get_logger() outfile = outroot + '.json' outfile = makepath(outfile, 'qa') # Loop on exposures odict = {} for qaexp in qaprod.qa_exps: # Get the exposure dict idict = write_qa_exposure('foo', qaexp, ret_dict=True) odict = combine_dicts(odict, idict) ydict = yamlify(odict) # This works well for JSON too # Simple json with open(outfile, 'wt') as fh: json.dump(ydict, fh, indent=indent) log.info('Wrote QA_Prod file: {:s}'.format(outfile)) return outfile
def build_data(self): """ Build QA data dict """ from desiutil.io import combine_dicts # Loop on exposures odict = {} for qaexp in self.qa_exps: # Get the exposure dict idict = write_qa_exposure('foo', qaexp, ret_dict=True) odict = combine_dicts(odict, idict) # Finish self.data = odict