Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell committed Aug 21, 2018
0 parents commit dcdc49a
Show file tree
Hide file tree
Showing 26 changed files with 1,069 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
*.pyc
*.swo
*.swp
~*
*~
.ropeproj
.project
*.egg*
.DS_Store
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Install pre-commit hooks via
# pre-commit install

# yapf = yet another python formatter
- repo: git://github.com/pre-commit/mirrors-yapf
sha: v0.17.0
hooks:
- id: yapf
language: system

# prospector: collection of python linters
- repo: git://github.com/guykisel/prospector-mirror
sha: b27f281eb9398fc8504415d7fbdabf119ea8c5e1
hooks:
- id: prospector
language: system
exclude: '^(tests/)|(examples/)'
6 changes: 6 additions & 0 deletions .travis-data/script.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

# Be verbose, and stop with error as soon there's one
set -ev

python -m unittest discover
37 changes: 37 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
language: python
python:
- "2.7"

cache: pip

services:
- postgresql

addons:
postgresql: "9.4"
#postgresql: "9.5" # Available in Trusty only
apt:
packages:
- texlive-base
- texlive-generic-recommended
- texlive-fonts-recommended
- texlive-latex-base
- texlive-latex-recommended
- texlive-latex-extra
- dvipng
- dvidvi

install:
# Upgrade pip setuptools and wheel
- pip install -U pip wheel setuptools
- pip install .[precommit,testing]
- reentry scan -r aiida

env:
- TEST_AIIDA_BACKEND=django
- TEST_AIIDA_BACKEND=sqlalchemy

script: .travis-data/script.sh

git:
depth: 3
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include setup.json
159 changes: 159 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
# aiida-scheduler-cx1

AiiDA plugin template for testing and gettings started with development

