-
Notifications
You must be signed in to change notification settings - Fork 10
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
Showing
31 changed files
with
540 additions
and
506 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
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
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 |
---|---|---|
|
@@ -3,4 +3,4 @@ | |
""" | ||
|
||
__version__ = "1.1.2" | ||
__version__ = "1.1.3-dev" |
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,36 @@ | ||
#!/usr/bin/env python | ||
|
||
import pika | ||
from time import sleep, time | ||
import timeout_decorator | ||
|
||
@timeout_decorator.timeout(5) | ||
def rmq_listen(): | ||
channel.start_consuming() | ||
|
||
# Part 1: send message | ||
print "Start sending message..." | ||
connection = pika.BlockingConnection(pika.ConnectionParameters('localhost')) | ||
channel = connection.channel() | ||
channel.queue_declare(queue='hello') | ||
msg = 'Hello World! {}'.format(time()) | ||
channel.basic_publish(exchange='',routing_key='hello', body=msg) | ||
print " [x] Sent '{}'".format(msg) | ||
connection.close() | ||
|
||
print "done sending message. Wait for 5 seconds and start receiving..." | ||
sleep(5) | ||
|
||
# Part 2: receive message | ||
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost')) | ||
channel = connection.channel() | ||
channel.queue_declare(queue='hello') | ||
print ' [*] Waiting 5 seconds for messages.' | ||
def callback(ch, method, properties, body): | ||
print " [x] Received %r" % (body,) | ||
channel.basic_consume(queue='hello',on_message_callback=callback,auto_ack=False) | ||
try: | ||
rmq_listen() | ||
except timeout_decorator.timeout_decorator.TimeoutError: | ||
print "Done waiting, now close connection" | ||
connection.close() |
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,81 @@ | ||
|
||
import os | ||
|
||
|
||
# some global settings | ||
|
||
kkr_codename = 'kkrhost' | ||
kkrimp_codename = 'kkrimp' | ||
voro_codename = 'voronoi' | ||
computername = 'localhost' | ||
queuename = '' | ||
|
||
cwd = os.getcwd() | ||
workdir = cwd+'/jukkr/work' | ||
codelocation = cwd+'/jukkr/' | ||
|
||
|
||
|
||
def prepare_computer(computername, workdir): | ||
"""Create new computer in db or read computer from db if it already exists.""" | ||
from aiida.orm import Computer | ||
from aiida.orm.backend import construct_backend | ||
from aiida.orm.querybuilder import QueryBuilder | ||
# | ||
# first check if computer exists already in database | ||
qb = QueryBuilder() | ||
qb.append(Computer, tag='computer') | ||
all_computers = qb.get_results_dict() | ||
computer_found_in_db = False | ||
if len(all_computers)>0: | ||
for icomp in range(len(all_computers)): | ||
c = all_computers[icomp].get('computer').get('*') | ||
if c.get_name() == computername: | ||
computer_found_in_db = True | ||
comp = c | ||
# if it is not there create a new one | ||
if not computer_found_in_db: | ||
#comp = Computer(computername, 'test computer', transport_type='local', scheduler_type='direct', workdir=workdir) | ||
b = construct_backend() | ||
comp = b.computers.create(computername, 'test computer', transport_type='local', scheduler_type='direct', workdir=workdir) | ||
comp.set_default_mpiprocs_per_machine(4) | ||
comp.store() | ||
print 'computer stored now cofigure' | ||
comp.configure() | ||
else: | ||
print 'found computer in database' | ||
# return computer | ||
return comp | ||
|
||
|
||
def prepare_code(codename, codelocation, computername, workdir): | ||
""".""" | ||
# first create or read computer | ||
comp = prepare_computer(computername, workdir) | ||
# now decide which code to add | ||
if codename == 'kkrhost': | ||
execname = 'kkr.x' | ||
pluginname = 'kkr.kkr' | ||
elif codename == 'voronoi': | ||
execname = 'voronoi.exe' | ||
pluginname = 'kkr.voro' | ||
elif codename == 'kkrimp': | ||
execname = 'kkrflex.exe' | ||
pluginname = 'kkr.kkrimp' | ||
else: | ||
raise ValueError('unknown codename') | ||
# then get code from database or create a new code | ||
from aiida.orm import Code | ||
from aiida.common.exceptions import NotExistent | ||
try: | ||
code = Code.get_from_string(codename+'@'+computername) | ||
except NotExistent as exception: | ||
code = Code() | ||
code.label = codename | ||
code.description = '' | ||
code.set_remote_computer_exec((comp, codelocation+execname)) | ||
code.set_input_plugin_name(pluginname) | ||
if codename == 'voronoi': | ||
code.set_prepend_text('ln -s '+codelocation+'ElementDataBase .') | ||
code.store() | ||
|
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
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
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
Oops, something went wrong.