You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by "taz1988 (via GitHub)" <gi...@apache.org> on 2024/10/15 16:12:40 UTC
[PR] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
taz1988 opened a new pull request, #9390:
URL: https://github.com/apache/nifi/pull/9390
…ty descriptors in case of python processors
<!-- Licensed to the Apache Software Foundation (ASF) under one or more -->
<!-- contributor license agreements. See the NOTICE file distributed with -->
<!-- this work for additional information regarding copyright ownership. -->
<!-- The ASF licenses this file to You under the Apache License, Version 2.0 -->
<!-- (the "License"); you may not use this file except in compliance with -->
<!-- the License. You may obtain a copy of the License at -->
<!-- http://www.apache.org/licenses/LICENSE-2.0 -->
<!-- Unless required by applicable law or agreed to in writing, software -->
<!-- distributed under the License is distributed on an "AS IS" BASIS, -->
<!-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -->
<!-- See the License for the specific language governing permissions and -->
<!-- limitations under the License. -->
# Summary
[NIFI-13872](https://issues.apache.org/jira/browse/NIFI-13872)
# Tracking
Please complete the following tracking steps prior to pull request creation.
### Issue Tracking
- [x] [Apache NiFi Jira](https://issues.apache.org/jira/browse/NIFI-13872) issue created
### Pull Request Tracking
- [x] Pull Request title starts with Apache NiFi Jira issue number, such as `NIFI-13872`
- [x] Pull Request commit message starts with Apache NiFi Jira issue number, as such `NIFI-13872`
### Pull Request Formatting
- [x] Pull Request based on current revision of the `main` branch
- [x] Pull Request refers to a feature branch with one commit containing changes
# Verification
Please indicate the verification steps performed prior to pull request creation.
### Build
- [x] Build completed using `mvn clean install -P contrib-check`
- [x] JDK 21
### Licensing
- [ ] New dependencies are compatible with the [Apache License 2.0](https://apache.org/licenses/LICENSE-2.0) according to the [License Policy](https://www.apache.org/legal/resolved.html)
- [ ] New dependencies are documented in applicable `LICENSE` and `NOTICE` files
### Documentation
- [ ] Documentation formatting appears as expected in rendered files
--
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] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
Posted by "markap14 (via GitHub)" <gi...@apache.org>.
markap14 commented on code in PR #9390:
URL: https://github.com/apache/nifi/pull/9390#discussion_r1828227527
##########
nifi-framework-bundle/nifi-framework-extensions/nifi-py4j-framework-bundle/nifi-python-framework/src/main/python/framework/ProcessorInspection.py:
##########
@@ -47,6 +47,70 @@ def visit_Assign(self, node):
self.string_assignments.append[variable_name] = string_value
self.generic_visit(node)
+class CollectPropertyDescriptorVisitors(ast.NodeVisitor):
+
+ def __init__(self, module_string_constants):
+ self.module_string_constants = module_string_constants
+ self.discovered_property_descriptors = {}
+ self.logger = logging.getLogger("python.CollectPropertyDescriptorVisitors")
+
+ def resolve_dependencies(self, node: ast.AST):
+ resolved_dependencies = []
+ for dependency in node.elts:
+ variable_name = dependency.args[0].id
+ if not self.discovered_property_descriptors[variable_name]:
+ self.logger.error(f"Not able to find actual property descriptor for {variable_name}, so not able to resolve property dependencies.")
+ else:
+ actual_property = self.discovered_property_descriptors[variable_name]
+ dependent_values = []
+ for dependent_value in dependency.args[1:]:
+ dependent_values.append(get_constant_values(dependent_value, self.module_string_constants))
+ resolved_dependencies.append(PropertyDependency(name = actual_property.name,
+ display_name = actual_property.display_name,
+ dependent_values = dependent_values))
+ return resolved_dependencies
+
+ def resolve_property_descriptor_name_in_code(self, node: ast.AST):
+ if isinstance(node.targets[0], ast.Name):
+ return node.targets[0].id
+ elif isinstance(node.targets[0], ast.Attribute):
+ return node.targets[0].attr
+ else:
+ raise Exception("Unable to determine name from source code")
+
+ def visit_Assign(self, node: ast.AST):
+ if self.assignment_is_property_descriton(node):
+ property_descriptor_name_in_code = self.resolve_property_descriptor_name_in_code(node)
+ self.logger.debug(f"Found PropertyDescriptor in the following assignment {property_descriptor_name_in_code}")
+ if not node.value.keywords:
+ self.logger.error(f"Not able to parse {property_descriptor_name_in_code} PropertyDescriptor as no keywords assignments used.")
+ else:
+ descriptor_info = {}
+ for keyword in node.value.keywords:
+ key = keyword.arg
+ if key == 'dependencies':
+ self.logger.info(f"Resolving dependencies for {property_descriptor_name_in_code}.")
Review Comment:
This should be a debug log, I believe. As-is, it keeps showing up in the logs because this is run periodically. So then we end up with random log messages that don't make much sense on their own.
##########
nifi-framework-bundle/nifi-framework-extensions/nifi-py4j-framework-bundle/nifi-python-framework/src/main/python/framework/ProcessorInspection.py:
##########
@@ -47,6 +47,70 @@ def visit_Assign(self, node):
self.string_assignments.append[variable_name] = string_value
self.generic_visit(node)
+class CollectPropertyDescriptorVisitors(ast.NodeVisitor):
+
+ def __init__(self, module_string_constants):
+ self.module_string_constants = module_string_constants
+ self.discovered_property_descriptors = {}
+ self.logger = logging.getLogger("python.CollectPropertyDescriptorVisitors")
+
+ def resolve_dependencies(self, node: ast.AST):
+ resolved_dependencies = []
+ for dependency in node.elts:
+ variable_name = dependency.args[0].id
+ if not self.discovered_property_descriptors[variable_name]:
+ self.logger.error(f"Not able to find actual property descriptor for {variable_name}, so not able to resolve property dependencies.")
Review Comment:
Any log of this nature should indicate the name of the Processor class that is being parsed. Without it, it's difficult to understand what's happening.
--
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] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
Posted by "taz1988 (via GitHub)" <gi...@apache.org>.
taz1988 commented on PR #9390:
URL: https://github.com/apache/nifi/pull/9390#issuecomment-2454412533
Fix is added, test is green locally. Somebody please kick the workflow
--
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] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
Posted by "taz1988 (via GitHub)" <gi...@apache.org>.
taz1988 commented on code in PR #9390:
URL: https://github.com/apache/nifi/pull/9390#discussion_r1828397814
##########
nifi-framework-bundle/nifi-framework-extensions/nifi-py4j-framework-bundle/nifi-python-framework/src/main/python/framework/ProcessorInspection.py:
##########
@@ -47,6 +47,70 @@ def visit_Assign(self, node):
self.string_assignments.append[variable_name] = string_value
self.generic_visit(node)
+class CollectPropertyDescriptorVisitors(ast.NodeVisitor):
+
+ def __init__(self, module_string_constants):
+ self.module_string_constants = module_string_constants
+ self.discovered_property_descriptors = {}
+ self.logger = logging.getLogger("python.CollectPropertyDescriptorVisitors")
+
+ def resolve_dependencies(self, node: ast.AST):
+ resolved_dependencies = []
+ for dependency in node.elts:
+ variable_name = dependency.args[0].id
+ if not self.discovered_property_descriptors[variable_name]:
+ self.logger.error(f"Not able to find actual property descriptor for {variable_name}, so not able to resolve property dependencies.")
+ else:
+ actual_property = self.discovered_property_descriptors[variable_name]
+ dependent_values = []
+ for dependent_value in dependency.args[1:]:
+ dependent_values.append(get_constant_values(dependent_value, self.module_string_constants))
+ resolved_dependencies.append(PropertyDependency(name = actual_property.name,
+ display_name = actual_property.display_name,
+ dependent_values = dependent_values))
+ return resolved_dependencies
+
+ def resolve_property_descriptor_name_in_code(self, node: ast.AST):
+ if isinstance(node.targets[0], ast.Name):
+ return node.targets[0].id
+ elif isinstance(node.targets[0], ast.Attribute):
+ return node.targets[0].attr
+ else:
+ raise Exception("Unable to determine name from source code")
+
+ def visit_Assign(self, node: ast.AST):
+ if self.assignment_is_property_descriton(node):
+ property_descriptor_name_in_code = self.resolve_property_descriptor_name_in_code(node)
+ self.logger.debug(f"Found PropertyDescriptor in the following assignment {property_descriptor_name_in_code}")
+ if not node.value.keywords:
+ self.logger.error(f"Not able to parse {property_descriptor_name_in_code} PropertyDescriptor as no keywords assignments used.")
+ else:
+ descriptor_info = {}
+ for keyword in node.value.keywords:
+ key = keyword.arg
+ if key == 'dependencies':
+ self.logger.info(f"Resolving dependencies for {property_descriptor_name_in_code}.")
Review Comment:
Yeah totally agree, forgot to change it, after I tested the code
--
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] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
Posted by "taz1988 (via GitHub)" <gi...@apache.org>.
taz1988 commented on PR #9390:
URL: https://github.com/apache/nifi/pull/9390#issuecomment-2415177443
Thanks, I will investigate tomorrow, what cause the 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] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
Posted by "markap14 (via GitHub)" <gi...@apache.org>.
markap14 commented on PR #9390:
URL: https://github.com/apache/nifi/pull/9390#issuecomment-2460355350
Thanks for updating @taz1988 . I'm a +1. @bbende did you have any additional concerns, or are you good to merge as well?
--
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] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
Posted by "bbende (via GitHub)" <gi...@apache.org>.
bbende merged PR #9390:
URL: https://github.com/apache/nifi/pull/9390
--
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] NIFI-13872: extend manifest generation to add dependencies for proper… [nifi]
Posted by "bbende (via GitHub)" <gi...@apache.org>.
bbende commented on PR #9390:
URL: https://github.com/apache/nifi/pull/9390#issuecomment-2415124829
@taz1988 thanks for the improvement, it looks like something in the change to the python property descriptor logic is causing a system failure where it can no longer load `WritePropertyToFlowFile.py` in `PythonProcessorIT - testFlowFileTransformWithEL`.
--
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