Using the Python library

The Beneath Python library is primarily for creating Beneath models and writing output back to Beneath.

Installation

Run on your command line:

pip install beneath
Example

The best way to showcase the Beneath library is through an example. Though, we’ll be sure to make the documentation more robust when we launch the write-to-beneath feature in October.

from beneath.client import Client
from beneath.beam import ReadFromBeneath, WriteToBeneath
def run(argv=None):
    client = Client(secret="SECRET")
    stream = client.stream("PROJECTNAME", "STREAMNAME")
    pipeline = beam.Pipeline()
    (
       pipeline
       | 'Read'         >> ReadFromBeneath(stream)
       | 'UDF' 		>> YourModel()
       | 'Write'        >> WriteToBeneath(stream)
     )

if __name__ == '__main__':
 run()