cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar

Developer Tutorial: New Python Integration and Scripting Capabilities in JMP 18

Published on ‎11-07-2024 03:32 PM by Community Manager Community Manager | Updated on ‎11-07-2024 05:42 PM

This video includes Q&A from attendees who attended the live webinar on March 21, 2024. at time 25:36- 50:39 and 01:00:21  A summary of some of the Q&A is provided below.  For a full answer, consider reviewing the Q&A in the video.

 

Q: Can you send me what the GAPs are from JMP 16 to 18.  

A: See the full release notes and version update notes.

 

Q: If python 3.11 is the default version, what about using libraries that rely on older versions of python?  Will there be some level of backwards compatibility with no guarantee of script running?

A: It will depend on what you can get from package repositories for 3.11.  If they work across versions. ,they may not run  or you may get message ‘package not found.’  Some packages require compilation and you must compile in a development environment on your system and in a few cases you have to install a standard 3.11 installation.

 

Q: I want to ensure that this is doesn't require Anaconda/Miniconda/Conda due to the cost and license requirement of these platforms.

A: These are NOT required.

 

Q: Can package installation be redirect to a controlled repository?  We cannot install directly from pypi.org without auditing them first.  I wasn't clear from your description if we could, for instance, create a venv, do package installation and then run that script in JMP's script editor.

A: No, we do not support venv and our environment is very close to that.  Most redirected packages require carefully changing vars in the jpip wrapper.

 

Q: Is possible to read the Python JMP environment and know how many packages you have installed?  as a user would like to keep track of packages version.

A: pip will give you the list of packages installed.

 

Q: Is there any tab level dependency to the python code in this environment?

A: The editor follows Python conventions.  Reformat is not enabled.  We will look at this for future release.

 

Q: Can I bundle python packages for my enterprise installation of JMP so my end user does not need to install libraries? For example, if I wanted to do a Python statistical analysis currently not in JMP (like Paul showed) can I publish that analysis report to JMP Live for my org to view and interact with.

A: If you can get your output into a JMP report you can publish it.  At present JMP Live does not support Python scripts running on the server but there are some security concerns that require more research to assure we don't compromise security.

 

Q: Does this mean JMP can't use other versions of Python? On the whole, if that's the tradeoff to having all the environment stuff handled so nicely, I think it's probably great, but just wondering.

A: Yes, you can use Python in JMP and then save to your external process and operate on the saved file. Python.org supports a Python version for only 5 years, so we chose this version to try to give us a full JMP 18-month cycle for users to use this.  We will switch to later versions later to give users a full 5 years if possible. To clarify: 

JMP 18 will only utilize the installed embedded Python 3.11.  Python Init() and Python Connect() parameters for selecting a Python installation have all been deprecated and the parameters ignored.

 

JMP 18's Python is an isolated environment so it will not (should not) conflict with other Python installations on your system.  There is nothing that prevents you from utilizing your existing Python pipeline.  You can use JMP's Python to get data to and from JMP to hand off to your existing pipeline.

 

Q: Today as user i create Add-ins in JSL. Can i with JMP 18  create add-ins that combine JSL and Python as I see best fit?

A: Yes ,with the caveat that the add-in builder does not recognize Python files yet but you can edit the zip file and you can add the python file and JMP can run it.

 

Q: If I want to access a JMP data table from jupyter notebook in a different Python environment, would the 'import ‘JMP' instruction still work?

A: No.

 

Resources

 



Start:
Fri, Mar 22, 2024 02:00 PM EDT
End:
Fri, Mar 22, 2024 03:00 PM EDT
Labels (1)
0 Kudos
6 Comments
gail_massari
Community Manager

From @Paul_Nelson  on ‎03-22-2024 04:03 PM

I want to clarify the response to the question:

Q: Does this mean JMP can't use other versions of Python? 

 

JMP 18 will only utilize the installed embedded Python 3.11.  Python Init() and Python Connect() parameters for selecting a Python installation have all been deprecated and the parameters ignored.

 

