You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2022/09/02 16:02:12 UTC

[GitHub] [nifi] NissimShiman commented on a diff in pull request #6254: NIFI-10287 ExecuteScript - Allow python scripts to use external modules

NissimShiman commented on code in PR #6254:
URL: https://github.com/apache/nifi/pull/6254#discussion_r961825380


##########
nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/ScriptingComponentHelper.java:
##########
@@ -265,7 +265,11 @@ public void setupVariables(final PropertyContext context) {
         scriptEngineName = context.getProperty(SCRIPT_ENGINE).getValue();
         scriptPath = context.getProperty(ScriptingComponentUtils.SCRIPT_FILE).evaluateAttributeExpressions().getValue();
         scriptBody = context.getProperty(ScriptingComponentUtils.SCRIPT_BODY).getValue();
-        modules = context.getProperty(ScriptingComponentUtils.MODULES).evaluateAttributeExpressions().asResources().flattenRecursively();
+        if (scriptEngineName.equals("python")) {
+            modules = context.getProperty(ScriptingComponentUtils.MODULES).evaluateAttributeExpressions().asResources();

Review Comment:
   Thank for you very much, @markobean for looking at this! 
   
   "flatten recursively"  finds all the files in a directory
   This doesn't work well with python which prefers including directory names as opposed to the file names.  
   
   More specifically, we are using sys.path.append 
   https://github.com/apache/nifi/blob/rel/nifi-1.17.0/nifi-nar-bundles/nifi-scripting-bundle/nifi-scripting-processors/src/main/java/org/apache/nifi/script/impl/JythonScriptRunner.java#L40 
   which then looks inside the directory for any needed files
   
   It is looking for a directory name, though, so when it gets a filename (because of the "flatten recursively")
   it doesn't handle it 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