You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "lordgamez (via GitHub)" <gi...@apache.org> on 2024/04/26 08:25:58 UTC
[PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
lordgamez opened a new pull request, #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770
- Additionally adapt some python classes more closely to NiFi's API
https://issues.apache.org/jira/browse/MINIFICPP-2341
----------------------------
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the LICENSE file?
- [ ] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1604690548
##########
extensions/python/pythonprocessors/nifiapi/properties.py:
##########
@@ -281,3 +284,21 @@ def getProperty(self, descriptor) -> PythonPropertyValue:
expression_language_support = descriptor.expressionLanguageScope != ExpressionLanguageScope.NONE
property_value = self.cpp_context.getProperty(property_name)
return PythonPropertyValue(self.cpp_context, property_name, property_value, expression_language_support)
+
+ def getStateManager(self) -> StateManager:
+ return self.cpp_context.getStateManager()
+
+ def getName(self) -> str:
+ return self.cpp_context.getName()
+
+ def getProperties(self) -> Dict[PropertyDescriptor, str]:
+ properties = dict()
+ cpp_properties = self.cpp_context.getProperties()
+
+ for property_name in cpp_properties:
+ for property_descriptor in self.processor.getPropertyDescriptors():
+ if property_descriptor.name == property_name:
+ properties[property_descriptor] = cpp_properties[property_name]
+ break
Review Comment:
I updated the test and the implementation of getProperties in 9eec8f9b0a61264578330919ed9e16fa2c5007fd
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1601405963
##########
extensions/python/PYTHON.md:
##########
@@ -166,6 +166,10 @@ Due to some differences between the NiFi and MiNiFi C++ processors and implement
- MiNiFi C++ only supports expression language with flow file attributes, so only FLOWFILE_ATTRIBUTES expression language scope is supported, otherwise the expression language will not be evaluated.
- MiNiFi C++ does not support property dependencies, so the property dependencies will be ignored. If a property depends on another property, the property will not be required.
- MiNiFi C++ does not support the use of self.jvm member in Python processors that provides JVM bindings in NiFi, it is set to None in MiNiFi C++.
+- Dynamic properties are supported in all Python processors and the dynamic properties defined in the flow configuration are automatically added. There is no need to define getDynamicPropertyDescriptor method in the Python processor. The only caveat is that the description of the dynamic property cannot be custom defined.
+- In MiNiFi C++ when the processor is stopped the stop event handling is done in the `notifystop()` processor which does not have the context available. Due to this the `def onStopped(self, context)` cannot be called in NiFi Python processors, so the `onStopped` method is not supported in MiNiFi C++.
Review Comment:
do you mean the following?
```suggestion
- In MiNiFi C++ when the processor is stopped the stop event handling is done in the `notifyStop()` method which does not have the context available. Due to this the `def onStopped(self, context)` cannot be called in NiFi Python processors, so the `onStopped` method is not supported in MiNiFi C++.
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1601416310
##########
extensions/python/pythonprocessors/nifiapi/properties.py:
##########
@@ -281,3 +284,21 @@ def getProperty(self, descriptor) -> PythonPropertyValue:
expression_language_support = descriptor.expressionLanguageScope != ExpressionLanguageScope.NONE
property_value = self.cpp_context.getProperty(property_name)
return PythonPropertyValue(self.cpp_context, property_name, property_value, expression_language_support)
+
+ def getStateManager(self) -> StateManager:
+ return self.cpp_context.getStateManager()
+
+ def getName(self) -> str:
+ return self.cpp_context.getName()
+
+ def getProperties(self) -> Dict[PropertyDescriptor, str]:
+ properties = dict()
+ cpp_properties = self.cpp_context.getProperties()
+
+ for property_name in cpp_properties:
+ for property_descriptor in self.processor.getPropertyDescriptors():
+ if property_descriptor.name == property_name:
+ properties[property_descriptor] = cpp_properties[property_name]
+ break
Review Comment:
can't we just flip it and do, `cpp_properties` seems to be a wrapped python dictionary, forwarding the `contains` call (which I think the following code would do)
```suggestion
for property_descriptor in self.processor.getPropertyDescriptors():
if property_descriptor.name in cpp_properties:
properties[property_descriptor] = cpp_properties[property_name]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1601416310
##########
extensions/python/pythonprocessors/nifiapi/properties.py:
##########
@@ -281,3 +284,21 @@ def getProperty(self, descriptor) -> PythonPropertyValue:
expression_language_support = descriptor.expressionLanguageScope != ExpressionLanguageScope.NONE
property_value = self.cpp_context.getProperty(property_name)
return PythonPropertyValue(self.cpp_context, property_name, property_value, expression_language_support)
+
+ def getStateManager(self) -> StateManager:
+ return self.cpp_context.getStateManager()
+
+ def getName(self) -> str:
+ return self.cpp_context.getName()
+
+ def getProperties(self) -> Dict[PropertyDescriptor, str]:
+ properties = dict()
+ cpp_properties = self.cpp_context.getProperties()
+
+ for property_name in cpp_properties:
+ for property_descriptor in self.processor.getPropertyDescriptors():
+ if property_descriptor.name == property_name:
+ properties[property_descriptor] = cpp_properties[property_name]
+ break
Review Comment:
can't we just flip it? `cpp_properties` seems to be a wrapped python dictionary, forwarding the `contains` call (which I think the following code would do)
```suggestion
for property_descriptor in self.processor.getPropertyDescriptors():
if property_descriptor.name in cpp_properties:
properties[property_descriptor] = cpp_properties[property_name]
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "lordgamez (via GitHub)" <gi...@apache.org>.
lordgamez commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1603707487
##########
extensions/python/PYTHON.md:
##########
@@ -166,6 +166,10 @@ Due to some differences between the NiFi and MiNiFi C++ processors and implement
- MiNiFi C++ only supports expression language with flow file attributes, so only FLOWFILE_ATTRIBUTES expression language scope is supported, otherwise the expression language will not be evaluated.
- MiNiFi C++ does not support property dependencies, so the property dependencies will be ignored. If a property depends on another property, the property will not be required.
- MiNiFi C++ does not support the use of self.jvm member in Python processors that provides JVM bindings in NiFi, it is set to None in MiNiFi C++.
+- Dynamic properties are supported in all Python processors and the dynamic properties defined in the flow configuration are automatically added. There is no need to define getDynamicPropertyDescriptor method in the Python processor. The only caveat is that the description of the dynamic property cannot be custom defined.
+- In MiNiFi C++ when the processor is stopped the stop event handling is done in the `notifystop()` processor which does not have the context available. Due to this the `def onStopped(self, context)` cannot be called in NiFi Python processors, so the `onStopped` method is not supported in MiNiFi C++.
Review Comment:
Yes, good catch, updated in 6015abfc8d282d8e9f9ef7458de4b4686298d696
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "martinzink (via GitHub)" <gi...@apache.org>.
martinzink closed pull request #1770: MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1591216617
##########
extensions/python/pythonprocessors/nifiapi/properties.py:
##########
@@ -281,3 +284,21 @@ def getProperty(self, descriptor) -> PythonPropertyValue:
expression_language_support = descriptor.expressionLanguageScope != ExpressionLanguageScope.NONE
property_value = self.cpp_context.getProperty(property_name)
return PythonPropertyValue(self.cpp_context, property_name, property_value, expression_language_support)
+
+ def getStateManager(self) -> StateManager:
+ return self.cpp_context.getStateManager()
+
+ def getName(self) -> str:
+ return self.cpp_context.getName()
+
+ def getProperties(self) -> Dict[PropertyDescriptor, str]:
+ properties = dict()
+ cpp_properties = self.cpp_context.getProperties()
+
+ for property_name in cpp_properties:
+ for property_descriptor in self.processor.getPropertyDescriptors():
+ if property_descriptor.name == property_name:
+ properties[property_descriptor] = cpp_properties[property_name]
+ break
Review Comment:
This is quadratic, we should improve this later to have linear complexity. It's fine for now, but I made a Jira issue to fix this later: [MINIFICPP-2361](https://issues.apache.org/jira/browse/MINIFICPP-2361)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "szaszm (via GitHub)" <gi...@apache.org>.
szaszm commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1627722859
##########
extensions/python/pythonprocessors/nifiapi/properties.py:
##########
@@ -281,3 +284,21 @@ def getProperty(self, descriptor) -> PythonPropertyValue:
expression_language_support = descriptor.expressionLanguageScope != ExpressionLanguageScope.NONE
property_value = self.cpp_context.getProperty(property_name)
return PythonPropertyValue(self.cpp_context, property_name, property_value, expression_language_support)
+
+ def getStateManager(self) -> StateManager:
+ return self.cpp_context.getStateManager()
+
+ def getName(self) -> str:
+ return self.cpp_context.getName()
+
+ def getProperties(self) -> Dict[PropertyDescriptor, str]:
+ properties = dict()
+ cpp_properties = self.cpp_context.getProperties()
+
+ for property_name in cpp_properties:
+ for property_descriptor in self.processor.getPropertyDescriptors():
+ if property_descriptor.name == property_name:
+ properties[property_descriptor] = cpp_properties[property_name]
+ break
Review Comment:
That's a hash table lookup now, right? That would be amortized linear complexity, which is fine IMO. If you can confirm, I'll close the Jira issue.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINIFICPP-2341 Include custom relationships in C2 manifest for NiFi python processors [nifi-minifi-cpp]
Posted by "adamdebreceni (via GitHub)" <gi...@apache.org>.
adamdebreceni commented on code in PR #1770:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1770#discussion_r1627768386
##########
extensions/python/pythonprocessors/nifiapi/properties.py:
##########
@@ -281,3 +284,21 @@ def getProperty(self, descriptor) -> PythonPropertyValue:
expression_language_support = descriptor.expressionLanguageScope != ExpressionLanguageScope.NONE
property_value = self.cpp_context.getProperty(property_name)
return PythonPropertyValue(self.cpp_context, property_name, property_value, expression_language_support)
+
+ def getStateManager(self) -> StateManager:
+ return self.cpp_context.getStateManager()
+
+ def getName(self) -> str:
+ return self.cpp_context.getName()
+
+ def getProperties(self) -> Dict[PropertyDescriptor, str]:
+ properties = dict()
+ cpp_properties = self.cpp_context.getProperties()
+
+ for property_name in cpp_properties:
+ for property_descriptor in self.processor.getPropertyDescriptors():
+ if property_descriptor.name == property_name:
+ properties[property_descriptor] = cpp_properties[property_name]
+ break
Review Comment:
yes, I think the Jira issue can be closed now
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org