当前位置: 首页>>代码示例>>Python>>正文


Python IonObject.process_id方法代码示例

本文整理汇总了Python中pyon.public.IonObject.process_id方法的典型用法代码示例。如果您正苦于以下问题:Python IonObject.process_id方法的具体用法?Python IonObject.process_id怎么用?Python IonObject.process_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyon.public.IonObject的用法示例。


在下文中一共展示了IonObject.process_id方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_transform

# 需要导入模块: from pyon.public import IonObject [as 别名]
# 或者: from pyon.public.IonObject import process_id [as 别名]
    def create_transform(self,
                         name='',
                         description='',
                         in_subscription_id='',
                         out_streams=None,
                         process_definition_id='',
                         configuration=None):

        """Creates the transform and registers it with the resource registry
        @param process_definition_id The process definition contains the module and class of the process to be spawned
        @param in_subscription_id The subscription id corresponding to the input subscription
        @param out_stream_id The stream id for the output
        @param configuration {}

        @return The transform_id to the transform
        """

        # ------------------------------------------------------------------------------------
        # Resources and Initial Configs
        # ------------------------------------------------------------------------------------
        # Determine Transform Name

        if isinstance(configuration, IonObjectBase):
            #@todo Is this the right way to handle configs that come as IonObjects?
            configuration = self.serializer.serialize(configuration)
            # strip the type
            self._strip_types(configuration)


        elif not configuration:
            configuration = {}

        # Handle the name uniqueness factor
        res, _ = self.clients.resource_registry.find_resources(name=name, id_only=True)
        if len(res)>0:
            raise BadRequest('The transform resource with name: %s, already exists.' % name)

        transform_name=name

        #@todo: fill in process schedule stuff (CEI->Process Dispatcher)
        #@note: In the near future, Process Dispatcher will do all of this

        if not process_definition_id:
            raise NotFound('No process definition was provided')

        process_definition = self.clients.process_dispatcher.read_process_definition(process_definition_id)
        module = process_definition.executable.get('module','ion.processes.data.transforms.transform_example')
        cls = process_definition.executable.get('class','TransformExample')

        # Transform Resource for association management and pid
        transform_res = IonObject(RT.Transform,name=transform_name,description=description)
        
        # ------------------------------------------------------------------------------------
        # Spawn Configuration and Parameters
        # ------------------------------------------------------------------------------------

        subscription = self.clients.pubsub_management.read_subscription(subscription_id = in_subscription_id)
        listen_name = subscription.exchange_name


        configuration['process'] = {
            'name':transform_name,
            'type':'stream_process',
            'listen_name':listen_name
        }
        if out_streams:
            configuration['process']['publish_streams'] = out_streams
            stream_ids = list(v for k,v in out_streams.iteritems())
        else:
            stream_ids = []


        # ------------------------------------------------------------------------------------
        # Process Spawning
        # ------------------------------------------------------------------------------------
        # Spawn the process
        pid = self.clients.process_dispatcher.schedule_process(
            process_definition_id=process_definition_id,
            configuration=configuration
        )
        transform_res.process_id =  pid
        
        # ------------------------------------------------------------------------------------
        # Handle Resources
        # ------------------------------------------------------------------------------------
        transform_id, _ = self.clients.resource_registry.create(transform_res)


        self.clients.resource_registry.create_association(transform_id,PRED.hasProcessDefinition,process_definition_id)
        self.clients.resource_registry.create_association(transform_id,PRED.hasSubscription,in_subscription_id)


        for stream_id in stream_ids:
            self.clients.resource_registry.create_association(transform_id,PRED.hasOutStream,stream_id)

        return transform_id
开发者ID:daf,项目名称:coi-services,代码行数:98,代码来源:transform_management_service.py


注:本文中的pyon.public.IonObject.process_id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。