Chaffelson / nipyapi

A convenient Python wrapper for Apache NiFi
Other
244 stars 76 forks source link

Create a PutMongo processor #230

Closed omkaringale closed 3 years ago

omkaringale commented 3 years ago

Description

Create a PutMongo processor

What I Did

set the required properties in processor_PutMongo_config PutMongoFile = canvas.create_processor(root_process_group,processor_PutMongo,(randrange(0,4000),randrange(0,4000)),name=None,config=processor_PutMongo_config)

Error:(AttributeError: 'list' object has no attribute 'type')

Urgency

Pretty urgent, went through the official documentation of nipyapi and NiFi but could'nt find anything yet. I've not dug super deep yet, so its possible i'm just missing something. Thanks so much for this project! Hopefully i'm not just missing something obvious.

Chaffelson commented 3 years ago

Have just tested this and it appears to work, here is my test script:

import nipyapi
putmongodef = nipyapi.canvas.get_processor_type('org.apache.nifi.processors.mongodb.PutMongo', greedy=False)
mongo_conf = nipyapi.nifi.ProcessorConfigDTO(scheduling_period='3s', properties={'Mongo URI': 'myMongoService'})
rpg = nipyapi.canvas.get_process_group('root')
r = nipyapi.canvas.create_processor(rpg, putmongodef, (400.0,400.0), 'test', mongo_conf)
r.component.config.scheduling_period
> '3s'
r.component.config.properties['Mongo URI']
> 'myMongoService'
omkaringale commented 3 years ago

Thanks for the quick reply. However the error is still the same that the list object has no attribute 'type'. Tried the exact same code. putmongodef = nipyapi.canvas.get_processor_type('org.apache.nifi.processors.mongodb.PutMongo') mongo_conf = nipyapi.nifi.ProcessorConfigDTO(scheduling_period='3s', properties={'Mongo URI': 'myMongoService'}) rpg = nipyapi.canvas.get_process_group('root') r = nipyapi.canvas.create_processor(rpg, putmongodef, (400.0,400.0), 'test', mongo_conf)

Chaffelson commented 3 years ago

ok can you give me the full error message please, there should be some context in there on where it's breaking down

omkaringale commented 3 years ago

Here's the full error message:

_**_r = nipyapi.canvas.create_processor(root_process_group, putmongodef, (400.0,400.0), 'test', mongo_conf)

~\AppData\Roaming\Python\Python38\site-packages\nipyapi\canvas.py in create_processor(parent_pg, processor, location, name, config) 520 y=float(location[1]) 521 ), --> 522 type=processor.type, 523 name=processor_name, 524 config=target_config

AttributeError: 'list' object has no attribute 'type'_**

Chaffelson commented 3 years ago

ah ok, I suspect you are passing in a list of Processor Types, if you search for PutMongo you will also get PutMongoRecord. Ensure you are passing in just a single Processor Type and not a list please. I'll add a test to the create_processor call to prevent this.

omkaringale commented 3 years ago

Thank you so much for your help!!! Was stuck with this simple issue for ages Just used the first processor type from the list. r = nipyapi.canvas.create_processor(root_process_group, putmongodef[0], (400.0,400.0), 'test', mongo_conf) Works perfectly :)