In [ ]:
from birdy import WPSClient
In [ ]:
emu = WPSClient(url='http://localhost:5000/wps')
emu_i = WPSClient(url='http://localhost:5000/wps', progress=True)
In [ ]:
emu.hello?
In [ ]:
emu.hello(name='Birdy').get()[0]
In [ ]:
result = emu_i.sleep(delay='1.0')
In [ ]:
result.get()[0]
In [ ]:
emu.chomsky(times='5').get()[0]
In [ ]:
fn = '/tmp/text.txt'
with open(fn, 'w') as f:
f.write('Just an example')
emu.wordcounter(text=fn).get(asobj=True)
The client is able to convert input objects into strings to create requests, and also convert output strings into python objects. This can be demonstrated with the inout process, which simply takes a variety of LiteralInputs of different data types and directs them to the output without any change.
In [ ]:
emu.inout?
In [ ]:
import datetime as dt
result = emu.inout(string='test', int=1, float=5.6, boolean=True, time='15:45', datetime=dt.datetime(2018, 12, 12), text=None, dataset=None)
Get result as object
In [ ]:
result.get(asobj=True).text
Similarly, the multiple_outputs function returns a text/plain file. The converter will automatically convert the text file into a string.
In [ ]:
out = emu.multiple_outputs(1).get(asobj=True)[0]
print(out)
... or use the metalink library on the referenced metalink file:
In [ ]:
out = emu.multiple_outputs(1).get(asobj=False)[0]
print(out)
In [ ]:
from metalink import download
download.get(out, path='/tmp', segmented=False)