NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Calling Python functions, some issues.

I am using the python step type in TS 2016 32 bit version. Currently working with Python 3.6.x

I want to first start by saying I have gone through the examples provided and understand how they work.

First I initialize my object reference to the class that I am using.

Next I do something like a "string value tests" and click on "configure Python Step"

I select "Operation Scope" drop down menu and have the option to pick "Class Instance" or "Class static" or "Module."

The problem:

If I pick "Class Static" all the drop menus will populate with my classes and Function names, that's Great!

1. But if i pick "Class Instanced" none of the functions populate. Is this designed this way on purpose  even though my functions are "instanced"?

2. When ever I update my python code and change the name of a function for example; I can see the new function by pressing the "refresh blue icon" but none of the calls to my functions work and i get an error. The error always says "MyClassNameHere object has no attribute MyFunctionHere .....NI_teststand_helper.py line 30"

Essentially what this error is telling me is that TestStand is still holding some reference to my last .py code and cant properly find the updated one. I can delete my .seq file and restart TS and have success calling my edited .py but otherwise that old code is stuck in memory....or something.

0 Kudos
Message 1 of 10
(4,764 Views)

Try to 'Unload All Modules' it works with me

 

 

 

0 Kudos
Message 2 of 10
(4,735 Views)


I am using the python step type in TS 2016 32 bit version. Currently working with Python 3.6.x

 

 


By the way, can you tell me how did you install Python step for TS 32 bit?

 

I installed a fresh Windows 10 64 bit, TS 2017 32 bit, Python 3.6.5 32 bit and Python Step. But I am still getting 'Invalid Python version' (see attached picture).

Same behavior also on win 7

with TS 2017 64 bit and Python 3.6 64 bit, it works without any problem

0 Kudos
Message 3 of 10
(4,731 Views)

Hi,

I have same issue and does happen with example sequence provided by installation: Passing Data to Python.seq

 

However function(s) does work if you know what to call. But would be nice to see available methods without opening python source files.

0 Kudos
Message 4 of 10
(4,724 Views)

@hbs_80

This might be a good temporary solution. I will try it and let you know.

0 Kudos
Message 5 of 10
(4,719 Views)

@hbs_80


@hbs_80 wrote:


I am using the python step type in TS 2016 32 bit version. Currently working with Python 3.6.x

 

 


By the way, can you tell me how did you install Python step for TS 32 bit?

 

I installed a fresh Windows 10 64 bit, TS 2017 32 bit, Python 3.6.5 32 bit and Python Step. But I am still getting 'Invalid Python version' (see attached picture).

Same behavior also on win 7

with TS 2017 64 bit and Python 3.6 64 bit, it works without any problem


I installed Python 3.6.8 for windows 32 found on their site. (https://www.python.org/downloads/windows/)

For the NI stepType I went to NI's page and installed "PythonST.exe" (http://www.ni.com/download/teststand-python-step-types/7761/en/)

I re-booted my PC and the step type recognized which version of Python I have installed.

-side note this might not be required but you may need to edit your "environment variable" found in windows specifically "Path." I didn't need to but a co-worker of mine recommend I add python to them.

0 Kudos
Message 6 of 10
(4,712 Views)

@mini_xx wrote:

Hi,

I have same issue and does happen with example sequence provided by installation: Passing Data to Python.seq

 

However function(s) does work if you know what to call. But would be nice to see available methods without opening python source files.


Thanks mini_xx for posting a picture. Glad i'm not the only one.

Do you know anything about closing object references in TS? Essentially my number 2?

0 Kudos
Message 7 of 10
(4,710 Views)

I found this on the last page..... Go to %teststandpublic%\Components\StepTypes\NIPython and open the PDF called "NIPythonStepType.pdf" and read the literal last line:

That answers my #1

Known Issues
• When using Python 3.6+ class instance methods present in a Python class are listed as
class static methods in the step settings dialog.

 

But thank you everyone else for confirming it does not work.

0 Kudos
Message 8 of 10
(4,698 Views)

@TTEng wrote:

I found this on the last page..... Go to %teststandpublic%\Components\StepTypes\NIPython and open the PDF called "NIPythonStepType.pdf" and read the literal last line:

That answers my #1

Known Issues
• When using Python 3.6+ class instance methods present in a Python class are listed as
class static methods in the step settings dialog.

 

But thank you everyone else for confirming it does not work.


Thanks for the reference. Glad to hear it is known issue.

0 Kudos
Message 9 of 10
(4,682 Views)

@TTEng wrote:

@mini_xx wrote:

Hi,

I have same issue and does happen with example sequence provided by installation: Passing Data to Python.seq

 

However function(s) does work if you know what to call. But would be nice to see available methods without opening python source files.


Thanks mini_xx for posting a picture. Glad i'm not the only one.

Do you know anything about closing object references in TS? Essentially my number 2?


Does the same document on page 4 also say that you should do "unload all modules" if sources are modified:

Note If you update the code module, you must unload all previous code modules in
order for the new code to be considered when it is loaded for execution.

 

 

 

0 Kudos
Message 10 of 10
(4,680 Views)