Skip to content

Instantly share code, notes, and snippets.

@swarbhanu
Created December 16, 2011 18:30
Show Gist options
  • Select an option

  • Save swarbhanu/1487273 to your computer and use it in GitHub Desktop.

Select an option

Save swarbhanu/1487273 to your computer and use it in GitHub Desktop.
Example script file to be run from within pyon container (interactive shell). Running this script results in a client terminal sending a message bearing an hdf file to a server set up in another pyon shell. The client then waits for a reply. When the repl
import h5py
import numpy
# use the core driver of h5Py to write an hdf file
file = h5py.File('myfile_check.hdf5', mode = 'w', driver='core')
#file = h5py.File('myfile_check2.hdf5', mode = 'w', driver='log')
grp = file.create_group('myGroup')
dataset = grp.create_dataset('dataset', (10,10), '=f8', maxshape=(None,None))
file['dataset'] = numpy.ones((10,10))
file.flush()
file.close()
# open the hdf5 file using python 'open()'
f = open("myfile_check.hdf5", mode='rb')
# read the binary string representation of the file
dataString = f.read()
f.close()
# Connecting to the server and sending the hdf file as a binary string
from interface.services.examples.hello.iHDFhello_service import HDFHelloServiceClient
hsc=HDFHelloServiceClient(node=cc.node) # specifies the broker to connect to as cc.node
dataString_fromServer = hsc.hello(dataString) # where dataString is some string
# write the binary string to a new file
f = open("myfile_check_out.hdf5", mode='wb')
f.write(dataString_fromServer)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment