cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar

Python Submit File fails right after package installation (timing issue)

Hello,

I’m currently developing a JMP add-in that relies on embedded Python scripts.
At startup, the add-in installs the required Python packages (using a local wheel repository) before executing any Python code.

The issue I’m facing is that, when the add-in is launched for the first time, it sometimes fails to execute the embedded Python functions defined in the files submitted right after the package installation.

It looks like JMP continues executing the script before the PowerShell installation process has actually completed.
The error I get is  that Python cannot find one of the functions defined in the two Python Submit File calls.

After the first successful installation, everything works fine (probably because the packages are already present and the scripts are then loaded properly).

How can I make sure that JMP waits until the PowerShell installation process is fully completed before running Python Submit File()?

Here’s the relevant part of my code:

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" );
1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: Python Submit File fails right after package installation (timing issue)

Using Read Function("text") is one option

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");
-Jarmo

View solution in original post

2 REPLIES 2
jthi
Super User

Re: Python Submit File fails right after package installation (timing issue)

Using Read Function("text") is one option

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");
-Jarmo

Re: Python Submit File fails right after package installation (timing issue)

Thank you ! 

Recommended Articles