From ca8afca9143b8cd5917ba8c7ef5b866370f1dbdd Mon Sep 17 00:00:00 2001 From: Jusong Yu Date: Wed, 27 Nov 2024 16:18:08 +0100 Subject: [PATCH] Bump ruff to 0.8.0 for sort the imports --- .pre-commit-config.yaml | 2 +- docs/source/tutorial.ipynb | 203 +++++++++++++--------------- examples/process_launch.py | 1 + examples/process_wait_and_resume.py | 3 +- src/plumpy/base/state_machine.py | 2 +- src/plumpy/base/utils.py | 2 +- src/plumpy/communications.py | 2 +- src/plumpy/events.py | 10 +- src/plumpy/exceptions.py | 2 +- src/plumpy/futures.py | 2 +- src/plumpy/loaders.py | 2 +- src/plumpy/persistence.py | 8 +- src/plumpy/ports.py | 2 +- src/plumpy/process_comms.py | 6 +- src/plumpy/process_states.py | 18 +-- src/plumpy/processes.py | 2 +- src/plumpy/workchains.py | 2 +- test/notebooks/get_event_loop.ipynb | 4 +- test/persistence/test_inmemory.py | 1 - test/persistence/test_pickle.py | 1 - test/rmq/test_communicator.py | 3 +- test/rmq/test_process_comms.py | 5 +- test/test_communications.py | 1 + test/test_events.py | 1 + test/test_expose.py | 1 - test/test_loaders.py | 3 +- test/test_persistence.py | 3 +- test/test_process_comms.py | 4 +- test/test_processes.py | 4 +- test/test_utils.py | 1 + test/test_workchains.py | 3 +- 31 files changed, 148 insertions(+), 156 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index d90a06a1..69b1054e 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: args: [--line-length=120, --fail-on-change] - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.5.0 + rev: v0.8.0 hooks: - id: ruff-format exclude: &exclude_ruff > diff --git a/docs/source/tutorial.ipynb b/docs/source/tutorial.ipynb index 90194728..c1fdb3b2 100644 --- a/docs/source/tutorial.ipynb +++ b/docs/source/tutorial.ipynb @@ -34,10 +34,11 @@ "outputs": [], "source": [ "import asyncio\n", - "from pprint import pprint\n", "import time\n", + "from pprint import pprint\n", "\n", "import kiwipy\n", + "\n", "import plumpy\n", "\n", "# this is required because jupyter is already running an event loop\n", @@ -116,16 +117,16 @@ ], "source": [ "class SimpleProcess(plumpy.Process):\n", - "\n", " def run(self):\n", " print(self.state.name)\n", - " \n", + "\n", + "\n", "process = SimpleProcess()\n", "print(process.state.name)\n", "process.execute()\n", "print(process.state.name)\n", - "print(\"Success\", process.is_successful)\n", - "print(\"Result\", process.result())" + "print('Success', process.is_successful)\n", + "print('Result', process.result())" ] }, { @@ -204,17 +205,16 @@ ], "source": [ "class SpecProcess(plumpy.Process):\n", - " \n", " @classmethod\n", " def define(cls, spec: plumpy.ProcessSpec):\n", " super().define(spec)\n", " spec.input('input1', valid_type=str, help='A help string')\n", " spec.output('output1')\n", - " \n", + "\n", " spec.input_namespace('input2')\n", " spec.input('input2.input2a')\n", " spec.input('input2.input2b', default='default')\n", - " \n", + "\n", " spec.output_namespace('output2')\n", " spec.output('output2.output2a')\n", " spec.output('output2.output2b')\n", @@ -223,12 +223,10 @@ " self.out('output1', self.inputs.input1)\n", " self.out('output2.output2a', self.inputs.input2.input2a)\n", " self.out('output2.output2b', self.inputs.input2.input2b)\n", - " \n", + "\n", + "\n", "pprint(SpecProcess.spec().get_description())\n", - "process = SpecProcess(inputs={\n", - " 'input1': 'my input',\n", - " 'input2': {'input2a': 'other input'}\n", - "})\n", + "process = SpecProcess(inputs={'input1': 'my input', 'input2': {'input2a': 'other input'}})\n", "process.execute()\n", "process.outputs" ] @@ -276,20 +274,20 @@ ], "source": [ "class ContinueProcess(plumpy.Process):\n", - "\n", " def run(self):\n", - " print(\"running\")\n", + " print('running')\n", " return plumpy.Continue(self.continue_fn)\n", - " \n", + "\n", " def continue_fn(self):\n", - " print(\"continuing\")\n", + " print('continuing')\n", " # message is stored in the process status\n", - " return plumpy.Kill(\"I was killed\")\n", - " \n", + " return plumpy.Kill('I was killed')\n", + "\n", + "\n", "process = ContinueProcess()\n", "try:\n", " process.execute()\n", - "except plumpy.KilledError as error:\n", + "except plumpy.KilledError:\n", " pass\n", "\n", "print(process.state)\n", @@ -330,7 +328,6 @@ ], "source": [ "class WaitListener(plumpy.ProcessListener):\n", - "\n", " def on_process_running(self, process):\n", " print(process.state.name)\n", "\n", @@ -338,14 +335,15 @@ " print(process.state.name)\n", " process.resume()\n", "\n", - "class WaitProcess(plumpy.Process):\n", "\n", + "class WaitProcess(plumpy.Process):\n", " def run(self):\n", " return plumpy.Wait(self.resume_fn)\n", - " \n", + "\n", " def resume_fn(self):\n", " return plumpy.Stop(None, True)\n", "\n", + "\n", "process = WaitProcess()\n", "print(process.state.name)\n", "\n", @@ -394,33 +392,32 @@ ], "source": [ "async def async_fn():\n", - " print(\"async_fn start\")\n", - " await asyncio.sleep(.01)\n", - " print(\"async_fn end\")\n", + " print('async_fn start')\n", + " await asyncio.sleep(0.01)\n", + " print('async_fn end')\n", + "\n", "\n", "class NamedProcess(plumpy.Process):\n", - " \n", " @classmethod\n", " def define(cls, spec: plumpy.ProcessSpec):\n", " super().define(spec)\n", " spec.input('name')\n", "\n", " def run(self):\n", - " print(self.inputs.name, \"run\")\n", + " print(self.inputs.name, 'run')\n", " return plumpy.Continue(self.continue_fn)\n", "\n", " def continue_fn(self):\n", - " print(self.inputs.name, \"continued\")\n", + " print(self.inputs.name, 'continued')\n", + "\n", + "\n", + "process1 = NamedProcess({'name': 'process1'})\n", + "process2 = NamedProcess({'name': 'process2'})\n", "\n", - "process1 = NamedProcess({\"name\": \"process1\"})\n", - "process2 = NamedProcess({\"name\": \"process2\"})\n", "\n", "async def execute():\n", - " await asyncio.gather(\n", - " async_fn(),\n", - " process1.step_until_terminated(),\n", - " process2.step_until_terminated()\n", - " )\n", + " await asyncio.gather(async_fn(), process1.step_until_terminated(), process2.step_until_terminated())\n", + "\n", "\n", "plumpy.get_event_loop().run_until_complete(execute())" ] @@ -468,31 +465,33 @@ ], "source": [ "class SimpleProcess(plumpy.Process):\n", - " \n", " def run(self):\n", " print(self.get_name())\n", - " \n", - "class PauseProcess(plumpy.Process):\n", "\n", + "\n", + "class PauseProcess(plumpy.Process):\n", " def run(self):\n", - " print(f\"{self.get_name()}: pausing\")\n", + " print(f'{self.get_name()}: pausing')\n", " self.pause()\n", - " print(f\"{self.get_name()}: continue step\")\n", + " print(f'{self.get_name()}: continue step')\n", " return plumpy.Continue(self.next_step)\n", - " \n", + "\n", " def next_step(self):\n", - " print(f\"{self.get_name()}: next step\")\n", + " print(f'{self.get_name()}: next step')\n", + "\n", "\n", "pause_proc = PauseProcess()\n", "simple_proc = SimpleProcess()\n", "\n", + "\n", "async def play(proc):\n", " while True:\n", " if proc.paused:\n", - " print(f\"{proc.get_name()}: playing (state={proc.state.name})\")\n", + " print(f'{proc.get_name()}: playing (state={proc.state.name})')\n", " proc.play()\n", " break\n", "\n", + "\n", "async def execute():\n", " return await asyncio.gather(\n", " pause_proc.step_until_terminated(),\n", @@ -500,6 +499,7 @@ " play(pause_proc),\n", " )\n", "\n", + "\n", "outputs = plumpy.get_event_loop().run_until_complete(execute())" ] }, @@ -555,7 +555,8 @@ "\n", " def step2(self):\n", " print('step2')\n", - " \n", + "\n", + "\n", "workchain = SimpleWorkChain()\n", "output = workchain.execute()" ] @@ -601,11 +602,7 @@ " super().define(spec)\n", " spec.input('run', valid_type=bool)\n", "\n", - " spec.outline(\n", - " plumpy.if_(cls.if_step)(\n", - " cls.conditional_step\n", - " )\n", - " )\n", + " spec.outline(plumpy.if_(cls.if_step)(cls.conditional_step))\n", "\n", " def if_step(self):\n", " print(' if')\n", @@ -613,12 +610,13 @@ "\n", " def conditional_step(self):\n", " print(' conditional')\n", - " \n", - "workchain = IfWorkChain({\"run\": False})\n", + "\n", + "\n", + "workchain = IfWorkChain({'run': False})\n", "print('execute False')\n", "output = workchain.execute()\n", "\n", - "workchain = IfWorkChain({\"run\": True})\n", + "workchain = IfWorkChain({'run': True})\n", "print('execute True')\n", "output = workchain.execute()" ] @@ -666,23 +664,19 @@ " super().define(spec)\n", " spec.input('steps', valid_type=int, default=3)\n", "\n", - " spec.outline(\n", - " cls.init_step,\n", - " plumpy.while_(cls.while_step)(\n", - " cls.conditional_step\n", - " )\n", - " )\n", - " \n", + " spec.outline(cls.init_step, plumpy.while_(cls.while_step)(cls.conditional_step))\n", + "\n", " def init_step(self):\n", " self.ctx.iterator = 0\n", "\n", " def while_step(self):\n", " self.ctx.iterator += 1\n", - " return (self.ctx.iterator <= self.inputs.steps)\n", + " return self.ctx.iterator <= self.inputs.steps\n", "\n", " def conditional_step(self):\n", " print('step', self.ctx.iterator)\n", - " \n", + "\n", + "\n", "workchain = WhileWorkChain()\n", "output = workchain.execute()" ] @@ -714,13 +708,12 @@ "outputs": [], "source": [ "async def awaitable_func(msg):\n", - " await asyncio.sleep(.01)\n", + " await asyncio.sleep(0.01)\n", " print(msg)\n", " return True\n", - " \n", "\n", - "class InternalProcess(plumpy.Process):\n", "\n", + "class InternalProcess(plumpy.Process):\n", " @classmethod\n", " def define(cls, spec):\n", " super().define(spec)\n", @@ -733,7 +726,6 @@ "\n", "\n", "class InterstepWorkChain(plumpy.WorkChain):\n", - "\n", " @classmethod\n", " def define(cls, spec):\n", " super().define(spec)\n", @@ -745,31 +737,24 @@ " cls.step2,\n", " cls.step3,\n", " )\n", - " \n", + "\n", " def step1(self):\n", " print(self.inputs.name, 'step1')\n", "\n", " def step2(self):\n", " print(self.inputs.name, 'step2')\n", - " time.sleep(.01)\n", - " \n", + " time.sleep(0.01)\n", + "\n", " if self.inputs.awaitable:\n", " self.to_context(\n", - " awaitable=asyncio.ensure_future(\n", - " awaitable_func(f'{self.inputs.name} step2 awaitable'),\n", - " loop=self.loop\n", - " )\n", + " awaitable=asyncio.ensure_future(awaitable_func(f'{self.inputs.name} step2 awaitable'), loop=self.loop)\n", " )\n", " if self.inputs.process:\n", - " self.to_context(\n", - " process=self.launch(\n", - " InternalProcess, \n", - " inputs={'name': f'{self.inputs.name} step2 process'})\n", - " )\n", + " self.to_context(process=self.launch(InternalProcess, inputs={'name': f'{self.inputs.name} step2 process'}))\n", "\n", " def step3(self):\n", " print(self.inputs.name, 'step3')\n", - " print(f\" ctx={self.ctx}\")" + " print(f' ctx={self.ctx}')" ] }, { @@ -803,11 +788,10 @@ "wkchain1 = InterstepWorkChain({'name': 'wkchain1'})\n", "wkchain2 = InterstepWorkChain({'name': 'wkchain2'})\n", "\n", + "\n", "async def execute():\n", - " return await asyncio.gather(\n", - " wkchain1.step_until_terminated(),\n", - " wkchain2.step_until_terminated()\n", - " )\n", + " return await asyncio.gather(wkchain1.step_until_terminated(), wkchain2.step_until_terminated())\n", + "\n", "\n", "output = plumpy.get_event_loop().run_until_complete(execute())" ] @@ -847,11 +831,10 @@ "wkchain1 = InterstepWorkChain({'name': 'wkchain1', 'process': True})\n", "wkchain2 = InterstepWorkChain({'name': 'wkchain2', 'process': True})\n", "\n", + "\n", "async def execute():\n", - " return await asyncio.gather(\n", - " wkchain1.step_until_terminated(),\n", - " wkchain2.step_until_terminated()\n", - " )\n", + " return await asyncio.gather(wkchain1.step_until_terminated(), wkchain2.step_until_terminated())\n", + "\n", "\n", "output = plumpy.get_event_loop().run_until_complete(execute())" ] @@ -882,11 +865,10 @@ "wkchain1 = InterstepWorkChain({'name': 'wkchain1', 'awaitable': True})\n", "wkchain2 = InterstepWorkChain({'name': 'wkchain2', 'awaitable': True})\n", "\n", + "\n", "async def execute():\n", - " return await asyncio.gather(\n", - " wkchain1.step_until_terminated(),\n", - " wkchain2.step_until_terminated()\n", - " )\n", + " return await asyncio.gather(wkchain1.step_until_terminated(), wkchain2.step_until_terminated())\n", + "\n", "\n", "output = plumpy.get_event_loop().run_until_complete(execute())" ] @@ -926,11 +908,10 @@ "wkchain1 = InterstepWorkChain({'name': 'wkchain1', 'process': True, 'awaitable': True})\n", "wkchain2 = InterstepWorkChain({'name': 'wkchain2', 'process': True, 'awaitable': True})\n", "\n", + "\n", "async def execute():\n", - " return await asyncio.gather(\n", - " wkchain1.step_until_terminated(),\n", - " wkchain2.step_until_terminated()\n", - " )\n", + " return await asyncio.gather(wkchain1.step_until_terminated(), wkchain2.step_until_terminated())\n", + "\n", "\n", "output = plumpy.get_event_loop().run_until_complete(execute())" ] @@ -972,8 +953,8 @@ "source": [ "persister = plumpy.InMemoryPersister()\n", "\n", - "class PersistWorkChain(plumpy.WorkChain):\n", "\n", + "class PersistWorkChain(plumpy.WorkChain):\n", " @classmethod\n", " def define(cls, spec):\n", " super().define(spec)\n", @@ -982,10 +963,10 @@ " cls.step2,\n", " cls.step3,\n", " )\n", - " \n", + "\n", " def __repr__(self):\n", - " return f\"PersistWorkChain(ctx={self.ctx})\"\n", - " \n", + " return f'PersistWorkChain(ctx={self.ctx})'\n", + "\n", " def init_step(self):\n", " self.ctx.step = 1\n", " persister.save_checkpoint(self, 'init')\n", @@ -997,7 +978,8 @@ " def step3(self):\n", " self.ctx.step += 1\n", " persister.save_checkpoint(self, 'step3')\n", - " \n", + "\n", + "\n", "workchain = PersistWorkChain()\n", "workchain.execute()\n", "workchain" @@ -1129,9 +1111,11 @@ "source": [ "communicator = kiwipy.LocalCommunicator()\n", "\n", + "\n", "class SimpleProcess(plumpy.Process):\n", " pass\n", "\n", + "\n", "process = SimpleProcess(communicator=communicator)\n", "\n", "pprint(communicator.rpc_send(str(process.pid), plumpy.STATUS_MSG).result())" @@ -1161,43 +1145,42 @@ ], "source": [ "class ControlledWorkChain(plumpy.WorkChain):\n", - "\n", " @classmethod\n", " def define(cls, spec):\n", " super().define(spec)\n", " spec.input('steps', valid_type=int, default=10)\n", " spec.output('result', valid_type=int)\n", "\n", - " spec.outline(\n", - " cls.init_step,\n", - " plumpy.while_(cls.while_step)(cls.loop_step),\n", - " cls.final_step\n", - " )\n", - " \n", + " spec.outline(cls.init_step, plumpy.while_(cls.while_step)(cls.loop_step), cls.final_step)\n", + "\n", " def init_step(self):\n", " self.ctx.iterator = 0\n", "\n", " def while_step(self):\n", - " return (self.ctx.iterator <= self.inputs.steps)\n", - " \n", + " return self.ctx.iterator <= self.inputs.steps\n", + "\n", " def loop_step(self):\n", " self.ctx.iterator += 1\n", "\n", " def final_step(self):\n", " self.out('result', self.ctx.iterator)\n", "\n", + "\n", "loop_communicator = plumpy.wrap_communicator(kiwipy.LocalCommunicator())\n", "loop_communicator.add_task_subscriber(plumpy.ProcessLauncher())\n", "controller = plumpy.RemoteProcessController(loop_communicator)\n", "\n", "wkchain = ControlledWorkChain(communicator=loop_communicator)\n", - " \n", + "\n", + "\n", "async def run_wait():\n", " return await controller.launch_process(ControlledWorkChain)\n", "\n", + "\n", "async def run_nowait():\n", " return await controller.launch_process(ControlledWorkChain, nowait=True)\n", "\n", + "\n", "print(plumpy.get_event_loop().run_until_complete(run_wait()))\n", "print(plumpy.get_event_loop().run_until_complete(run_nowait()))" ] diff --git a/examples/process_launch.py b/examples/process_launch.py index 3aa46fdc..645af0fd 100644 --- a/examples/process_launch.py +++ b/examples/process_launch.py @@ -4,6 +4,7 @@ import tempfile import kiwipy + import plumpy diff --git a/examples/process_wait_and_resume.py b/examples/process_wait_and_resume.py index f92fb2f7..d4aa20b4 100644 --- a/examples/process_wait_and_resume.py +++ b/examples/process_wait_and_resume.py @@ -1,7 +1,8 @@ # -*- coding: utf-8 -*- -import plumpy from kiwipy import rmq +import plumpy + class WaitForResumeProc(plumpy.Process): def run(self): diff --git a/src/plumpy/base/state_machine.py b/src/plumpy/base/state_machine.py index e177dd13..d99d0705 100644 --- a/src/plumpy/base/state_machine.py +++ b/src/plumpy/base/state_machine.py @@ -14,7 +14,7 @@ from .utils import call_with_super_check, super_check -__all__ = ['StateMachine', 'StateMachineMeta', 'event', 'TransitionFailed'] +__all__ = ['StateMachine', 'StateMachineMeta', 'TransitionFailed', 'event'] _LOGGER = logging.getLogger(__name__) diff --git a/src/plumpy/base/utils.py b/src/plumpy/base/utils.py index 232c5d26..8c35b903 100644 --- a/src/plumpy/base/utils.py +++ b/src/plumpy/base/utils.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from typing import Any, Callable -__all__ = ['super_check', 'call_with_super_check'] +__all__ = ['call_with_super_check', 'super_check'] def super_check(wrapped: Callable[..., Any]) -> Callable[..., Any]: diff --git a/src/plumpy/communications.py b/src/plumpy/communications.py index e1950a34..1d7e775b 100644 --- a/src/plumpy/communications.py +++ b/src/plumpy/communications.py @@ -12,8 +12,8 @@ __all__ = [ 'Communicator', - 'RemoteException', 'DeliveryFailed', + 'RemoteException', 'TaskRejected', 'plum_to_kiwi_future', 'wrap_communicator', diff --git a/src/plumpy/events.py b/src/plumpy/events.py index b37241a4..3de81987 100644 --- a/src/plumpy/events.py +++ b/src/plumpy/events.py @@ -6,13 +6,13 @@ from typing import TYPE_CHECKING, Any, Callable, Dict, Optional, Sequence __all__ = [ - 'new_event_loop', - 'set_event_loop', + 'PlumpyEventLoopPolicy', 'get_event_loop', + 'new_event_loop', + 'reset_event_loop_policy', 'run_until_complete', + 'set_event_loop', 'set_event_loop_policy', - 'reset_event_loop_policy', - 'PlumpyEventLoopPolicy', ] if TYPE_CHECKING: @@ -73,7 +73,7 @@ def run_until_complete(future: asyncio.Future, loop: Optional[asyncio.AbstractEv class ProcessCallback: """Object returned by callback registration methods.""" - __slots__ = ('_callback', '_args', '_kwargs', '_process', '_cancelled', '__weakref__') + __slots__ = ('__weakref__', '_args', '_callback', '_cancelled', '_kwargs', '_process') def __init__( self, process: 'Process', callback: Callable[..., Any], args: Sequence[Any], kwargs: Dict[str, Any] diff --git a/src/plumpy/exceptions.py b/src/plumpy/exceptions.py index 40d3e12d..70b5aa2d 100644 --- a/src/plumpy/exceptions.py +++ b/src/plumpy/exceptions.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from typing import Optional -__all__ = ['KilledError', 'UnsuccessfulResult', 'InvalidStateError', 'PersistenceError', 'ClosedError'] +__all__ = ['ClosedError', 'InvalidStateError', 'KilledError', 'PersistenceError', 'UnsuccessfulResult'] class KilledError(Exception): diff --git a/src/plumpy/futures.py b/src/plumpy/futures.py index 99d03fc3..161244cd 100644 --- a/src/plumpy/futures.py +++ b/src/plumpy/futures.py @@ -8,7 +8,7 @@ import kiwipy -__all__ = ['Future', 'gather', 'chain', 'copy_future', 'CancelledError', 'create_task'] +__all__ = ['CancelledError', 'Future', 'chain', 'copy_future', 'create_task', 'gather'] CancelledError = kiwipy.CancelledError diff --git a/src/plumpy/loaders.py b/src/plumpy/loaders.py index 2da2e57c..a01f9b60 100644 --- a/src/plumpy/loaders.py +++ b/src/plumpy/loaders.py @@ -3,7 +3,7 @@ import importlib from typing import Any, Optional -__all__ = ['ObjectLoader', 'DefaultObjectLoader', 'set_object_loader', 'get_object_loader'] +__all__ = ['DefaultObjectLoader', 'ObjectLoader', 'get_object_loader', 'set_object_loader'] class ObjectLoader(metaclass=abc.ABCMeta): diff --git a/src/plumpy/persistence.py b/src/plumpy/persistence.py index 23c66a57..ba755bc5 100644 --- a/src/plumpy/persistence.py +++ b/src/plumpy/persistence.py @@ -19,14 +19,14 @@ __all__ = [ 'Bundle', + 'InMemoryPersister', + 'LoadSaveContext', + 'PersistedCheckpoint', 'Persister', 'PicklePersister', - 'auto_persist', 'Savable', 'SavableFuture', - 'LoadSaveContext', - 'PersistedCheckpoint', - 'InMemoryPersister', + 'auto_persist', ] PersistedCheckpoint = collections.namedtuple('PersistedCheckpoint', ['pid', 'tag']) diff --git a/src/plumpy/ports.py b/src/plumpy/ports.py index 9db537fc..cfbd92d5 100644 --- a/src/plumpy/ports.py +++ b/src/plumpy/ports.py @@ -11,7 +11,7 @@ from plumpy.utils import AttributesFrozendict, is_mutable_property, type_check -__all__ = ['UNSPECIFIED', 'PortValidationError', 'PortNamespace', 'Port', 'InputPort', 'OutputPort'] +__all__ = ['UNSPECIFIED', 'InputPort', 'OutputPort', 'Port', 'PortNamespace', 'PortValidationError'] _LOGGER = logging.getLogger(__name__) UNSPECIFIED = () diff --git a/src/plumpy/process_comms.py b/src/plumpy/process_comms.py index 6fb1d39a..293c680b 100644 --- a/src/plumpy/process_comms.py +++ b/src/plumpy/process_comms.py @@ -12,15 +12,15 @@ from .utils import PID_TYPE __all__ = [ + 'KILL_MSG', 'PAUSE_MSG', 'PLAY_MSG', - 'KILL_MSG', 'STATUS_MSG', 'ProcessLauncher', + 'RemoteProcessController', + 'RemoteProcessThreadController', 'create_continue_body', 'create_launch_body', - 'RemoteProcessThreadController', - 'RemoteProcessController', ] if TYPE_CHECKING: diff --git a/src/plumpy/process_states.py b/src/plumpy/process_states.py index 13a69877..7ae6e9bd 100644 --- a/src/plumpy/process_states.py +++ b/src/plumpy/process_states.py @@ -22,21 +22,21 @@ from .utils import SAVED_STATE_TYPE __all__ = [ - 'ProcessState', + 'Continue', 'Created', - 'Running', - 'Waiting', - 'Finished', 'Excepted', - 'Killed', + 'Finished', + 'Interruption', # Commands 'Kill', - 'Stop', - 'Wait', - 'Continue', - 'Interruption', 'KillInterruption', + 'Killed', 'PauseInterruption', + 'ProcessState', + 'Running', + 'Stop', + 'Wait', + 'Waiting', ] if TYPE_CHECKING: diff --git a/src/plumpy/processes.py b/src/plumpy/processes.py index f681a9c0..ba7967d3 100644 --- a/src/plumpy/processes.py +++ b/src/plumpy/processes.py @@ -48,7 +48,7 @@ from .process_spec import ProcessSpec from .utils import PID_TYPE, SAVED_STATE_TYPE, protected -__all__ = ['Process', 'ProcessSpec', 'BundleKeys', 'TransitionFailed'] +__all__ = ['BundleKeys', 'Process', 'ProcessSpec', 'TransitionFailed'] _LOGGER = logging.getLogger(__name__) PROCESS_STACK = ContextVar('process stack', default=[]) diff --git a/src/plumpy/workchains.py b/src/plumpy/workchains.py index bd40ad38..748a44d7 100644 --- a/src/plumpy/workchains.py +++ b/src/plumpy/workchains.py @@ -28,7 +28,7 @@ from . import lang, mixins, persistence, process_states, processes from .utils import PID_TYPE, SAVED_STATE_TYPE -__all__ = ['WorkChain', 'if_', 'while_', 'return_', 'ToContext', 'WorkChainSpec'] +__all__ = ['ToContext', 'WorkChain', 'WorkChainSpec', 'if_', 'return_', 'while_'] ToContext = dict diff --git a/test/notebooks/get_event_loop.ipynb b/test/notebooks/get_event_loop.ipynb index 6aa4fbd5..860ca3d2 100644 --- a/test/notebooks/get_event_loop.ipynb +++ b/test/notebooks/get_event_loop.ipynb @@ -7,7 +7,9 @@ "outputs": [], "source": [ "import asyncio\n", - "from plumpy import set_event_loop_policy, PlumpyEventLoopPolicy\n", + "\n", + "from plumpy import PlumpyEventLoopPolicy, set_event_loop_policy\n", + "\n", "set_event_loop_policy()\n", "assert isinstance(asyncio.get_event_loop_policy(), PlumpyEventLoopPolicy)\n", "assert hasattr(asyncio.get_event_loop(), '_nest_patched')" diff --git a/test/persistence/test_inmemory.py b/test/persistence/test_inmemory.py index ba661aad..22b84e70 100644 --- a/test/persistence/test_inmemory.py +++ b/test/persistence/test_inmemory.py @@ -2,7 +2,6 @@ import unittest import plumpy - from test.utils import ProcessWithCheckpoint diff --git a/test/persistence/test_pickle.py b/test/persistence/test_pickle.py index 5c2b306a..cddb0207 100644 --- a/test/persistence/test_pickle.py +++ b/test/persistence/test_pickle.py @@ -6,7 +6,6 @@ from backports import tempfile import plumpy - from test.utils import ProcessWithCheckpoint diff --git a/test/rmq/test_communicator.py b/test/rmq/test_communicator.py index a446aae7..3f2570d8 100644 --- a/test/rmq/test_communicator.py +++ b/test/rmq/test_communicator.py @@ -7,11 +7,12 @@ import tempfile import uuid -import plumpy import pytest import shortuuid import yaml from kiwipy import BroadcastFilter, rmq + +import plumpy from plumpy import communications, process_comms from .. import utils diff --git a/test/rmq/test_process_comms.py b/test/rmq/test_process_comms.py index 5a8525bd..2859e7e8 100644 --- a/test/rmq/test_process_comms.py +++ b/test/rmq/test_process_comms.py @@ -2,11 +2,12 @@ import asyncio import kiwipy -import plumpy -import plumpy.communications import pytest import shortuuid from kiwipy import rmq + +import plumpy +import plumpy.communications from plumpy import process_comms from .. import utils diff --git a/test/test_communications.py b/test/test_communications.py index 1691cbd7..f7e04255 100644 --- a/test/test_communications.py +++ b/test/test_communications.py @@ -3,6 +3,7 @@ import pytest from kiwipy import CommunicatorHelper + from plumpy.communications import LoopCommunicator diff --git a/test/test_events.py b/test/test_events.py index 1dc2d325..964bd6f7 100644 --- a/test/test_events.py +++ b/test/test_events.py @@ -5,6 +5,7 @@ import pathlib import pytest + from plumpy import PlumpyEventLoopPolicy, new_event_loop, reset_event_loop_policy, set_event_loop, set_event_loop_policy diff --git a/test/test_expose.py b/test/test_expose.py index a9ab49ea..48d59b28 100644 --- a/test/test_expose.py +++ b/test/test_expose.py @@ -4,7 +4,6 @@ from plumpy.ports import PortNamespace from plumpy.process_spec import ProcessSpec from plumpy.processes import Process - from test.utils import NewLoopProcess diff --git a/test/test_loaders.py b/test/test_loaders.py index 75fd2848..a1813f09 100644 --- a/test/test_loaders.py +++ b/test/test_loaders.py @@ -1,9 +1,10 @@ # -*- coding: utf-8 -*- """Tests for the :mod:`plumpy.loaders` module.""" -import plumpy import pytest +import plumpy + class DummyClass: """Dummy class for testing.""" diff --git a/test/test_persistence.py b/test/test_persistence.py index 0ec3d5ab..78724aa0 100644 --- a/test/test_persistence.py +++ b/test/test_persistence.py @@ -2,9 +2,10 @@ import asyncio import unittest -import plumpy import yaml +import plumpy + from . import utils diff --git a/test/test_process_comms.py b/test/test_process_comms.py index 93aa8307..ed2be6fa 100644 --- a/test/test_process_comms.py +++ b/test/test_process_comms.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- -import plumpy import pytest -from plumpy import process_comms +import plumpy +from plumpy import process_comms from test import utils diff --git a/test/test_processes.py b/test/test_processes.py index 8b51fbe6..ff7ba90d 100644 --- a/test/test_processes.py +++ b/test/test_processes.py @@ -6,11 +6,11 @@ import unittest import kiwipy -import plumpy import pytest + +import plumpy from plumpy import BundleKeys, Process, ProcessState from plumpy.utils import AttributesFrozendict - from test import utils diff --git a/test/test_utils.py b/test/test_utils.py index c01d712b..9567db7a 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -5,6 +5,7 @@ import warnings import pytest + from plumpy.utils import AttributesFrozendict, ensure_coroutine, load_function diff --git a/test/test_workchains.py b/test/test_workchains.py index 1335517f..08c7317a 100644 --- a/test/test_workchains.py +++ b/test/test_workchains.py @@ -3,8 +3,9 @@ import inspect import unittest -import plumpy import pytest + +import plumpy from plumpy.process_listener import ProcessListener from plumpy.workchains import *