Repository: ray-project/ray
File: python/ray/data/_internal/execution/interfaces/physical_operator.py (Python)

Code before:
        This release any Ray resources acquired by this operator such as active
        tasks, actors, and objects.
        """
        if self._shutdown:
            return
        elif not self._started:
            raise ValueError("Operator must be started before being shutdown.")

        # Mark operator as shut down
        self._shutdown = True
        # Time shutdown sequence duration
        with timer.timer():
            self._do_shutdown(force)

    def _do_shutdown(self, force: bool):
        # Default implementation simply cancels any outstanding active task
        self._cancel_active_tasks(force=force)

    def current_logical_usage(self) -> ExecutionResources:
        """Returns the current estimated CPU, GPU, and memory usage of this operator,
        excluding object store memory.

        This method is called by the executor to decide how to allocate processors
        between different operators.
        """
        return ExecutionResources(0, 0, 0, 0)

    def running_logical_usage(self) -> ExecutionResources:
        """Returns the estimated running CPU, GPU, and memory usage of this operator,
        excluding object store memory.

        This method is called by the resource manager and the streaming
        executor to display the number of currently running CPUs, GPUs, and memory in
        the progress bar.

        Note, this method returns `current_logical_usage() -
        pending_logical_usage()` by default. Subclasses should only override
        `pending_logical_usage()` if needed.
        """
        usage = self.current_logical_usage()
        usage = usage.subtract(self.pending_logical_usage())
        return usage

    def pending_logical_usage(self) -> ExecutionResources:
        """Returns the estimated pending CPU, GPU, and memory usage of this operator,
        excluding object store memory.

        This method is called by the resource manager and the streaming
        executor to display the number of currently pending actors in the
        progress bar.
        """

Review comment (suggestion):
Nit: Consider using `ExecutionResources.zero()` for readability

Code after:
        This release any Ray resources acquired by this operator such as active
        tasks, actors, and objects.
        """
        if self._shutdown:
            return
        elif not self._started:
            raise ValueError("Operator must be started before being shutdown.")

        # Mark operator as shut down
        self._shutdown = True
        # Time shutdown sequence duration
        with timer.timer():
            self._do_shutdown(force)

    def _do_shutdown(self, force: bool):
        # Default implementation simply cancels any outstanding active task
        self._cancel_active_tasks(force=force)

    def current_logical_usage(self) -> ExecutionResources:
        """Returns the current estimated CPU, GPU, and memory usage of this operator,
        excluding object store memory.

        This method is called by the executor to decide how to allocate resources
        between different operators.
        """
        return ExecutionResources.zero()

    def running_logical_usage(self) -> ExecutionResources:
        """Returns the estimated running CPU, GPU, and memory usage of this operator,
        excluding object store memory.

        This method is called by the resource manager and the streaming
        executor to display the number of currently running CPUs, GPUs, and memory in
        the progress bar.

        Note, this method returns `current_logical_usage() -
        pending_logical_usage()` by default. Subclasses should only override
        `pending_logical_usage()` if needed.
        """
        usage = self.current_logical_usage()
        usage = usage.subtract(self.pending_logical_usage())
        return usage

    def pending_logical_usage(self) -> ExecutionResources:
        """Returns the estimated pending CPU, GPU, and memory usage of this operator,
        excluding object store memory.

        This method is called by the resource manager and the streaming
        executor to display the number of currently pending actors in the
        progress bar.
        """