* can be pip-installed from source with no dependencies except for aiida
* can be run on a local machine with direct scheduler for easy testing
* includes a basic regression test (submitting a calculation)
* comes with [Travis CI](https://travis-ci.org) configuration - just enable it to run tests at every commit
* pre-commit hook configuration to sanitize format and check for syntax errors (enable by `pre-commit install`)
* documentation ready for [Read the Docs](http://aiida-scheduler-cx1.readthedocs.io/en/latest/)
* listed on the [AiiDA plugin registry](http://aiidateam.github.io/aiida-registry)

Please see the
[quickstart guide](http://aiida-core.readthedocs.io/en/latest/developer_guide/plugins/quickstart.html)
for step-by-step instructions on how to develop your new AiiDA plugin using this template.

# Installation

```shell
git clone https://github.com/aiidateam/aiida-scheduler-cx1 aiida-scheduler-cx1
cd aiida-scheduler-cx1
pip install -e . # also installs aiida, if missing (but not postgres)
#pip install -e .[precommit,testing] # install extras for more features
reentry scan -r aiida
verdi quicksetup # better to set up a new profile
verdi calculation plugins # should now show template.multiply
```

# Usage

A complete example of how to submit a test calculation using this plugin.

```shell
$ verdi computer setup # set up localhost for testing
At any prompt, type ? to get some help.
---------------------------------------
=> Computer name: localhost
Creating new computer with name 'localhost'
=> Fully-qualified hostname: localhost
=> Description: my local computer
=> Enabled: True
=> Transport type: local
=> Scheduler type: direct
=> AiiDA work directory: /tmp
=> mpirun command:
=> Default number of CPUs per machine: 4
=> Text to prepend to each command execution:
# This is a multiline input, press CTRL+D on a
# empty line when you finish
# ------------------------------------------
# End of old input. You can keep adding
# lines, or press CTRL+D to store this value
# ------------------------------------------
=> Text to append to each command execution:
# This is a multiline input, press CTRL+D on a
# empty line when you finish
# ------------------------------------------
# End of old input. You can keep adding
# lines, or press CTRL+D to store this value
# ------------------------------------------
Computer 'localhost' successfully stored in DB.
pk: 1, uuid: a5b452f0-ec1e-4ec2-956a-10a416f60ed3
Note: before using it with AiiDA, configure it using the command
verdi computer configure localhost
(Note: machine_dependent transport parameters cannot be set via
the command-line interface at the moment)

$ verdi computer configure localhost
Configuring computer 'localhost' for the AiiDA user '[email protected]'
Computer localhost has transport of type local
There are no special keys to be configured. Configuration completed.

$ verdi code setup # set up (local) code
At any prompt, type ? to get some help.
---------------------------------------
=> Label: aiida_scheduler_cx1
=> Description: aiida template plugin
=> Local: True
=> Default input plugin: template.multiply
=> Folder with the code: /your/path/to/aiida_scheduler_cx1
=> Relative path of the executable: code.py
=> Text to prepend to each command execution
FOR INSTANCE, MODULES TO BE LOADED FOR THIS CODE:
# This is a multiline input, press CTRL+D on a
# empty line when you finish
# ------------------------------------------
# End of old input. You can keep adding
# lines, or press CTRL+D to store this value
# ------------------------------------------
=> Text to append to each command execution:
# This is a multiline input, press CTRL+D on a
# empty line when you finish
# ------------------------------------------
# End of old input. You can keep adding
# lines, or press CTRL+D to store this value
# ------------------------------------------
Code 'aiida_scheduler_cx1' successfully stored in DB.
pk: 1, uuid: 7627c747-b7f2-4717-b0fa-94e53915e422

$ verdi run examples/submit.py
submitted calculation; calc=Calculation(uuid='a4d2fa09-f704-4d47-8d0f-07001b13316f') # ID=3

$ verdi calculation list
# Last daemon state_updater check: (Never)
PK State Creation Sched. state Computer Type
---- -------- ---------- -------------- ---------- ----------------
3 TOSUBMIT 1m ago localhost emplate.multiply

Total results: 1

$ verdi daemon start # may need to 'verdi daemon configureuser'
Clearing all locks ...
Starting AiiDA Daemon ...
Daemon started

$ verdi calculation list -a # after daemon poll (30s), calculation should be "FINISHED"
# Last daemon state_updater check: 0h:00m:06s ago (at 19:36:11 on 2017-09-20)
PK State Creation Sched. state Computer Type
---- ---------------- ---------- -------------- ---------- ----------------
3 FINISHED 29s ago DONE localhost emplate.multiply

Total results: 1

$ verdi calculation show 3
----------- --------------------------------------------------
type MultiplyCalculation
pk 23
uuid 6d4b774a-7de7-485a-82b7-6a36b4a60db8
label aiida_scheduler_cx1 computes 2*3
description Test job submission with the aiida_scheduler_cx1 plugin
ctime 2017-09-27 13:50:14.133219+00:00
mtime 2017-09-27 13:52:35.683063+00:00
computer [1] localhost
code aiida_scheduler_cx1
----------- --------------------------------------------------
##### INPUTS:
Link label PK Type
------------ ---- ------------------
parameters 3 MultiplyParameters
##### OUTPUTS:
Link label PK Type
----------------- ---- -------------
remote_folder 4 RemoteData
output_parameters 6 ParameterData
retrieved 5 FolderData


$ verdi data parameter show 3
{
"x1": 2,
"x2": 3
}

$ verdi data parameter show 26
{
"product": 6
}

```
7 changes: 7 additions & 0 deletions aiida_scheduler_cx1/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
"""
AiiDA Plugin Template
Adapt this template for your own needs.
"""

__version__ = "0.2.0"
41 changes: 41 additions & 0 deletions aiida_scheduler_cx1/code.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python


def multiply():
"""
Example code, multiplying two numbers.
This is expected to be run from the command line, as it reads
``sys.argv``.
Usage::
./code.py in_file out_file
Reads input from ``in_file`` (``sys.argv[1]``) (e.g.: {"x1": 2, "x2": 4})
Writes product to ``out_file`` (``sys.argv[2]``) (e.g.: {"product": 8})
Note for developers:
* This would be replaced by a python wrapper around your code.
* This code will be executed on the computer you specify.
"""
import json
import sys

in_file = sys.argv[1]
out_file = sys.argv[2]

with open(in_file) as f:
in_dict = json.load(f)

out_dict = {'product': in_dict['x1'] * in_dict['x2']}

with open(out_file, 'w') as f:
json.dump(out_dict, f)

print("Exiting multiply code.")


if __name__ == '__main__':
multiply()
5 changes: 5 additions & 0 deletions aiida_scheduler_cx1/schedulers/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""
Parsers provided by the plugin
Register parsers via the "aiida.parsers" entry point in setup.json.
"""
Loading

0 comments on commit dcdc49a

Please sign in to comment.