Skip to content

Commit

Permalink
Merge pull request open-mpi#6771 from ggouaillardet/topic/pmix_refresh
Browse files Browse the repository at this point in the history
pmix/pmix4x: refresh to the latest PMIx master
  • Loading branch information
ggouaillardet authored Jun 24, 2019
2 parents 6433da7 + 5679a88 commit f1ae036
Show file tree
Hide file tree
Showing 10 changed files with 295 additions and 96 deletions.
4 changes: 2 additions & 2 deletions opal/mca/pmix/pmix4x/pmix/VERSION
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ greek=a1
# command, or with the date (if "git describe" fails) in the form of
# "date<date>".

repo_rev=git186dca19
repo_rev=gitf67efc83

# If tarball_version is not empty, it is used as the version string in
# the tarball filename, regardless of all other versions listed in
Expand All @@ -44,7 +44,7 @@ tarball_version=

# The date when this release was created

date="Jun 10, 2019"
date="Jun 24, 2019"

# The shared library version of each of PMIx's public libraries.
# These versions are maintained in accordance with the "Library
Expand Down
137 changes: 137 additions & 0 deletions opal/mca/pmix/pmix4x/pmix/bindings/python/sched.py.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
@PMIX_PYTHON_PATH@

from pmix import *
import signal, time
import os
import select
import subprocess

global killer

class GracefulKiller:
kill_now = False
def __init__(self):
signal.signal(signal.SIGINT, self.exit_gracefully)
signal.signal(signal.SIGTERM, self.exit_gracefully)

def exit_gracefully(self,signum, frame):
self.kill_now = True

def clientconnected(proc:tuple is not None):
print("CLIENT CONNECTED", proc)
return PMIX_SUCCESS

def clientfinalized(proc:tuple is not None):
print("CLIENT FINALIZED", proc)
return PMIX_SUCCESS

def clientfence(args:dict is not None):
print("SERVER FENCE", args)
return PMIX_SUCCESS

def main():
try:
foo = PMIxServer()
except:
print("FAILED TO CREATE SERVER")
exit(1)
print("Testing server version ", foo.get_version())
args = {PMIX_SERVER_SCHEDULER: ('T', PMIX_BOOL)}
map = {'clientconnected': clientconnected,
'clientfinalized': clientfinalized,
'fencenb': clientfence}
my_result = foo.init(args, map)
print("Testing PMIx_Initialized")
rc = foo.initialized()
print("Initialized: ", rc)
vers = foo.get_version()
print("Version: ", vers)

# Register a fabric
rc = foo.register_fabric(None)
print("Fabric registered: ", rc)

# Get the number of vertices in this fabric
nverts = foo.get_num_vertices()
print("Nverts in fabric: ", nverts)

# setup the application
(rc, regex) = foo.generate_regex("test000,test001,test002")
print("Node regex: ", regex)
(rc, ppn) = foo.generate_ppn("0,1,2;3,4,5;6,7")
print("PPN: ", ppn)
darray = (PMIX_INFO, [{PMIX_ALLOC_NETWORK_ID: ("SIMPSCHED.net", PMIX_STRING)},
{PMIX_ALLOC_NETWORK_SEC_KEY: ('T', PMIX_BOOL)},
{PMIX_SETUP_APP_ENVARS: ('T', PMIX_BOOL)}])
kyvals = {PMIX_NODE_MAP: (regex, PMIX_STRING), PMIX_PROC_MAP: (ppn, PMIX_STRING), PMIX_ALLOC_NETWORK: (darray, PMIX_DATA_ARRAY)}

appinfo = []
rc, appinfo = foo.setup_application("SIMPSCHED", kyvals)
print("SETUPAPP: ", appinfo)

rc = foo.setup_local_support("SIMPSCHED", appinfo)
print("SETUPLOCAL: ", rc)

# get our environment as a base
env = os.environ.copy()

# register an nspace for the client app
kvals = {PMIX_NODE_MAP: (regex, PMIX_STRING), PMIX_PROC_MAP: (ppn, PMIX_STRING), PMIX_UNIV_SIZE: (1, PMIX_UINT32), PMIX_JOB_SIZE: (1, PMIX_UINT32)}
print("REGISTERING NSPACE")
rc = foo.register_nspace("testnspace", 1, kvals)
print("RegNspace ", rc)

# register a client
uid = os.getuid()
gid = os.getgid()
print("REGISTERING CLIENT")
rc = foo.register_client(("testnspace", 0), uid, gid)
print("RegClient ", rc)

# setup the fork
rc = foo.setup_fork(("testnspace", 0), env)
print("SetupFrk", rc)

# setup the client argv
args = ["./client.py"]
# open a subprocess with stdout and stderr
# as distinct pipes so we can capture their
# output as the process runs
p = subprocess.Popen(args, env=env,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
# define storage to catch the output
stdout = []
stderr = []
# loop until the pipes close
while True:
reads = [p.stdout.fileno(), p.stderr.fileno()]
ret = select.select(reads, [], [])

stdout_done = True
stderr_done = True

for fd in ret[0]:
# if the data
if fd == p.stdout.fileno():
read = p.stdout.readline()
if read:
read = read.decode('utf-8').rstrip()
print('stdout: ' + read)
stdout_done = False
elif fd == p.stderr.fileno():
read = p.stderr.readline()
if read:
read = read.decode('utf-8').rstrip()
print('stderr: ' + read)
stderr_done = False

if stdout_done and stderr_done:
break

print("FINALIZING")
foo.finalize()

if __name__ == '__main__':
global killer
killer = GracefulKiller()
main()
1 change: 1 addition & 0 deletions opal/mca/pmix/pmix4x/pmix/config/pmix.m4
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ AC_DEFUN([PMIX_SETUP_CORE],[
if test "$WANT_PYTHON_BINDINGS" = "1"; then
AC_CONFIG_FILES(pmix_config_prefix[bindings/python/server.py], [chmod +x bindings/python/server.py])
AC_CONFIG_FILES(pmix_config_prefix[bindings/python/client.py], [chmod +x bindings/python/client.py])
AC_CONFIG_FILES(pmix_config_prefix[bindings/python/sched.py], [chmod +x bindings/python/sched.py])
fi

# publish any embedded flags so external wrappers can use them
Expand Down
Loading

0 comments on commit f1ae036

Please sign in to comment.