Execute the tool over the given time interval.
        If an alignment stream is given, the output instances will be aligned to this stream

        :param sources: The source streams (possibly None)
        :param sink: The sink stream
        :param alignment_stream: The alignment stream
        :param interval: The time interval
        :type sources: list[Stream] | tuple[Stream] | None
        :type sink: Stream
        :type alignment_stream: Stream | None
        :type interval: TimeInterval
        :return: None

def execute(self, sources, sink, interval, alignment_stream=None):
        """
        Execute the tool over the given time interval.
        If an alignment stream is given, the output instances will be aligned to this stream

        :param sources: The source streams (possibly None)
        :param sink: The sink stream
        :param alignment_stream: The alignment stream
        :param interval: The time interval
        :type sources: list[Stream] | tuple[Stream] | None
        :type sink: Stream
        :type alignment_stream: Stream | None
        :type interval: TimeInterval
        :return: None
        """
        if not isinstance(interval, TimeInterval):
            raise TypeError('Expected TimeInterval, got {}'.format(type(interval)))
        # logging.info(self.message(interval))

        if interval.end > sink.channel.up_to_timestamp:
            raise StreamNotAvailableError(sink.channel.up_to_timestamp)

        required_intervals = TimeIntervals([interval]) - sink.calculated_intervals

        if not required_intervals.is_empty:
            document_count = 0

            for interval in required_intervals:
                for stream_instance in self._execute(
                        sources=sources, alignment_stream=alignment_stream, interval=interval):
                    sink.writer(stream_instance)
                    document_count += 1
                sink.calculated_intervals += interval

            required_intervals = TimeIntervals([interval]) - sink.calculated_intervals
            if not required_intervals.is_empty:
                # raise ToolExecutionError(required_intervals)
                logging.error("{} execution error for time interval {} on stream {}".format(
                    self.name, interval, sink))

            if not document_count:
                logging.debug("{} did not produce any data for time interval {} on stream {}".format(
                    self.name, interval, sink))

            self.write_to_history(
                interval=interval,
                tool=self.name,
                document_count=document_count
            )