diff --git a/.github/workflows/ci-tests.yml b/.github/workflows/ci-tests.yml index a7c6617..0b5e393 100644 --- a/.github/workflows/ci-tests.yml +++ b/.github/workflows/ci-tests.yml @@ -2,7 +2,7 @@ name: tests on: push: - branches: [main] + branches: ['main', 'support/v*'] pull_request: jobs: diff --git a/pyproject.toml b/pyproject.toml index 2137596..0188007 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -20,7 +20,7 @@ classifiers = [ keywords = ["aiida", "plugin"] requires-python = ">=3.9" dependencies = [ - "aiida-core>=2.7.1,<3", + "aiida-core==2.8.0rc0", "ase", "node-graph~=0.5.0", ] diff --git a/src/aiida_pythonjob/__init__.py b/src/aiida_pythonjob/__init__.py index 6708707..4a3eed0 100644 --- a/src/aiida_pythonjob/__init__.py +++ b/src/aiida_pythonjob/__init__.py @@ -1,6 +1,6 @@ """AiiDA plugin that run Python function on remote computers.""" -__version__ = "0.4.8" +__version__ = "0.4.9" from node_graph import socket_spec as spec diff --git a/src/aiida_pythonjob/data/serializer.py b/src/aiida_pythonjob/data/serializer.py index 8b117c0..e3aeb8c 100644 --- a/src/aiida_pythonjob/data/serializer.py +++ b/src/aiida_pythonjob/data/serializer.py @@ -21,7 +21,8 @@ "numpy.float32": "aiida.orm.nodes.data.float.Float", "numpy.float64": "aiida.orm.nodes.data.float.Float", "numpy.int64": "aiida.orm.nodes.data.int.Int", - "numpy.bool_": "aiida.orm.nodes.data.bool.Bool", + "numpy.bool_": "aiida.orm.nodes.data.bool.Bool", # numpy<2.0 + "numpy.bool": "aiida.orm.nodes.data.bool.Bool", # numpy>=2.0 "numpy.ndarray": "aiida.orm.nodes.data.array.array.ArrayData", } diff --git a/src/aiida_pythonjob/decorator.py b/src/aiida_pythonjob/decorator.py index e89b573..98528fb 100644 --- a/src/aiida_pythonjob/decorator.py +++ b/src/aiida_pythonjob/decorator.py @@ -7,16 +7,24 @@ import typing as t from typing import List -from aiida.engine.processes.functions import FunctionType, get_stack_size +import aiida +from aiida.engine.processes.functions import FunctionType from aiida.manage import get_manager from aiida.orm import ProcessNode from node_graph.socket_spec import SocketSpec +from packaging.version import parse as parse_version from aiida_pythonjob.calculations.pyfunction import PyFunction from aiida_pythonjob.launch import create_inputs, prepare_pyfunction_inputs LOGGER = logging.getLogger(__name__) +_AIIDA_VERSION = parse_version(aiida.__version__) +_NEEDS_RECURSION_LIMIT_WORKAROUND = _AIIDA_VERSION < parse_version("2.8.0rc0") + +if _NEEDS_RECURSION_LIMIT_WORKAROUND: + from aiida.engine.processes.functions import get_stack_size + # The following code is modified from the aiida-core.engine.processes.functions module def pyfunction( @@ -42,25 +50,26 @@ def run_get_node(*args, **kwargs) -> tuple[dict[str, t.Any] | None, "ProcessNode :param kwargs: input keyword arguments to construct the FunctionProcess :return: tuple of the outputs of the process and the process node """ - frame_delta = 1000 - frame_count = get_stack_size() - stack_limit = sys.getrecursionlimit() - LOGGER.info("Executing process function, current stack status: %d frames of %d", frame_count, stack_limit) - - # If the current frame count is more than 80% of the stack limit, or comes within 200 frames, increase the - # stack limit by ``frame_delta``. - if frame_count > min(0.8 * stack_limit, stack_limit - 200): - LOGGER.warning( - "Current stack contains %d frames which is close to the limit of %d. Increasing the limit by %d", - frame_count, - stack_limit, - frame_delta, + if _NEEDS_RECURSION_LIMIT_WORKAROUND: + frame_delta = 1000 + frame_count = get_stack_size() + stack_limit = sys.getrecursionlimit() + LOGGER.info( + "Executing process function, current stack status: %d frames of %d", frame_count, stack_limit ) - sys.setrecursionlimit(stack_limit + frame_delta) + + if frame_count > min(0.8 * stack_limit, stack_limit - 200): + LOGGER.warning( + "Current stack contains %d frames which is close to the limit of %d. Increasing the limit by %d", + frame_count, + stack_limit, + frame_delta, + ) + sys.setrecursionlimit(stack_limit + frame_delta) manager = get_manager() runner = manager.get_runner() - # # Remove all the known inputs from the kwargs + # Remove all the known inputs from the kwargs outputs_spec = kwargs.pop("outputs_spec", None) or outputs inputs_spec = kwargs.pop("inputs_spec", None) or inputs metadata = kwargs.pop("metadata", None)