JMP 18's Python is an isolated environment so it will not (should not) conflict with other Python installations on your system.  There is nothing that prevents you from utilizing your existing Python pipeline.  You can use JMP's Python to get data to and from JMP to hand off to your existing pipeline.

gail_massari
Community Manager
From  on ‎03-22-2024 06:55 PM
@gail_massari wrote:

Q: If I want to access a JMP data table from jupyter notebook in a different Python environment, would the 'import ‘JMP' instruction still work?

A: No.

How about "same Python environment" - is it possible to link python IDEs like Spyder or Visual Studio Code Editors  to the JMP Python installation?

To have all the Python programming functionality of the IDEs + the possibility to

import 'JMP'
gail_massari
Community Manager
From  on ‎03-25-2024 01:04 PM

The import jmp statement will only function from within JMP itself.  

 

It is not implemented as a shared library or Python script, the bridge from Python to JMP functionality is C++ code internal to the JMP executable itself.

gail_massari
Community Manager
From ‎03-25-2024 04:31 PM

When sending tables with images to Python, is it possible to access the images from within Python?

gail_massari
Community Manager
From    @Paul_Nelson    ‎on  04-17-2024 03:39 PM
# getColImage.py
# 
# Description: 
#   Get a picture from an image column using Python
#   JMP 18 only supports numeric and character column types for transfer
#   but the value can be grabbed via JSL, and passed to Python as a string
#   in the meantime.  The Python code will need to trim off the 
#   New Image( Char To Blob()) and decode the image back to binary.
import jmp

dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class Families.jmp')

jmp.run_jsl('''
Names Default to Here(1);
dt = Current Data Table();

img = dt:picture[1];		// get the picture
img_str = char(img);		// make it a string
Python Send(img_str);		// send Python the string
''')

# print the object's JSL representation
# which is text encoding of the binary, a description of the 
# encoding and image format type.
print(img_str)
			

With output:

New Image(Char To Blob( "1iVBORw0KGgoAAAANSUhEUgAAAEYAAABGCAYAAABxLuK ...

VORK5CYII=", "base64compressed" ), "png")

From the Python side you need to parse out the Blob string, compression method, and format, decode the image from text to binary.

 

However, an alternate and likely better way is to use << Get Pixels("rgba"); on the column to get a 4 element list of matrices which is supported via Python Send().

 

Updated getColImage.py

# getColImage.py
# 
# Description: 
#   Get a picture from an image column using Python
#   JMP 18 only supports numeric and character column types for transfer
#   but the value can be grabbed via JSL, and passed to Python as a string
#   in the meantime.  The Python code will need to trim off the 
#   New Image( Char To Blob()) and decode the image back to binary.
#
#   Alternatively use << Get Pixels("rgba");  to get a list of matricies
#   which is passable from JSL to Python using Python Send();
#
import jmp

dt = jmp.open(jmp.SAMPLE_DATA + 'Big Class Families.jmp')

jmp.run_jsl('''
Names Default to Here(1);
dt = Current Data Table();

img = dt:picture[1];		// get the picture
img_str = char(img);		// make it a string
Python Send(img_str);		// send Python the string

asRGBA = { r, g, b, a} = dt:picture[1] << Get Pixels("rgba");
Python Send(asRGBA);
''')

# print the object's JSL representation
# which is text encoding of the binary, a description of the 
# encoding and image format type.
print(img_str)
print(asRGBA)				

 

gail_massari_4-1731082900358.png

 

This post originally written in German has been computer translated for you. When you reply, it will also be translated back to German.

gail_massari
Community Manager
From on ‎04-17-2024 03:41 PM

Somewhere the first few lines of the post got clipped.

No, not directly possible using the Python Integration in JMP 18, but a work around is possible using JSL.

The focus on JMP 18 was character and numeric columns. Full support of the data table is current ongoing development.