Skip to content

Commit

Permalink
Using typing-extensions for 3.9 support of @OverRide
Browse files Browse the repository at this point in the history
  • Loading branch information
unkcpz committed Jan 22, 2025
1 parent 75ff4a3 commit a90dcff
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ dependencies = [
'kiwipy[rmq]~=0.8.5',
'nest_asyncio~=1.5,>=1.5.1',
'pyyaml~=6.0',
'typing-extensions~=4.12'
]

[project.urls]
Expand Down
2 changes: 2 additions & 0 deletions src/plumpy/base/state_machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,8 @@ def state(self) -> State | None:
def state_label(self) -> Any:
if self._state is None:
return None
# XXX: should not use `.value` to access the printable output from LABEL
# LABEL as the ClassVar should have __str__
return self._state.LABEL

def add_state_event_callback(self, hook: Hashable, callback: EVENT_CALLBACK_TYPE) -> None:
Expand Down
2 changes: 2 additions & 0 deletions src/plumpy/persistence.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import annotations

import abc
import asyncio
import collections
Expand Down
2 changes: 1 addition & 1 deletion src/plumpy/process_states.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
Union,
cast,
final,
override,
)

import yaml
from typing_extensions import override
from yaml.loader import Loader

from plumpy.message import MessageBuilder, MessageType
Expand Down
10 changes: 6 additions & 4 deletions src/plumpy/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,20 @@ def recreate_from(
if 'loop' in load_context:
proc._loop = load_context.loop
else:
_LOGGER.warning(f'cannot find `loop` store in load_context, use default event loop')
_LOGGER.warning('cannot find `loop` store in load_context, use default event loop')
proc._loop = asyncio.get_event_loop()

proc._state = proc.recreate_state(saved_state['_state'])

if 'coordinator' in load_context:
proc._coordinator = load_context.coordinator
else:
_LOGGER.warning(f'cannot find `coordinator` store in load_context')
_LOGGER.warning('cannot find `coordinator` store in load_context')

if 'logger' in load_context:
proc._logger = load_context.logger
else:
_LOGGER.warning(f'cannot find `logger` store in load_context')
_LOGGER.warning('cannot find `logger` store in load_context')

# Need to call this here as things downstream may rely on us having the runtime variable above
persistence.load_auto_persist_params(proc, saved_state, load_context)
Expand Down Expand Up @@ -760,7 +760,9 @@ def on_entered(self, from_state: Optional[state_machine.State]) -> None:
try:
self._coordinator.broadcast_send(body=None, sender=self.pid, subject=subject)
except exceptions.CoordinatorCommunicationError:
message = f'Process<{self.pid}>: cannot broadcast state change from {from_label} to {self.state.value}'
message = (
f'Process<{self.pid}>: cannot broadcast state change from {from_label} to {self.state_label.value}'
)
self.logger.warning(message)
self.logger.debug(message, exc_info=True)
except Exception:
Expand Down
2 changes: 2 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a90dcff

Please sign in to comment.