Skip to content

Commit

Permalink
do not use type strings
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhollas committed Sep 12, 2023
1 parent a55f04b commit 3c65d78
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
12 changes: 6 additions & 6 deletions aiida/engine/daemon/execmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
"""
Expand Down
2 changes: 1 addition & 1 deletion aiida/engine/processes/calcjobs/monitors.py
Original file line number Diff line number Diff line change
Expand Up @@ -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``.
Expand Down
16 changes: 9 additions & 7 deletions aiida/plugins/entry_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion aiida/schedulers/scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 3c65d78

Please sign in to comment.