Skip to content
This repository has been archived by the owner on Jul 19, 2023. It is now read-only.

Commit

Permalink
Merge pull request #64 from keisukefukuda/add-config-yml
Browse files Browse the repository at this point in the history
Removed unnecessary output
  • Loading branch information
keisukefukuda committed Jul 14, 2017
2 parents b9f94c4 + e668f97 commit 05768a9
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 11 deletions.
28 changes: 26 additions & 2 deletions common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from subprocess import PIPE
from subprocess import Popen
import sys
import yaml

from mpienv.ompi import parse_ompi_info
from mpienv.py import MPI4Py
Expand Down Expand Up @@ -214,6 +215,16 @@ def mkdir_p(path):
os.makedirs(path)


DefaultConf = {
'mpich': {
},
'mvapich': {
},
'openmpi': {
},
}


class Manager(object):
def __init__(self, root_dir):
self._root_dir = root_dir
Expand All @@ -236,7 +247,8 @@ def __init__(self, root_dir):
mkdir_p(self._cache_dir)
mkdir_p(self._build_dir)

self._load_info()
self._load_mpi_info()
self._load_config()

def root_dir(self):
return self._root_dir
Expand All @@ -253,7 +265,7 @@ def mpi_dir(self):
def pylib_dir(self):
return self._pylib_dir

def _load_info(self):
def _load_mpi_info(self):
# Get the current status of the MPI environment.
self._installed = {}
for prefix in glob.glob(os.path.join(self._mpi_dir, '*')):
Expand All @@ -262,6 +274,18 @@ def _load_info(self):
info['name'] = name
self._installed[name] = info

def _load_config(self):
conf_yml = os.path.join(self._root_dir, "config.yml")
if os.path.exists(conf_yml):
with open(conf_yml) as f:
conf = yaml.load(f)
else:
sys.stderr.write("Warning: Cannot find config file\n")
conf = {}

self._conf = DefaultConf.copy()
self._conf.update(conf)

def get_info_from_prefix(self, prefix):
info = {}
mpiexec = os.path.join(prefix, 'bin', 'mpiexec')
Expand Down
12 changes: 7 additions & 5 deletions mpienv/py.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,13 @@ def install(self):
else:
env['LD_LIBRARY_PATH'] = "{}".format(LD)

sys.stderr.write("Installing {} for {} ...\n".format(self._libname,
self._name))
check_call(['pip', 'install', '-t', self._pylib_dir,
'--no-cache-dir', self._libname],
stdout=sys.stderr, env=env)
if False:
sys.stderr.write("Installing {} for {} ...\n".format(self._libname,
self._name))
with open(os.devnull, 'w') as devnull:
check_call(['pip', 'install', '-t', self._pylib_dir,
'--no-cache-dir', self._libname],
stdout=devnull, env=env)

def use(self):
pypath = os.environ.get('PYTHONPATH', None)
Expand Down
4 changes: 0 additions & 4 deletions tests/test_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ EOF
mpienv use --mpi4py mpich-3.2
mpienv exec -n 2 python -c "from mpi4py import MPI"
assertTrue $?
mpienv exec -n 2 python $SCRIPT
assertTrue $?
OUT=$(mpienv use --mpi4py mpich-3.2; mpienv exec -n 2 python $SCRIPT)
assertEquals "01" "$OUT"

Expand All @@ -183,8 +181,6 @@ EOF
mpienv use --mpi4py openmpi-2.1.1
mpienv exec -n 2 python -c "from mpi4py import MPI"
assertTrue $?
mpienv exec -n 2 python $SCRIPT
assertTrue $?
OUT=$(mpienv use --mpi4py openmpi-2.1.1; mpienv exec -n 2 python $SCRIPT)
assertEquals "01" "$OUT"

Expand Down

0 comments on commit 05768a9

Please sign in to comment.