cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
matth1
Level IV

Stop python code being written to JMP log

Is there a way to stop JMP from printing a copy of code submitted to Python to the log?

It seems that every time I run

Python Submit( code )

I get a copy of code in the log.

If only running once it's not a big deal, but if running a small chunk of python many times it does clutter up the log, making real messages harder to find. Does it also have a performance impact due to writing to the screen?

I'm using JMP 18.0.1.

 

Simple example:

Names Default To Here( 1 );
for(i = 1, i <= 10, i++,
	Python Send( i );
	Python Submit( "\[
b = i / 2
a = b ** 2]\" );
	show( geta = Python Get( a ) );
);

Gives the following:

/*:

//:*/

b = i / 2
a = b ** 2
/*:

geta = Python Get(a) = 0.25;
//:*/

b = i / 2
a = b ** 2
/*:

geta = Python Get(a) = 1;
//:*/

b = i / 2
a = b ** 2
/*:

geta = Python Get(a) = 2.25;
//:*/

b = i / 2
a = b ** 2
/*:

geta = Python Get(a) = 4;
//:*/
// ....... and so on
1 ACCEPTED SOLUTION

Accepted Solutions
pmroz
Super User

Re: Stop python code being written to JMP log

You could try the log capture() function.

a = "Goodbye";
b = log capture(
	print("Hello World");
	print(a);
// Python commands here... ); write(b);

View solution in original post

7 REPLIES 7
pmroz
Super User

Re: Stop python code being written to JMP log

You could try the log capture() function.

a = "Goodbye";
b = log capture(
	print("Hello World");
	print(a);
// Python commands here... ); write(b);
matth1
Level IV

Re: Stop python code being written to JMP log

Thanks! I had forgotten about log capture().

Re: Stop python code being written to JMP log

The scripting index shows the optional parameter echo(True | False).  

Python Submit( code, echo(False) );

 

Unfortunately, this optional argument is ignored in 18.0 ( and 18.0.1 ) so the log capture is the way to go at this point.

This was fixed earlier this month but did not make it into the code base for the upcoming 18.1 maintenance release.  We had already passed the code freeze deadline for 18.1.  It has been fixed in our mainline development track. (JMP 19)

 

Similarly, the companion to this jmp.run_jsl() also has the optional echo argument added.  (JMP 19)

 jmp.run_jsl( '''code''', echo=True|False

matth1
Level IV

Re: Stop python code being written to JMP log


@Paul_Nelson wrote:

The scripting index shows the optional parameter echo(True | False).  

Python Submit( code, echo(False) );


The echo parameter doesn't appear in the scripting index for me, in either 18.0.1 or 17.2:

matth1_0-1719484056759.png

Is it in Pro only?

Re: Stop python code being written to JMP log

It may have been documented in the on-line help documentation or it was an unintentional oversight.  It also may have been mentioned with Python Execute().  If you run across documentation of the optional arguments echo(True | False) you will probably also see another optional parameter expand ( True | False ).  Disregard that one, it's been removed in 19.

matth1
Level IV

Re: Stop python code being written to JMP log


@Paul_Nelson wrote:

Unfortunately, this optional argument is ignored in 18.0 ( and 18.0.1 ) so the log capture is the way to go at this point.

This was fixed earlier this month but did not make it into the code base for the upcoming 18.1 maintenance release.  We had already passed the code freeze deadline for 18.1.  It has been fixed in our mainline development track. (JMP 19)


Hi @Paul_Nelson,

For JMP 19, will the echo parameter offer any granularity on what is printed to the log? For example, it could be useful to disable printing the python code, but still allow messages from Python (from print() commands for example, or errors from libraries) to be printed to the log as generated. At the moment, the Log Capture() method will always catch everything.

Thanks!

Re: Stop python code being written to JMP log

I wanted to test it out before replying.  

 

Yes, with the current code and my test cases, the Python print( value )'s output still comes through even with the code not echoing to log, as does the stack Traceback: when an error occurs in Python code. With an error exception thrown in Python, the JSL returns a -1.  std::disclaimer< this is pre-release development, while I believe this to be close to final form, no guarantees. >.  The idea of controllable logging levels is an interesting feature idea.