def wrapper(f): return PythonApp(f, data_flow_kernel=data_flow_kernel, cache=cache, executors=executors, ignore_for_cache=ignore_for_cache, join=join)
def wrapper(f): return PythonApp(f, data_flow_kernel=data_flow_kernel, walltime=walltime, cache=cache, executors=executors)
def __init__(self, methods: List[Union[Callable, Tuple[Callable, Dict]]], queues: MethodServerQueues, timeout: Optional[int] = None, default_executors: Union[str, List[str]] = 'all'): """ Args: methods (list): List of methods to be served. Each element in the list is either a function or a tuple where the first element is a function and the second is a dictionary of the arguments being used to create the Parsl ParslApp see `Parsl documentation <https://parsl.readthedocs.io/en/stable/stubs/parsl.app.app.python_app.html#parsl.app.app.python_app>`_. queues (MethodServerQueues): Queues for the method server timeout (int): Timeout, if desired default_executors: Executor or list of executors to use by default. """ super().__init__(queues, timeout) # Assemble the list of methods self.methods_ = {} for method in methods: # Get the options or use the defaults if isinstance(method, tuple): if len(method) != 2: raise ValueError( 'Method description should a tuple of length 2') function, options = method else: function = method options = {'executors': default_executors} if default_executors == 'all': logger.warning( f'Method {function.__name__} may run on the method server\'s local threads.' ' Consider specifying default_executors') # Make the Parsl app name = function.__name__ # Wrap the function in the timer class wrapped_function = partial(run_and_record_timing, function) app = PythonApp(wrapped_function, **options) # Store it self.methods_[name] = app logger.info( f'Defined {len(self.methods_)} methods: {", ".join(self.methods_.keys())}' ) # If only one method, store a default method self.default_method_ = list(self.methods_.keys())[0] if len( self.methods_) else None if self.default_method_ is not None: logger.info( f'There is only one method, so we are using {self.default_method_} as a default' ) # Create a thread to check if tasks completed successfully self.task_queue = Queue() self.error_checker = _ErrorHandler(self.task_queue) self.error_checker.start()