Skip to content

Custom Task

Quantum methods for running custom tasks.

CustomTask

For running custom tasks.

Source code in src/scruby/mixins/custom_task.py
class CustomTask:
    """For running custom tasks."""

    @final
    def run_custom_task(
        self,
        custom_task_fn: Callable,
        filter_fn: Callable = lambda _: True,
        **kwargs,
    ) -> Any:
        """For run a custom task.

        Attention:
            - The search is based on the effect of a quantum loop.
            - The search effectiveness depends on the number of processor threads.

        Args:
            custom_task_fn (Callable): A function that execute the custom task.

        Returns:
            The result of a custom task.
        """
        hash_reduce_left: int = self._hash_reduce_left
        assert hash_reduce_left != 0, "Scruby.run(hash_reduce_left = 0) - Not valid for `run_custom_task` method."

        return custom_task_fn(
            search_task_fn=self._task_find,
            filter_fn=filter_fn,
            hash_reduce_left=hash_reduce_left,
            branch_numbers=range(self._max_number_branch),
            class_model=self._class_model,
            max_workers=self._max_workers,
            stop_signal=Event(),
            **kwargs,
        )

run_custom_task(custom_task_fn, filter_fn=lambda _: True, **kwargs)

For run a custom task.

Attention
  • The search is based on the effect of a quantum loop.
  • The search effectiveness depends on the number of processor threads.

Parameters:

Name Type Description Default
custom_task_fn Callable

A function that execute the custom task.

required

Returns:

Type Description
Any

The result of a custom task.

Source code in src/scruby/mixins/custom_task.py
@final
def run_custom_task(
    self,
    custom_task_fn: Callable,
    filter_fn: Callable = lambda _: True,
    **kwargs,
) -> Any:
    """For run a custom task.

    Attention:
        - The search is based on the effect of a quantum loop.
        - The search effectiveness depends on the number of processor threads.

    Args:
        custom_task_fn (Callable): A function that execute the custom task.

    Returns:
        The result of a custom task.
    """
    hash_reduce_left: int = self._hash_reduce_left
    assert hash_reduce_left != 0, "Scruby.run(hash_reduce_left = 0) - Not valid for `run_custom_task` method."

    return custom_task_fn(
        search_task_fn=self._task_find,
        filter_fn=filter_fn,
        hash_reduce_left=hash_reduce_left,
        branch_numbers=range(self._max_number_branch),
        class_model=self._class_model,
        max_workers=self._max_workers,
        stop_signal=Event(),
        **kwargs,
    )