Skip to content

Instantly share code, notes, and snippets.

@swarbhanu
swarbhanu / ingestion_management_service.py
Created February 1, 2012 19:52
Ingestion Management Service
#!/usr/bin/env python
__license__ = 'Apache 2.0'
'''
@author Maurice Manning
@author Swarbhanu Chatterjee
@file ion/services/dm/ingestion/ingestion_management_service.py
@description Implementation for IngestionManagementService
'''
from interface.services.dm.iingestion_management_service import BaseIngestionManagementService
from pyon.core.exception import NotFound
@swarbhanu
swarbhanu / ingestion_worker.py
Created February 1, 2012 19:25
IngestionWorker class
class IngestionWorker(TransformDataProcess):
''' A basic transform that receives input through a subscription,
parses the input for an integer and adds 1 to it. If the transform
has an output_stream it will publish the output on the output stream.
This transform appends transform work in '/tmp/transform_output'
'''
def __init__(self, *args, **kwargs):
super(IngestionWorker,self).__init__()
@swarbhanu
swarbhanu / ingestion_management_service.py
Created January 31, 2012 22:44
IngestionWorker class at the bottom of the file. Processes packets and writes to disk
#!/usr/bin/env python
__license__ = 'Apache 2.0'
'''
@author Maurice Manning
@author Swarbhanu Chatterjee
@file ion/services/dm/ingestion/ingestion_management_service.py
@description Implementation for IngestionManagementService
'''
from interface.services.dm.iingestion_management_service import BaseIngestionManagementService
from pyon.core.exception import NotFound
@swarbhanu
swarbhanu / couchdb_ingestion_example.py
Created January 31, 2012 19:34
A small script to do couchdb operations in coi-services.
from pyon.datastore.couchdb.couchdb_datastore import CouchDB_DataStore
db = CouchDB_DataStore()
# Creates a datastore
datastore_name = 'dm_datastore'
db.create_datastore(datastore_name)
# Create a document
#!/usr/bin/env python
__author__ = 'Maurice Manning'
__license__ = 'Apache 2.0'
from interface.services.dm.iingestion_management_service import BaseIngestionManagementService
from pyon.core.exception import NotFound
from pyon.public import RT, AT, log, IonObject
from pyon.public import CFG
@swarbhanu
swarbhanu / ingestion_script.py
Created January 20, 2012 23:17
Uses an IngestionManagementService client to create an ingestion_configuration, and launch transforms. The transforms wait for messages. Once the transforms can handle (print etc) the messages, this script can be complete.
from interface.services.dm.ipubsub_management_service import PubsubManagementServiceClient
from interface.services.dm.itransform_management_service import TransformManagementServiceClient
from interface.services.coi.iresource_registry_service import ResourceRegistryServiceClient
from interface.services.dm.iingestion_management_service import IngestionManagementServiceClient
from pyon.public import IonObject, RT, log, AT
from ion.services.dm.transformation.example.transform_example import TransformExampleProducer
pubsub_client = PubsubManagementServiceClient(node=cc.node)
tms_client = TransformManagementServiceClient(node=cc.node)
@swarbhanu
swarbhanu / ingestion_worker.py
Created January 20, 2012 20:03
This would define an ingestion worker class. The ingestion worker, an instance of the class, can extract instruction from the metadata in a science stream, and according to the instruction store the data in couch and hdf datastores, and/or process data an
#!/usr/bin/env python
'''
@package ion.services.dm.ingestion
@file ion/services/dm/ingestion/ingestion.py
@author Swarbhanu Chatterjee
@brief Ingestion Class. When instantiated the ingestion objects will be able to handle one specific scientific request.
The scientific request may involved several data subscriptions, retrievals, processing, and data publishing.
Uses the HDFEncoder and HDFDecoder classes to perform most of its work with the data and the PubSub messaging to
send data far and wide.
@swarbhanu
swarbhanu / hdf_hello.py
Created December 16, 2011 18:57
Example code, pyon/examples/service/hdf_hello.py (to replace hello_service.py) that defines a method which the server uses to handle a message. In our case, the server makes an hdf file out of the binary string provided in the message, modifies it using h
#!/usr/bin/env python
from pyon.util.log import log
from interface.services.examples.hello.ihello_service import BaseHelloService
from examples.service.hello_service import HelloService
import h5py
import numpy
@swarbhanu
swarbhanu / iHDFhello_service.py
Created December 16, 2011 18:50
iHDFhello_service.py. Put this file in the same directory as iHello_service.py. This file creates a new class HDFHelloServiceClient that replaces the usual HelloServiceClient class, used by the server to listen to processes.
#!/usr/bin/env python
from zope.interface import Interface, implements
from collections import OrderedDict, defaultdict
from pyon.service.service import BaseService, BaseClients
from pyon.net.endpoint import RPCClient, ProcessRPCClient
from interface.services.examples.hello.ihello_service import HelloServiceClientMixin
@swarbhanu
swarbhanu / hdf_hello.yml
Created December 16, 2011 18:36
Use this hdf_hello.yml file to launch the server that accepts an hdf file inside a message from a client, modifies it and returns the modified hdf file back to the client as a message. Usage example: bin/pycc --rel=res/deploy/examples/hdf_hello.yml
type: release
name: MyConfig
version: 0.1
description: Demo deployment configuration
ion: 0.0.1
apps:
- name: hdf_hello
description: HDF Hello service
version: 0.1
processapp: [hdf_hello, examples.service.hdf_hello, HDFHelloService]