-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e33376c
Showing
21 changed files
with
1,187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
*.pyc | ||
*.swo | ||
*.swp | ||
~* | ||
*~ | ||
.project | ||
*.egg* | ||
.DS_Store | ||
.coverage | ||
.pytest_cache | ||
.vscode | ||
build/ | ||
dist/ | ||
pip-wheel-metadata/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Install pre-commit hooks via: | ||
# pre-commit install | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v3.4.0 | ||
hooks: | ||
- id: double-quote-string-fixer | ||
- id: end-of-file-fixer | ||
- id: fix-encoding-pragma | ||
- id: mixed-line-ending | ||
- id: trailing-whitespace | ||
- id: check-json | ||
|
||
# yapf = yet another python formatter | ||
- repo: https://github.com/pre-commit/mirrors-yapf | ||
rev: v0.30.0 | ||
hooks: | ||
- id: yapf | ||
name: yapf | ||
args: ["-i"] | ||
|
||
- repo: local | ||
hooks: | ||
- id: pylint | ||
language: system | ||
types: [file, python] | ||
name: pylint | ||
description: "This hook runs the pylint static code analyzer" | ||
exclude: &exclude_files > | ||
(?x)^( | ||
docs/.*| | ||
)$ | ||
entry: pylint | ||
|
||
- id: version-number | ||
name: Check version numbers | ||
entry: python ./.github/check_version.py | ||
language: system | ||
files: '^(setup.json)|(aiida_hyperqueue/__init__.py)' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 The AiiDA Team. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
include setup.json | ||
include LICENSE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
[![Build Status](https://github.com/aiidateam/aiida-hyperqueue/workflows/ci/badge.svg?branch=master)](https://github.com/aiidateam/aiida-hyperqueue/actions) | ||
[![Coverage Status](https://coveralls.io/repos/github/aiidateam/aiida-hyperqueue/badge.svg?branch=master)](https://coveralls.io/github/aiidateam/aiida-hyperqueue?branch=master) | ||
[![Docs status](https://readthedocs.org/projects/aiida-hyperqueue/badge)](http://aiida-hyperqueue.readthedocs.io/) | ||
[![PyPI version](https://badge.fury.io/py/aiida-hyperqueue.svg)](https://badge.fury.io/py/aiida-hyperqueue) | ||
|
||
# aiida-hyperqueue | ||
|
||
> WARNING: This plugin is still in heavy development. Expect bugs to pop up and the API to change. | ||
AiiDA plugin for the HyperQueue metascheduler. | ||
|
||
## Features | ||
|
||
Allows task farming on Slurm machines through the submission of AiiDA calculations to the HyperQueue metascheduler. | ||
|
||
## Installation | ||
|
||
TODO | ||
|
||
## Usage | ||
|
||
TODO | ||
|
||
## Development | ||
|
||
TODO | ||
|
||
## License | ||
|
||
MIT | ||
|
||
## Contact | ||
|
||
[email protected] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# -*- coding: utf-8 -*- | ||
""" | ||
aiida_hyperqueue | ||
AiiDA plugin for the HyperQueue metascheduler | ||
""" | ||
|
||
__version__ = '0.1.0' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
# -*- coding: utf-8 -*- | ||
"""Command line interface (CLI) for aiida_hyperqueue.""" | ||
|
||
import click | ||
from aiida.cmdline.params import options, arguments | ||
from aiida.cmdline.utils import decorators, echo | ||
from aiida.cmdline.commands.cmd_data import verdi_data | ||
|
||
|
||
@verdi_data.group('hyperqueue') | ||
def data_cli(): | ||
"""Command line interface for aiida-hyperqueue""" | ||
|
||
|
||
@data_cli.group('server') | ||
def server_group(): | ||
"""Commands for interacting with the HQ server.""" | ||
|
||
|
||
@server_group.command('start') | ||
@arguments.COMPUTER() | ||
@decorators.with_dbenv() | ||
def start_cmd(computer): | ||
"""Start the HyperQueue server.""" | ||
|
||
with computer.get_transport() as transport: | ||
retval, _, _ = transport.exec_command_wait('hq server info') | ||
|
||
if retval == 0: | ||
echo.echo_info('server is already running!') | ||
return | ||
|
||
with computer.get_transport() as transport: | ||
retval, stdout, stderr = transport.exec_command_wait( | ||
'nohup hq server start 1>$HOME/.hq-stdout 2>$HOME/.hq-stderr &') | ||
|
||
if retval != 0: | ||
echo.echo_critical(f'unable to start the server: {stderr}') | ||
|
||
echo.echo_success(f'{stdout}') | ||
|
||
|
||
@server_group.command('info') | ||
@arguments.COMPUTER() | ||
@decorators.with_dbenv() | ||
def info_cmd(computer): | ||
"""Get information on the HyperQueue server.""" | ||
|
||
with computer.get_transport() as transport: | ||
retval, stdout, stderr = transport.exec_command_wait('hq server info') | ||
|
||
if retval != 0: | ||
echo.echo_critical( | ||
f'cannot obtain HyperQueue server information: {stderr}\n' | ||
'Try starting the server with `verdi data hyperqueue server start`.' | ||
) | ||
|
||
echo.echo(stdout) | ||
|
||
|
||
@data_cli.group('alloc') | ||
def alloc_group(): | ||
"""Commands to configure HQ allocations.""" | ||
|
||
|
||
@alloc_group.command('add') | ||
@click.argument('slurm-options', nargs=-1) | ||
@options.COMPUTER(required=True) | ||
@click.option( | ||
'-t', | ||
'--time-limit', | ||
type=str, | ||
required=True, | ||
help= | ||
('Time limit for each job run by the allocation. The duration can be expressed using various shortcuts ' | ||
'recognised by HyperQueue, e.g. 30m, 2h, ... For the full list, see https://tinyurl.com/hq-duration.' | ||
)) | ||
@decorators.with_dbenv() | ||
def add_cmd(slurm_options, computer, time_limit): | ||
"""Add a new allocation to the HQ server.""" | ||
|
||
with computer.get_transport() as transport: | ||
retval, _, stderr = transport.exec_command_wait( | ||
f'hq alloc add slurm -b 1 --time-limit {time_limit} --name aiida -- {" ".join(slurm_options)}' | ||
) | ||
|
||
if retval != 0: | ||
echo.echo_critical(f'failed to create new allocation: {stderr}\n') | ||
|
||
echo.echo_success(f'{stderr}') | ||
|
||
|
||
@alloc_group.command('list') | ||
@arguments.COMPUTER() | ||
@decorators.with_dbenv() | ||
def list_cmd(computer): | ||
"""List the allocations on the HQ server.""" | ||
|
||
with computer.get_transport() as transport: | ||
retval, stdout, stderr = transport.exec_command_wait('hq alloc list') | ||
|
||
if retval != 0: | ||
echo.echo_critical(f'failed to list allocations: {stderr}\n') | ||
|
||
echo.echo(stdout) | ||
|
||
|
||
@alloc_group.command('remove') | ||
@click.argument('alloc_id') | ||
@options.COMPUTER(required=True) | ||
@decorators.with_dbenv() | ||
def remove_cmd(alloc_id, computer): | ||
"""Remove an allocation from the HQ server.""" | ||
|
||
with computer.get_transport() as transport: | ||
retval, _, stderr = transport.exec_command_wait( | ||
f'hq alloc remove {alloc_id}') | ||
|
||
if retval != 0: | ||
echo.echo_critical(f'failed to remove allocation: {stderr}\n') | ||
|
||
echo.echo_success(f'{stderr}') |
Oops, something went wrong.