Skip to content

Commit

Permalink
misc: pre-commit
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Feb 24, 2025
1 parent 7fc8f45 commit 49991fe
Show file tree
Hide file tree
Showing 8 changed files with 29 additions and 29 deletions.
1 change: 1 addition & 0 deletions src/plumpy/broadcast_filter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# -*- coding: utf-8 -*-
# type: ignore
import re
import typing

Expand Down
3 changes: 1 addition & 2 deletions src/plumpy/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ def play_process(self, pid: 'PID_TYPE') -> ProcessResult:
...

def play_all(self) -> None:
"""Play all processes that are subscribed to the same coordinator
"""
"""Play all processes that are subscribed to the same coordinator"""

def kill_process(self, pid: 'PID_TYPE', msg_text: str | None = None) -> Any:
"""Kill the process
Expand Down
8 changes: 6 additions & 2 deletions src/plumpy/coordinator.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

from typing import TYPE_CHECKING, Any, Callable, Hashable, Protocol
from re import Pattern
from typing import TYPE_CHECKING, Any, Callable, Hashable, Protocol

if TYPE_CHECKING:
ID_TYPE = Hashable
Expand Down Expand Up @@ -36,7 +36,11 @@ def unhook_broadcast_receiver(self, identifier: 'ID_TYPE | None') -> None: ...

def unhook_task_receiver(self, identifier: 'ID_TYPE') -> None: ...

def rpc_send(self, recipient_id: Hashable, msg: Any,) -> Any: ...
def rpc_send(
self,
recipient_id: Hashable,
msg: Any,
) -> Any: ...

def broadcast_send(
self,
Expand Down
1 change: 0 additions & 1 deletion src/plumpy/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import logging
from typing import TYPE_CHECKING, Any, Dict, Optional, Sequence, Union, cast

from plumpy.coordinator import Coordinator
from plumpy.exceptions import PersistenceError, TaskRejectedError

from . import loaders, persistence
Expand Down
35 changes: 14 additions & 21 deletions src/plumpy/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,7 @@
cast,
)

import kiwipy

from plumpy.broadcast_filter import BroadcastFilter
from plumpy.broadcast_filter import BroadcastFilter # type: ignore
from plumpy.coordinator import Coordinator

try:
Expand Down Expand Up @@ -944,19 +942,16 @@ def _fire_event(self, evt: Callable[..., Any], *args: Any, **kwargs: Any) -> Non
# region Communication

def message_receive(self, msg: MessageType) -> Any:
"""
Coroutine called when the process receives a message from the communicator
"""Coroutine called when the process receives a message from the communicator
:param _comm: the communicator that sent the message
:param msg: the message
:return: the outcome of processing the message, the return value will be sent back as a response to the sender
"""
# self.logger.debug(
# "Process<%s>: received RPC message with communicator '%s': %r",
# self.pid,
# _comm,
# msg,
# )
self.logger.debug(
"Process<%s>: received RPC message: %r",
self.pid,
msg,
)

intent = msg[message.INTENT_KEY]

Expand All @@ -977,19 +972,17 @@ def message_receive(self, msg: MessageType) -> Any:
def broadcast_receive(
self, msg: MessageType, sender: Any, subject: Any, correlation_id: Any
) -> Optional[concurrent.futures.Future]:
"""
Coroutine called when the process receives a message from the communicator
"""Coroutine called when the process receives a message from the communicator
:param msg: the message
"""
self.logger.debug(
"Process<%s>: received broadcast message '%s': %r",
self.pid,
subject,
msg,
)

# self.logger.debug(
# "Process<%s>: received broadcast message '%s' with communicator '%s': %r",
# self.pid,
# subject,
# _comm,
# msg,
# )
# If we get a message we recognise then action it, otherwise ignore
fn = None
if subject == message.Intent.PLAY:
Expand Down
4 changes: 3 additions & 1 deletion src/plumpy/rmq/communications.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,9 @@ def converted(communicator: kiwipy.Communicator, *args: Any, **kwargs: Any) -> k
CommT = TypeVar('CommT', bound=kiwipy.Communicator)


def wrap_communicator(communicator: CommT, loop: Optional[asyncio.AbstractEventLoop] = None) -> 'LoopCommunicator[CommT]':
def wrap_communicator(
communicator: CommT, loop: Optional[asyncio.AbstractEventLoop] = None
) -> 'LoopCommunicator[CommT]':
"""
Wrap a communicator such that all callbacks made to any subscribers are scheduled on the
given event loop.
Expand Down
3 changes: 2 additions & 1 deletion src/plumpy/rmq/process_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@
ProcessStatus = Any


# FIXME: the class not fit typing of ProcessController protocol
# This class not conform with typing of ProcessController protocol.
# Does't matter too much, since this controller is not directly used as the controller by downstream.
class RemoteProcessController:
"""
Control remote processes using coroutines that will send messages and wait
Expand Down
3 changes: 2 additions & 1 deletion tests/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
"""Utilities for tests"""
from __future__ import annotations

import asyncio
import collections
Expand Down Expand Up @@ -105,7 +106,7 @@ def hook_broadcast_receiver(
self._broadcast_receivers[identifier] = receiver
return identifier

def unhook_broadcast_receiver(self, identifier: 'ID_TYPE | None') -> None:
def unhook_broadcast_receiver(self, identifier: 'ID_TYPE | None') -> None:
self._ensure_open()
try:
del self._broadcast_receivers[identifier]
Expand Down

0 comments on commit 49991fe

Please sign in to comment.