def save_job_descriptions(self, job_descriptions): """ saves multiple job descriptions at a time job_descriptions - type -> list of dicts - {'jd_id', 'jd_title', jd_html', 'jd_sentences'} """ if not job_descriptions: raise ServiceException('job descriptions are required') jd_insts = [JobDescription(**{ 'jd_id': jd.get('jd_id'), 'jd_title': jd.get('jd_title'), 'jd_html': jd.get('jd_html'), 'jd_sentences': jd.get('jd_sentences') }) for jd in job_descriptions] validated_jds = list(filter( lambda x: x is not None, map(self._validate_jd, jd_insts) )) if validated_jds: JobDescription.objects.insert(validated_jds) return {'inserted_docs': len(validated_jds)}
def test_main(self): config = { 'algorithm': 'heliosat', 'data': 'mock_data/goes13.2015.*.BAND_01.nc', 'temporal_cache': 'temporal_cache', 'product': 'products/estimated' } job = JobDescription(**config) begin = datetime.now() job.run() # heliosat.workwith(**config) end = datetime.now() self.verify_output() elapsed = (end - begin).total_seconds() first, last = min(self.files), max(self.files) to_dt = helpers.to_datetime processed = (to_dt(last) - to_dt(first)).total_seconds() processed_days = processed / 3600. / 24 scale_shapes = (2245. / 86) * (3515. / 180) * (30. / processed_days) estimated = elapsed * scale_shapes / 3600. print "Scaling total time to %.2f hours." % estimated print "Efficiency achieved: %.2f%%" % (3.5 / estimated * 100.)