From 3c65d78699abe46dc70ce83051e83b2a114f2f97 Mon Sep 17 00:00:00 2001 From: Daniel Hollas Date: Tue, 12 Sep 2023 17:08:45 +0100 Subject: [PATCH] do not use type strings --- aiida/engine/daemon/execmanager.py | 12 ++++++------ aiida/engine/processes/calcjobs/monitors.py | 2 +- aiida/plugins/entry_point.py | 16 +++++++++------- aiida/schedulers/scheduler.py | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/aiida/engine/daemon/execmanager.py b/aiida/engine/daemon/execmanager.py index 25942b7e57..5e5a0cbc02 100644 --- a/aiida/engine/daemon/execmanager.py +++ b/aiida/engine/daemon/execmanager.py @@ -66,7 +66,7 @@ def _find_data_node(inputs: MappingType[str, Any], uuid: str) -> Optional[Node]: def upload_calculation( node: CalcJobNode, - transport: 'Transport', + transport: Transport, calc_info: CalcInfo, folder: SandboxFolder, inputs: Optional[MappingType[str, Any]] = None, @@ -357,7 +357,7 @@ def upload_calculation( remotedata.store() -def submit_calculation(calculation: CalcJobNode, transport: 'Transport') -> str | ExitCode: +def submit_calculation(calculation: CalcJobNode, transport: Transport) -> str | ExitCode: """Submit a previously uploaded `CalcJob` to the scheduler. :param calculation: the instance of CalcJobNode to submit. @@ -387,7 +387,7 @@ def submit_calculation(calculation: CalcJobNode, transport: 'Transport') -> str return result -def stash_calculation(calculation: CalcJobNode, transport: 'Transport') -> None: +def stash_calculation(calculation: CalcJobNode, transport: Transport) -> None: """Stash files from the working directory of a completed calculation to a permanent remote folder. After a calculation has been completed, optionally stash files from the work directory to a storage location on the @@ -453,7 +453,7 @@ def stash_calculation(calculation: CalcJobNode, transport: 'Transport') -> None: remote_stash.base.links.add_incoming(calculation, link_type=LinkType.CREATE, link_label='remote_stash') -def retrieve_calculation(calculation: CalcJobNode, transport: 'Transport', retrieved_temporary_folder: str) -> None: +def retrieve_calculation(calculation: CalcJobNode, transport: Transport, retrieved_temporary_folder: str) -> None: """Retrieve all the files of a completed job calculation using the given transport. If the job defined anything in the `retrieve_temporary_list`, those entries will be stored in the @@ -522,7 +522,7 @@ def retrieve_calculation(calculation: CalcJobNode, transport: 'Transport', retri ) -def kill_calculation(calculation: CalcJobNode, transport: 'Transport') -> None: +def kill_calculation(calculation: CalcJobNode, transport: Transport) -> None: """ Kill the calculation through the scheduler @@ -558,7 +558,7 @@ def kill_calculation(calculation: CalcJobNode, transport: 'Transport') -> None: def retrieve_files_from_list( - calculation: CalcJobNode, transport: 'Transport', folder: str, retrieve_list: List[Union[str, Tuple[str, str, int], + calculation: CalcJobNode, transport: Transport, folder: str, retrieve_list: List[Union[str, Tuple[str, str, int], list]] ) -> None: """ diff --git a/aiida/engine/processes/calcjobs/monitors.py b/aiida/engine/processes/calcjobs/monitors.py index 36470fcaea..9bc08b6a0f 100644 --- a/aiida/engine/processes/calcjobs/monitors.py +++ b/aiida/engine/processes/calcjobs/monitors.py @@ -173,7 +173,7 @@ def monitors(self) -> collections.OrderedDict: def process( self, node: CalcJobNode, - transport: 'Transport', + transport: Transport, ) -> CalcJobMonitorResult | None: """Call all monitors in order and return the result as one returns anything other than ``None``. diff --git a/aiida/plugins/entry_point.py b/aiida/plugins/entry_point.py index d361aa9faa..048ba20e78 100644 --- a/aiida/plugins/entry_point.py +++ b/aiida/plugins/entry_point.py @@ -8,6 +8,8 @@ # For further information please visit http://www.aiida.net # ########################################################################### """Module to manage loading entrypoints.""" +from __future__ import annotations + import enum import functools import traceback @@ -31,13 +33,13 @@ @functools.cache -def eps() -> 'Union[EntryPoints, SelectableGroups]': +def eps() -> Union[EntryPoints, SelectableGroups]: from importlib_metadata import entry_points return entry_points() #@functools.lru_cache(maxsize=100) -def eps_select(group, name=None) -> 'EntryPoints': +def eps_select(group, name=None) -> EntryPoints: if name is None: return eps().select(group=group) return eps().select(group=group, name=name) @@ -115,7 +117,7 @@ class EntryPointFormat(enum.Enum): } -def parse_entry_point(group: str, spec: str) -> 'EntryPoint': +def parse_entry_point(group: str, spec: str) -> EntryPoint: """Return an entry point, given its group and spec (as formatted in the setup)""" from importlib_metadata import EntryPoint @@ -199,7 +201,7 @@ def get_entry_point_string_format(entry_point_string: str) -> EntryPointFormat: return EntryPointFormat.PARTIAL -def get_entry_point_from_string(entry_point_string: str) -> 'EntryPoint': +def get_entry_point_from_string(entry_point_string: str) -> EntryPoint: """ Return an entry point for the given entry point string @@ -270,7 +272,7 @@ def get_entry_point_names(group: str, sort: bool = True) -> List[str]: return group_names -def get_entry_points(group: str) -> 'EntryPoints': +def get_entry_points(group: str) -> EntryPoints: """ Return a list of all the entry points within a specific group @@ -280,7 +282,7 @@ def get_entry_points(group: str) -> 'EntryPoints': return eps_select(group=group) -def get_entry_point(group: str, name: str) -> 'EntryPoint': +def get_entry_point(group: str, name: str) -> EntryPoint: """ Return an entry point with a given name within a specific group @@ -327,7 +329,7 @@ def convert_potentially_deprecated_entry_point(group: str, name: str) -> str: @functools.lru_cache(maxsize=100) -def get_entry_point_from_class(class_module: str, class_name: str) -> Tuple[Optional[str], Optional['EntryPoint']]: +def get_entry_point_from_class(class_module: str, class_name: str) -> Tuple[Optional[str], Optional[EntryPoint]]: """ Given the module and name of a class, attempt to obtain the corresponding entry point if it exists diff --git a/aiida/schedulers/scheduler.py b/aiida/schedulers/scheduler.py index 3853830491..d98e343d67 100644 --- a/aiida/schedulers/scheduler.py +++ b/aiida/schedulers/scheduler.py @@ -377,7 +377,7 @@ def transport(self): return self._transport - def set_transport(self, transport: 'Transport'): + def set_transport(self, transport: Transport): """Set the transport to be used to query the machine or to submit scripts. This class assumes that the transport is open and active.