def get_fw_by_id(self, fw_id): """ Given a FireWork id, give back a FireWork object :param fw_id: FireWork id (int) :return: FireWork object """ fw_dict = self.fireworks.find_one({'fw_id': fw_id}) if not fw_dict: raise ValueError('No FireWork exists with id: {}'.format(fw_id)) # recreate launches from the launch collection launches = [] for launch_id in fw_dict['launches']: launches.append(self.get_launch_by_id(launch_id).to_dict()) fw_dict['launches'] = launches return FireWork.from_dict(fw_dict)
def get_fw_by_id(self, fw_id): """ Given a FireWork id, give back a FireWork object :param fw_id: FireWork id (int) :return: FireWork object """ fw_dict = self.fireworks.find_one({'fw_id': fw_id}) if not fw_dict: raise ValueError('No FireWork exists with id: {}'.format(fw_id)) # recreate launches from the launch collection launches = [] for launch_id in fw_dict['launches']: launches.append(self.get_launch_by_id(launch_id).to_dict()) fw_dict['launches'] = launches return FireWork.from_dict(fw_dict)
def get_fw_by_id(self, fw_id): """ Given a FireWork id, give back a FireWork object :param fw_id: FireWork id (int) :return: FireWork object """ fw_dict = self.fireworks.find_one({'fw_id': fw_id}) if not fw_dict: raise ValueError('No FireWork exists with id: {}'.format(fw_id)) # recreate launches from the launch collection fw_dict['launches'] = list(self.launches.find( {'launch_id': {"$in": fw_dict['launches']}})) fw_dict['archived_launches'] = list(self.launches.find( {'launch_id': {"$in": fw_dict['archived_launches']}})) return FireWork.from_dict(fw_dict)
def get_fw_by_id(self, fw_id): """ Given a FireWork id, give back a FireWork object :param fw_id: FireWork id (int) :return: FireWork object """ fw_dict = self.fireworks.find_one({'fw_id': fw_id}) if not fw_dict: raise ValueError('No FireWork exists with id: {}'.format(fw_id)) # recreate launches from the launch collection fw_dict['launches'] = list(self.launches.find( {'launch_id': {"$in": fw_dict['launches']}})) fw_dict['archived_launches'] = list(self.launches.find( {'launch_id': {"$in": fw_dict['archived_launches']}})) return FireWork.from_dict(fw_dict)
def from_dict(cls, m_dict): return Workflow([FireWork.from_dict(f) for f in m_dict['fws']], Workflow.Links.from_dict(m_dict['links']))
def from_dict(cls, m_dict): return Workflow([FireWork.from_dict(f) for f in m_dict['fws']], Workflow.Links.from_dict(m_dict['links']))