def make_records(): for vol, rec in Tracker(iter=generate_image_records(), report_every=100): if rec.instrument_name == 'MOC-NA': a = Asset() a.volume = vol a.product_id = rec.product_id a.instrument_name = rec.instrument_name a.footprint = build_footprint(rec) a.relative_file_path = os.path.join(vol, rec.file_specification_name) a.save()
def spawn_output_asset(self): """ Creates a new asset record for the job's output file. Assumes that the output filename will be the second parameter in the output list """ assert self.assets.count() == 1 asset_o = self.assets.all()[0] asset_n = Asset() asset_n.__dict = asset_o.__dict__ asset_n.id = None asset_n.is_original = False asset_n.creator_job = self args = json.loads(self.arguments) asset_n.relative_file_path = args[self.outfile_argument_index].replace(DATA_ROOT,'') assert os.path.exists(asset_n.file_path) asset_n.class_label = self.jobset.output_asset_label or self.jobset.name asset_n.save() asset_n.parents.add(asset_o)
def spawn_output_asset(self): """ Creates a new asset record for the job's output file. Assumes that the output filename will be the second parameter in the output list """ assert self.assets.count() == 1 asset_o = self.assets.all()[0] asset_n = Asset() asset_n.__dict = asset_o.__dict__ asset_n.id = None asset_n.is_original = False asset_n.creator_job = self args = json.loads(self.arguments) asset_n.relative_file_path = args[self.outfile_argument_index].replace( DATA_ROOT, '') assert os.path.exists(asset_n.file_path) asset_n.class_label = self.jobset.output_asset_label or self.jobset.name asset_n.save() asset_n.parents.add(asset_o)