def get_units(self, unit_ids=None): """Returns one or more compute units identified by their IDs. **Arguments:** * **unit_ids** [`string` or `list of strings`]: The IDs of the compute unit objects to return. **Returns:** * A list of :class:`radical.pilot.ComputeUnit` objects. **Raises:** * :class:`radical.pilot.PilotException` """ if not self._uid: raise IncorrectState(msg="Invalid object instance.") return_list_type = True if (not isinstance(unit_ids, list)) and (unit_ids is not None): return_list_type = False unit_ids = [unit_ids] units = ComputeUnit._get(unit_ids=unit_ids, unit_manager_obj=self) if return_list_type : return units else : return units[0]
def get_units(self, unit_ids=None): """Returns one or more compute units identified by their IDs. **Arguments:** * **unit_ids** [`string` or `list of strings`]: The IDs of the compute unit objects to return. **Returns:** * A list of :class:`radical.pilot.ComputeUnit` objects. **Raises:** * :class:`radical.pilot.PilotException` """ if not self._uid: raise IncorrectState(msg="Invalid object instance.") return_list_type = True if (not isinstance(unit_ids, list)) and (unit_ids is not None): return_list_type = False unit_ids = [unit_ids] units = ComputeUnit._get(unit_ids=unit_ids, unit_manager_obj=self) if return_list_type: return units else: return units[0]
def submit_units(self, unit_descriptions): """Submits on or more :class:`radical.pilot.ComputeUnit` instances to the unit manager. **Arguments:** * **unit_descriptions** [:class:`radical.pilot.ComputeUnitDescription` or list of :class:`radical.pilot.ComputeUnitDescription`]: The description of the compute unit instance(s) to create. **Returns:** * A list of :class:`radical.pilot.ComputeUnit` objects. **Raises:** * :class:`radical.pilot.PilotException` """ if not self._uid: raise IncorrectState(msg="Invalid object instance.") return_list_type = True if not isinstance(unit_descriptions, list): return_list_type = False unit_descriptions = [unit_descriptions] # we return a list of compute units ret = list() # the scheduler will return a dictionary of the form: # { # ud_1 : pilot_id_a, # ud_2 : pilot_id_b # ... # } # # The scheduler may not be able to schedule some units - those will # have 'None' as pilot ID. units = list() for ud in unit_descriptions : units.append (ComputeUnit.create (unit_description=ud, unit_manager_obj=self, local_state=SCHEDULING)) self._worker.publish_compute_units (units=units) schedule = None try: schedule = self._scheduler.schedule (units=units) except Exception as e: logger.exception ("Internal error - unit scheduler failed") raise self.handle_schedule (schedule) if return_list_type : return units else : return units[0]
def submit_units(self, unit_descriptions): """Submits on or more :class:`radical.pilot.ComputeUnit` instances to the unit manager. **Arguments:** * **unit_descriptions** [:class:`radical.pilot.ComputeUnitDescription` or list of :class:`radical.pilot.ComputeUnitDescription`]: The description of the compute unit instance(s) to create. **Returns:** * A list of :class:`radical.pilot.ComputeUnit` objects. **Raises:** * :class:`radical.pilot.PilotException` """ if not self._uid: raise IncorrectState(msg="Invalid object instance.") return_list_type = True if not isinstance(unit_descriptions, list): return_list_type = False unit_descriptions = [unit_descriptions] # we return a list of compute units ret = list() # the scheduler will return a dictionary of the form: # { # ud_1 : pilot_id_a, # ud_2 : pilot_id_b # ... # } # # The scheduler may not be able to schedule some units - those will # have 'None' as pilot ID. units = list() for ud in unit_descriptions: units.append( ComputeUnit.create(unit_description=ud, unit_manager_obj=self, local_state=SCHEDULING)) self._worker.publish_compute_units(units=units) schedule = None try: schedule = self._scheduler.schedule(units=units) except Exception as e: logger.exception("Internal error - unit scheduler failed") raise self.handle_schedule(schedule) if return_list_type: return units else: return units[0]