Closed chris762 closed 3 years ago
Hi @chris762 sorry I hadn't responded to this earlier, something is up with my notifications on the repo for new issues that I need to figure out further. I have today taken some thought from your Issue in implementing controls for Paramter Contexts on the Next branch, specifically if you look at parameters.py, and the tests to go with it, I think you'll see how the delete should work. I included a convenience method which should help with your exact case here. Part of the issue you were having is probably related to using update_parameter_context, which doesn't work intuitively for Parameters that already exist, you instead want to use submit_parameter_context_update as I have in nipyapi.parameters. update_parameter_context. Hopefully this simplifies your logic a bit, please let me know if I've missed the point or you could use more convenience functions here :)
https://github.com/Chaffelson/nipyapi/blob/next/nipyapi/parameters.py https://github.com/Chaffelson/nipyapi/blob/next/tests/test_parameters.py
Hi @Chaffelson - Thanks very much for getting back to me and making this enhancement. This looks very good and I will plan to test it out in the coming weeks. Thanks again and I will let you know if I hit any snags!
Should be fixed in 0.16.0
Description
We use the ParameterContextsApi to update our parameter values when deploying from cluster to cluster. We wanted to start issuing a cleanup step in our pipeline, where we could remove old/unused parameters from parameter contexts, which were attached to PG's being deployed. The logic is just looking for any parameters which have a "referencing_components" = []. I was told by Mark Payne today that in order to delete a key/value programmatically from a parameter context, I would need to modify the parameter value to have an explicit null. Didn't seem like a big deal because that is exactly how we update the parameters when deploying, but I noticed something which seems to be related to Pythons None/null compatibility. I am not entirely sure how the request is submitted or received, so I thought I would ask you first.
What I Did
Consider this function:
The function accepts the ID of a given processor group being deployed and:
This is exactly how we modify the sensitive and non-sensitive values when we are deploying things around and it has thus far worked perfectly. The problem I see here is when we submit the None type. I can see that the parameter_body correctly saves the None type in the dict within the parameter_body.component.parameters array and it does successful submit the entire object to the update_parameter_context. The issue is nothing ever gets removed. I get an object back from the service which has the same values which were previously set. If I change that None type to be anything else (which is string based - such as "Chris"), it works just fine. My uneducated guess is something is getting mixed up between the None and expected null value the Nifi API is hoping to see (but that could be totally wrong).
Any easy way to reproduce this would be to:
Urgency
This is probably more of a "Does this make sense to you?" type of thing. It does seem like something is off, but I don't know that I can pinpoint it.
Thanks and please let me know if something doesn't make sense.
Thanks, Chris Lundeberg