如何解决使用nipyapi的PutMongo处理器
尝试在与本地实例连接的nipyapi中创建PutMongo处理器。我已经指定了所有必需的配置,但是似乎没有用。
PutMongoFile = canvas.create_processor(
root_process_group,processor_PutMongo,(randrange(0,4000),randrange(0,4000)),name=None,config=processor_PutMongo_config)
出现以下错误:
*AttributeError Traceback (most recent call last)
<ipython-input-48-ef1b815cdbdb> in <module>
----> 1 PutMongoFile = canvas.create_processor(root_process_group,config=processor_PutMongo_config)
~\AppData\Roaming\Python\python38\site-packages\nipyapi\canvas.py in create_processor(parent_pg,processor,location,name,config)
503 """
504 if name is None:
--> 505 processor_name = processor.type.split('.')[-1]
506 else:
507 processor_name = name
AttributeError: 'list' object has no attribute 'type'*
感谢任何帮助!
解决方法
我们在关于仓库here的问题讨论中解决了这个问题。 get_processor_type方法默认情况下是贪婪的,如果找到多个处理器类型,则将返回一个列表,在这种情况下,将同时查找PutMongo和PutMongoRecord。我已经更新了只允许完全匹配的方法,并在下一个版本中对此进行了更好的检查
,processor_PutMongo = canvas.get_processor_type('org.apache.nifi.processors.mongodb.PutMongo',identifier_type='name')
这将返回一个字典列表,其中包含处理器 PutMongo
和 PutMongoRecord
的详细信息。
这是您在打印 processor_PutMongo
时将获得的确切 JSON:
[
{
"bundle":{
"artifact":"nifi-mongodb-nar","group":"org.apache.nifi","version":"1.13.2"
},"controller_service_apis":"None","deprecation_reason":"None","description":"Creates FlowFiles from documents in MongoDB loaded by a user-specified query.","explicit_restrictions":"None","restricted":false,"tags":[
"read","get","mongodb"
],"type":"org.apache.nifi.processors.mongodb.GetMongo","usage_restriction":"None"
},{
"bundle":{
"artifact":"nifi-mongodb-nar","description": "A record-based version of GetMongo that uses the Record writers to write the MongoDB result set.","tags":[
"mongo","fetch","record","json","type":"org.apache.nifi.processors.mongodb.GetMongoRecord","usage_restriction":"None"
}
]
最短的解决方案是通过索引提取列表的第一个或第二个元素。
例如
PutMongo = canvas.create_processor(new_processor_group,processor_PutMongo[0],(randrange(0,20000),randrange(0,20000)),name=None,config=processor_PutMongo_config)
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。