Hallo,
Ich entwickle derzeit ein JMP-Add-In, das auf eingebetteten Python-Skripten basiert.
Beim Start installiert das Add-In die erforderlichen Python-Pakete (unter Verwendung eines lokalen Wheel-Repositorys), bevor Python-Code ausgeführt wird.
Das Problem, mit dem ich konfrontiert bin, besteht darin, dass beim ersten Start des Add-Ins die Ausführung der eingebetteten Python-Funktionen, die in den direkt nach der Paketinstallation übermittelten Dateien definiert sind, manchmal fehlschlägt.
It looks like JMP continues executing the script bevor der PowerShell-Installationsprozess tatsächlich abgeschlossen ist.
The error I get is that Python cannot find one of the functions defined in the two Python Submit File calls.
Nach der ersten erfolgreichen Installation funktioniert alles einwandfrei (wahrscheinlich, weil die Pakete bereits vorhanden sind und die Skripte dann ordnungsgemäß geladen werden).
How can I make sure that JMP waits until the PowerShell installation process is fully completed before running Python Submit File()?
Hier ist der relevante Teil meines Codes:
strPathjpip = dest_path || "\jpip.bat";
If( !File Exists( strPathjpip ),
Python Send( dest_path );
Python Submit( "
import jmp
import jmputils
jmputils.create_jpip(dest_path)
" );
);
// Build command to run
cmd = Eval Insert( "\[& "^strPathjpip^" install --no-index --find-links "^strPathPythonLibs^" numpy pandas scipy]\" );
Eval( Eval Expr( commands = {Expr( cmd )} ) );
icommand = 0;
// Use Run Program to execute the script
rp = Run Program(
Executable( "PowerShell.exe" ),
ReadFunction( Function( {this}, Write( this << Read ) ) ),
WriteFunction(
Function( {this},
icommand++;
If( icommand <= N Items( commands ),
this << Write( commands[icommand] ),
this << WriteEOF
);
)
)
);
// Include Python scripts
Python Submit File( strPathAddin || "include/PYTHON/exttolint.py" );
Python Submit File( strPathAddin || "include/PYTHON/normtolint.py" );
Die Verwendung der Lesefunktion („Text“) ist eine Möglichkeit
Names Default To Here(1);
RP = Run Program(
Executable("PING.EXE"/*path probably not needed*/ ),
Options({"-n 5", "localhost"}),
ReadFunction("text")
);
Show(RP);
Write("\!NDONE");