Beispiel #1
0
 def __init__(self, id, block_store):
     self.id = id
     self.block_store = block_store
     self.current_pos = 0
     self.output_ctx = make_local_output(self.id)
     (filename, is_fd) = self.output_ctx.get_filename_or_fd()
     assert not is_fd
     self.output_filename = filename
Beispiel #2
0
 def __init__(self, id, block_store):
     self.id = id
     self.block_store = block_store
     self.current_pos = 0
     self.output_ctx = make_local_output(self.id)
     (filename, is_fd) = self.output_ctx.get_filename_or_fd()
     assert not is_fd
     self.output_filename = filename
Beispiel #3
0
 def __init__(self, output_name, output_index, can_smart_subscribe, may_pipe, make_local_sweetheart, can_accept_fd, executor):
     kwargs = {"may_pipe": may_pipe, "can_use_fd": can_accept_fd}
     if can_smart_subscribe:
         kwargs["subscribe_callback"] = self.subscribe_output
     self.output_ctx = make_local_output(output_name, **kwargs)
     self.may_pipe = may_pipe
     self.make_local_sweetheart = make_local_sweetheart
     self.output_name = output_name
     self.output_index = output_index
     self.watch_chunk_size = None
     self.executor = executor
     self.filename = None
     self.fd = None
Beispiel #4
0
 def __init__(self, output_name, output_index, can_smart_subscribe,
              may_pipe, make_local_sweetheart, can_accept_fd, executor):
     kwargs = {"may_pipe": may_pipe, "can_use_fd": can_accept_fd}
     if can_smart_subscribe:
         kwargs["subscribe_callback"] = self.subscribe_output
     self.output_ctx = make_local_output(output_name, **kwargs)
     self.may_pipe = may_pipe
     self.make_local_sweetheart = make_local_sweetheart
     self.output_name = output_name
     self.output_index = output_index
     self.watch_chunk_size = None
     self.executor = executor
     self.filename = None
     self.fd = None
Beispiel #5
0
    def guarded_execute(self):
        try:
            self.input_refs = self.args['inputs']
        except KeyError:
            self.input_refs = []
        try:
            self.stream_output = self.args['stream_output']
        except KeyError:
            self.stream_output = False
        try:
            self.pipe_output = self.args['pipe_output']
        except KeyError:
            self.pipe_output = False
        try:
            self.eager_fetch = self.args['eager_fetch']
        except KeyError:
            self.eager_fetch = False
        try:
            self.stream_chunk_size = self.args['stream_chunk_size']
        except KeyError:
            self.stream_chunk_size = 67108864

        try:
            self.make_sweetheart = self.args['make_sweetheart']
            if not isinstance(self.make_sweetheart, list):
                self.make_sweetheart = [self.make_sweetheart]
        except KeyError:
            self.make_sweetheart = []

        file_inputs = None
        push_threads = None

        if self.eager_fetch:
            file_inputs = retrieve_filenames_for_refs(self.input_refs,
                                                      self.task_record)
        else:

            push_threads = [
                OngoingFetch(ref,
                             chunk_size=self.stream_chunk_size,
                             task_record=self.task_record,
                             must_block=True) for ref in self.input_refs
            ]

            for thread in push_threads:
                self.context_mgr.add_context(thread)

        # TODO: Make these use OngoingOutputs and the context manager.
        with list_with([
                make_local_output(id, may_pipe=self.pipe_output)
                for id in self.output_ids
        ]) as out_file_contexts:

            if self.stream_output:

                stream_refs = [
                    ctx.get_stream_ref() for ctx in out_file_contexts
                ]
                self.task_record.prepublish_refs(stream_refs)

            # We do these last, as these are the calls which can lead to stalls whilst we await a stream's beginning or end.
            if file_inputs is None:
                file_inputs = []
                for thread in push_threads:
                    (filename, is_blocking) = thread.get_filename()
                    if is_blocking is not None:
                        assert is_blocking is True
                    file_inputs.append(filename)

            file_outputs = [
                filename for (filename, _) in (ctx.get_filename_or_fd()
                                               for ctx in out_file_contexts)
            ]

            self.proc = self.start_process(file_inputs, file_outputs)
            add_running_child(self.proc)

            rc = self.await_process(file_inputs, file_outputs)
            remove_running_child(self.proc)

            self.proc = None

            #        if "trace_io" in self.debug_opts:
            #            transfer_ctx.log_traces()

            if rc != 0:
                raise OSError()

        for i, output in enumerate(out_file_contexts):
            self.output_refs[i] = output.get_completed_ref()

        ciel.engine.publish("worker_event", "Executor: Done")
Beispiel #6
0
    def guarded_execute(self):
        try:
            self.input_refs = self.args['inputs']
        except KeyError:
            self.input_refs = []
        try:
            self.stream_output = self.args['stream_output']
        except KeyError:
            self.stream_output = False
        try:
            self.pipe_output = self.args['pipe_output']
        except KeyError:
            self.pipe_output = False
        try:
            self.eager_fetch = self.args['eager_fetch']
        except KeyError:
            self.eager_fetch = False
        try:
            self.stream_chunk_size = self.args['stream_chunk_size']
        except KeyError:
            self.stream_chunk_size = 67108864

        try:
            self.make_sweetheart = self.args['make_sweetheart']
            if not isinstance(self.make_sweetheart, list):
                self.make_sweetheart = [self.make_sweetheart]
        except KeyError:
            self.make_sweetheart = []

        file_inputs = None
        push_threads = None

        if self.eager_fetch:
            file_inputs = retrieve_filenames_for_refs(self.input_refs, self.task_record)
        else:

            push_threads = [OngoingFetch(ref, chunk_size=self.stream_chunk_size, task_record=self.task_record, must_block=True) for ref in self.input_refs]

            for thread in push_threads:
                self.context_mgr.add_context(thread)

        # TODO: Make these use OngoingOutputs and the context manager.                
        with list_with([make_local_output(id, may_pipe=self.pipe_output) for id in self.output_ids]) as out_file_contexts:

            if self.stream_output:
       
                stream_refs = [ctx.get_stream_ref() for ctx in out_file_contexts]
                self.task_record.prepublish_refs(stream_refs)

            # We do these last, as these are the calls which can lead to stalls whilst we await a stream's beginning or end.
            if file_inputs is None:
                file_inputs = []
                for thread in push_threads:
                    (filename, is_blocking) = thread.get_filename()
                    if is_blocking is not None:
                        assert is_blocking is True
                    file_inputs.append(filename)
            
            file_outputs = [filename for (filename, _) in (ctx.get_filename_or_fd() for ctx in out_file_contexts)]
            
            self.proc = self.start_process(file_inputs, file_outputs)
            add_running_child(self.proc)

            rc = self.await_process(file_inputs, file_outputs)
            remove_running_child(self.proc)

            self.proc = None

            #        if "trace_io" in self.debug_opts:
            #            transfer_ctx.log_traces()

            if rc != 0:
                raise OSError()

        for i, output in enumerate(out_file_contexts):
            self.output_refs[i] = output.get_completed_ref()

        ciel.engine.publish("worker_event", "Executor: Done")