Esempio n. 1
0
    def run_task(self, fw_spec):
        lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec)

        wf = lp.get_wf_by_fw_id(fw_id)
        wf_module = importlib.import_module(wf.metadata['workflow_module'])
        wf_class = getattr(wf_module, wf.metadata['workflow_class'])

        database = fw_spec['mongo_database']
        if self.criteria is not None:
            entry = database.get_entry(criteria=self.criteria)
        else:
            entry = {}

        inserted = []
        for root_key, method_name in self.insertion_data.items():
            get_results_method = getattr(wf_class, method_name)
            results = get_results_method(wf)
            for key, val in results.items():
                entry[key] = jsanitize(val)
                inserted.append(key)

        if self.criteria is not None:
            database.save_entry(entry=entry)
        else:
            database.insert_entry(entry=entry)

        logging.info("Inserted data:\n{}".format('- {}\n'.join(inserted)))
        return FWAction()
Esempio n. 2
0
    def run_task(self, fw_spec):
        lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec)

        wf = lp.get_wf_by_fw_id(fw_id)
        wf_module = importlib.import_module(wf.metadata['workflow_module'])
        wf_class = getattr(wf_module, wf.metadata['workflow_class'])

        database = fw_spec['mongo_database']
        if self.criteria is not None:
            entry = database.get_entry(criteria=self.criteria)
        else:
            entry = {}

        inserted = []
        for root_key, method_name in self.insertion_data.items():
            get_results_method = getattr(wf_class, method_name)
            results = get_results_method(wf)
            for key, val in results.items():
                entry[key] = jsanitize(val)
                inserted.append(key)

        if self.criteria is not None:
            database.save_entry(entry=entry)
        else:
            database.insert_entry(entry=entry)

        logging.info("Inserted data:\n{}".format('- {}\n'.join(inserted)))
        return FWAction()
Esempio n. 3
0
    def run_task(self, fw_spec):
        self.db_data.connect_mongoengine()

        lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec)

        wf = lp.get_wf_by_fw_id_lzyfw(fw_id)
        wf_module = importlib.import_module(wf.metadata['workflow_module'])
        wf_class = getattr(wf_module, wf.metadata['workflow_class'])

        get_results_method = getattr(wf_class, 'get_mongoengine_results')

        #TODO extend for multiple documents?
        document = get_results_method(wf)

        with self.db_data.switch_collection(document.__class__) as document.__class__:
            #TODO it would be better to try to remove automatically the FileFields already saved if the save of
            # the document fails.
            document.save()
Esempio n. 4
0
    def run_task(self, fw_spec):
        lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec)

        wf = lp.get_wf_by_fw_id_lzyfw(fw_id)

        deleted_files = []
        # iterate over all the fws and launches
        for fw_id, fw in wf.id_fw.items():
            for l in fw.launches+fw.archived_launches:
                l_dir = l.launch_dir

                deleted_files.extend(self.delete_files(os.path.join(l_dir, TMPDIR_NAME)))
                deleted_files.extend(self.delete_files(os.path.join(l_dir, INDIR_NAME)))
                deleted_files.extend(self.delete_files(os.path.join(l_dir, OUTDIR_NAME), self.out_exts))

        logging.info("Deleted files:\n {}".format("\n".join(deleted_files)))

        return FWAction(stored_data={'deleted_files': deleted_files})
Esempio n. 5
0
    def run_task(self, fw_spec):
        self.db_data.connect_mongoengine()

        lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec)

        wf = lp.get_wf_by_fw_id_lzyfw(fw_id)
        wf_module = importlib.import_module(wf.metadata['workflow_module'])
        wf_class = getattr(wf_module, wf.metadata['workflow_class'])

        get_results_method = getattr(wf_class, 'get_mongoengine_results')

        #TODO extend for multiple documents?
        document = get_results_method(wf)

        with self.db_data.switch_collection(
                document.__class__) as document.__class__:
            #TODO it would be better to try to remove automatically the FileFields already saved if the save of
            # the document fails.
            document.save()
Esempio n. 6
0
    def run_task(self, fw_spec):
        lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec)

        wf = lp.get_wf_by_fw_id_lzyfw(fw_id)

        deleted_files = []
        # iterate over all the fws and launches
        for fw_id, fw in wf.id_fw.items():
            for l in fw.launches + fw.archived_launches:
                l_dir = l.launch_dir

                deleted_files.extend(
                    self.delete_files(os.path.join(l_dir, TMPDIR_NAME)))
                deleted_files.extend(
                    self.delete_files(os.path.join(l_dir, INDIR_NAME)))
                deleted_files.extend(
                    self.delete_files(os.path.join(l_dir, OUTDIR_NAME),
                                      self.out_exts))

        logging.info("Deleted files:\n {}".format("\n".join(deleted_files)))

        return FWAction(stored_data={'deleted_files': deleted_files})
Esempio n. 7
0
 def run_task(self, fw_spec):
     lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec=fw_spec)
Esempio n. 8
0
 def run_task(self, fw_spec):
     lp, fw_id = get_lp_and_fw_id_from_task(self, fw_spec=fw_spec)