Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Having issue creating a LogMessage processor with values set for the default properties #289

Closed
instance-id opened this issue Sep 30, 2021 · 3 comments

Comments

@instance-id
Copy link

instance-id commented Sep 30, 2021

  • Nipyapi version: 0.16.2
  • NiFi version: 1.14.0
  • NiFi-Registry version: 1.14.0
  • Python version: 3.9 (I believe)
  • Operating System: Dev machine is Win 10, but Nifi servers are RHEL

Description

I am trying to deploy a LogMessage node, and while most everything is fine, the issue is that upon creation of the node, the properties are just creating a new separate set of properties after the original ones and not setting those values. Seen below is the code section in which I am using, followed by an example of the outcome. I tried the properties field using both single and double quotes, but it didn't seem to make a difference. Also, the L in Level for the Log Level property is capitalized in Nifi, but the second word of each of the other properties is not, I don't know if that has anything to do with it?

    log_message_name = F"{numeric}.{str(start_num + 2)}_{title}_Log"
    filename_string = '${filename}'
    prefix_string = F"__Log_PutFile_{put_file_name}_{title.lower()}"
    message_string = F"Unable to deliver {filename_string} to {put_file_path}"

    # -- LogMessage Processor --------------
    log_message = nipyapi.canvas.create_processor(
        parent_pg=process_group,
        processor=nipyapi.canvas.get_processor_type('LogMessage'),
        location=(400.0, 500.0),
        name=log_message_name,
        config=nipyapi.nifi.ProcessorConfigDTO(
            scheduling_period='1s',
            auto_terminated_relationships=['success', 'failure'],
            properties={
                "Log Level": "error",
                "Log prefix": prefix_string,
                "Log message": message_string
            },
        )
    )

Urgency

While it is technically blocking from being able to bulk deploy a large number of processors that are needed to be tested sooner rather than later, it really isn't a huge deal at this point, especially since I can just copy/paste the text if needed.

I am not sure if there is something that I am just not doing correctly, but after scouring this repo and more generic searches for 'nipyapi LogMessage' or log with keywords such as prefix and message, I can't seem to find any examples of it not only being done properly but being done at all.

If someone might be able to point me in the right direction, I would greatly appreciate it.


Update, I tried adjusting how I went about this based on a code example I found for another processor, but it, unfortunately, didn't seem to help any. Still had the same result of duplicating the properties. This was attempted by removing the initial properties I was trying to set during the creation of the processor so that there were only just the default property fields, trying to update the existing ones.

    log_properties_dict = log_message.to_dict()
    properties = log_properties_dict['component']['config']['properties']
    properties['Log Level'] = 'error'
    properties['Log prefix'] = prefix_string
    properties['Log message'] = message_string
    newConfig = nipyapi.nifi.ProcessorConfigDTO(properties=properties)
    nipyapi.canvas.update_processor(log_message, newConfig)
@instance-id
Copy link
Author

Never mind, my apologies. Upon dumping out the data that was within properties = log_properties_dict['component']['config']['properties'] I discovered that the properties were under the names 'log-level', 'log-prefix', and 'log-message'. By using those values instead, I was able to update them properly.

@Chaffelson
Copy link
Owner

Chaffelson commented Sep 30, 2021 via email

@instance-id
Copy link
Author

instance-id commented Oct 1, 2021

Something of a side question/recommendation request, when using nipyapi.canvas.create_connection(), I wanted to specify bends in the connection, but there doesn't seem to be a way to define them with the function available.

What would be the best way to go about doing so? Creating a while new create_connection function, or getting the return from the create function, then modifying it and sending another update, or something else altogether?

edit: Perhaps it's not even counted as a bend, but basically the position of the connector node in the middle between two processors.

double edit: Nevermind again, sorry, I got it figured out, lol.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants