跳转到主要内容

描述待定。

项目描述

aiida-calcmonitor

AiiDA插件,其中包含用于监控正在进行计算的工具。

开发安装

git clone git@github.com:ramirezfranciscof/aiida-calcmonitor.git .
cd aiida-calcmonitor
pip install --upgrade pip
pip install -e .

# These are not available yet!
pip install -e .[pre-commit,testing]  # install extra dependencies
pre-commit install  # install pre-commit hooks
pytest -v  # discover and run all tests

运行监控测试

要运行监控测试,您需要有一个现有的aiida配置文件。您必须在其中运行toymodel代码的计算机上进行设置(需要将aiida_calcmonitor/utils/toymodel_code.sh复制到计算机中,并在AiiDA中设置一个代码)。您可以像这样设置本地主机:

$ verdi computer setup -L localhost -H localhost -T local -S direct -w /scratch/{username}/aiida/ --mpiprocs-per-machine 1 -n
$ verdi computer configure local localhost --safe-interval 5 -n

要运行calcjob监控calcjob,您需要设置一个特殊类型的本地主机,使用以下Mpirun命令:verdi -p <PROFILE_NAME> run(将<PROFILE_NAME>替换为相应的名称)。它还需要一个前置命令,以激活aiida使用的虚拟环境。对于典型的Python虚拟环境,您可以这样做:

source /home/username/.virtualenvs/aiida/bin/activate

一旦所有这些设置完成,您可以使用/examples/example01/submit_everything.py中的示例作为模板,了解如何准备和提交toymodel计算并进行监控。

创建您自己的监控器

要创建您自己的监控器,您需要从MonitorBase类进行子类化。这是一个从Dict派生出来的数据类型,所以您的想法是创建一个子数据类型,该类型具有描述检查过程的方法,然后您将从这个子类型创建一个数据节点,其中包含该过程选项的字典,监控代码将获取该数据节点输入并调用检查方法。

这是一个示例,用于展示可以从父类访问的关键变量(self[...])以及需要使用的返回值,但结构可以根据需要修改(例如,不需要设置和使用error_detected布尔值,您可以在检查过程中直接返回错误信息)。

class NewMonitorSubclass(MonitorBase):  # pylint: disable=too-many-ancestors
    """Example of monitor for the toy model."""

    def monitor_analysis(self):
        
        sources = self['sources']
        # this contains the mapping to the actual filepaths (see below)

        options = self['options']
        # this contains the specific options for this method (the structure is determined here in this method and the user must know what is expected when constructing it)

        retrieve = self['retrieve']
        # there will also be a list of files to retrieve if the original calculation is killed, but this should probably not be needed here

        internal_naming = sources['internal_naming']['filepath']
        # This is how you access the mapping for the files; now internal_naming contains the actual path to the file it requires

        with open(internal_naming) as fileobj:
            # Here one performs the parsing of the files and checking.
            # Setups the variables error_detected and error_msg or equivalent

        if error_detected:
            return f'An error was detected: {error_msg}'        
            # The calcjob_monitor will interpret string returns as errors and will kill the process
        else:
            return None
            # The calcjob_monitor will interpret None returns to mean everything is going fine

为了可以使用,您还需要将其添加为入口点/插件,例如在pyproject.toml内部。

[project.entry-points."aiida.data"]
"calcmonitor.monitor.toymodel" = "aiida_calcmonitor.data.monitors.monitor_toymodel:MonitorToymodel"
"calcmonitor.monitor.newmonitor" = "aiida_calcmonitor.data.monitors.newmonitor_file:NewMonitorSubclass"

许可

MIT

项目详情


下载文件

下载适合您平台的文件。如果您不确定选择哪个,请了解有关安装包的更多信息。

源代码分发

aiida_calcmonitor-0.1.0.tar.gz(100.5 kB 查看哈希值

上传时间 源代码

构建分发

aiida_calcmonitor-0.1.0-py3-none-any.whl(19.7 kB 查看哈希值

上传时间 Python 3

由...