def process_output(self): """ In the current directory, make sure that the results are ready to go by checking that ``RESULT_FILE`` exists and conforms to the property definitions that it promises. Also append SI units """ # Short-circuit if we already have a results.edn with self.runner_temp.in_dir(): if not os.path.isfile(cf.RESULT_FILE): raise cf.KIMRuntimeError, "The test did not produce a %s output file." % cf.RESULT_FILE # now, let's check whether that was actual a valid test result logger.debug("Checking the output EDN for validity") with self.runner_temp.in_dir(), open(cf.RESULT_FILE, 'r') as f: try: doc = cf.loadedn(f) doc = kimunits.add_si_units(doc) except Exception as e: raise cf.KIMRuntimeError, "Test did not produce valid EDN %s" % cf.RESULT_FILE if self.verify: valid, reply = test_result_valid(cf.RESULT_FILE) if not valid: raise cf.KIMRuntimeError, "Test result did not conform to property definition\n%r" % reply logger.debug("Adding units to result file") with self.runner_temp.in_dir(), open(cf.RESULT_FILE, 'w') as f: cf.dumpedn(doc, f) logger.debug("Made it through EDN read, everything looks good")
def insert_one_reference_data(leader, kimcode): logger.info("Inserting reference data %s ", kimcode) info = kimcode_to_dict(kimcode) try: resultobj = db.obj.insert(info) except: logger.error("Already have %s", kimcode) return try: with open(os.path.join(PATH_APPROVED,leader,kimcode,'data.edn')) as f: edn_docs = util.loadedn(f) edn_docs = edn_docs if isinstance(edn_docs, list) else [edn_docs] for doc in edn_docs: stuff = doc_to_dict(doc,leader,kimcode) stuff = kimunits.add_si_units(stuff) db.data.insert(stuff) except: logger.info("Could not read document for %s/%s", leader, kimcode)
def process_output(self): """ In the current directory, make sure that the results are ready to go by checking that ``RESULT_FILE`` exists and conforms to the property definitions that it promises. Also append SI units """ # Short-circuit if we already have a results.edn with self.runner_temp.in_dir(): if not os.path.isfile(cf.RESULT_FILE): raise cf.KIMRuntimeError( "The test did not produce a %s output file." % cf.RESULT_FILE ) # now, let's check whether that was actual a valid test result logger.debug("Checking the output EDN for validity") with self.runner_temp.in_dir(), open(cf.RESULT_FILE, 'r') as f: try: doc = util.loadedn(f) doc = kimunits.add_si_units(doc) except Exception as e: raise cf.PipelineRuntimeError( "Test did not produce valid EDN %s" % cf.RESULT_FILE, str(e) ) if self.verify: valid, reply = test_result_valid(cf.RESULT_FILE) if not valid: raise cf.KIMRuntimeError( "Test result did not conform to property definition\n%r" % reply ) logger.debug("Adding units to result file") with self.runner_temp.in_dir(), open(cf.RESULT_FILE, 'w') as f: util.dumpedn(doc, f) logger.debug("Made it through EDN read, everything looks good")