Chaffelson / nipyapi

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

upsert_parameter_to_context failing! #307

Closed silverbullet1 closed 2 years ago

silverbullet1 commented 2 years ago

Description

My code has suddenly started breaking without making any recent change. I was creating parameters and upserting them to a parameter context via the the following piece of code:


def create_parameters(data, parameter_context):
    for connection in data:
       for key, value in connection.items():
             parameter_entity = parameters.prepare_parameter(f"{connection["instance_id"]}_{key}", value)
             parameters.upsert_parameter_to_context(parameter_context, parameter_entity)
          print(f"Parameter {connection["instance_id"]_{key} created successfully")
          time.sleep(5)

This is being invoked with a list with k,v pairs [{k1: v1, k2: v2 ..}] and for parameter_context I am passing get_parameter_context(nipyapi.canvas.get_root_pg_id())

This code has suddenly stopped working. Its giving the following error: An exception occurred while creating parameters : 'list' object has no attribute 'component'

What I Did

On some debugging it looks like the upsert command is failing where we are trying to access context.component.parameters = [parameter]

Urgency

I have neither updated nipyapi nor nifi, and this is why I find this behaviour strange. Please help, as its blocking some critical stuff.

silverbullet1 commented 2 years ago

I think someone has changed something in the nifi config from UI, not sure what got changed.

silverbullet1 commented 2 years ago

got it, i created another parameter context with same prefix and hence search was giving a list..very stupid of me. Thanks.