[bug-15134]Ignition 8 SFC Scope to Project Scripts

Hello,

I’m struggling to get the scripting scope figured out, particularly as it relates to SFCs and scripts in a project. Currently I have a package I’ve put down in …\user-lib\pylib<my package> on the Ignition server, but would prefer to move the package to Project Library.

The issue I’m having is if I have an SFC in a project and add the script to the Project Library, I’m not able to make an import/reference work from the SFC to modules in the package.

For example if in the Project Library I have a package myPackage and maybe subpackage mySubPackage with various modules … nothing like myPackage.mySubPackage. works.

Thanks,

Rick

Paul Scott’s post Ignition 8 Tag Event Script helped me resolve the issue. While Paul didn’t address an SFC specifically a couple key phrases helped me understand … basically since an SFC is gateway scoped, getting access to the project script isn’t going to happen, except via “Gateway Scripting Project” project setting.

Thanks,

Rick

Hey, it looks like we missed this one.

Something doesn’t sound right about this.

SFCs belong to a project and should be able to access the project scripts available to that project. The Gateway Scripting Project is really only relevant for things like tags, which don’t belong to any project.

Hi Keven,

I created a simple SFC that opens a logger and calls testScript.doSomething() printing to the log the return value, here is the script:

def doSomething():
	return "This is something"

Regardless if I

import testScript
# Or
from . import testScript

# Or simply use full path
testScript.doSomething()

I also tried various other namespaces such as project…, or myProject… and other variations but the end result is along the lines of no module named testScript, no module named null, global name ‘testScript’ is not defined, etc.

Probably something simple, but I’m missing what it is.

Running version 8.02

Thanks,

Rick

Is the script in the same project as the SFC? Or if in a parent project, has the script’s module been overridden? Consider logging str(dir()) to see what local variables are present.

All in the same project, here is an image:

Ignition_Project

Any attempt in the SFC, which is nothing more then (Entry, Action, End) with the Action attempting to reference testScript (import testScript, or testScript.<some_method>) results in the SFC aborting instead of making a clean exit.

Thanks,

Rick

I thought this was resolved in 8.03, turns out the offending line of code was commented out. Appears SFC in a project still cannot access script in the same project with 8.03.

Interesting though, if I create a timer even in Gateway Events in the same project, no problem getting to the project script. The SFC appears not to “scope in” the project itself.

Thanks,

Rick

I tried calling a REST http call from within the SFC and could never get it to execute the function. One post said it was a bug in version 8.x and that I should place all scripts in the project library and call them, I tried this and I run into the same thing you show here. The SFC onStart script cannot see the Project Library scripts. I can’t seem to win here. Did you ever get a resolution?

Hi Joe,

No resolution last time I checked. I was on a support call with Inductive and the person I was working with made a quick project and saw the issue. He was going to submit the issue as he thought it should work as well. Of course there maybe some good reasons it doesn’t work or is difficult to make work, but I’ve not heard one way or the other as of yet.

Thanks,

Rick

Hi Joe,

I confirmed that 8.0.6 didn’t resolve the issue either.

-Rick

It’s a medium priority issue on our backlog, but hasn’t been assigned to any actual development team. I just gave the priority a kick, which should help a bit. We’ll update this thread when there’s progress.

Hi PGriffith,

Any updates on this topic?

Thanks,
Carlos

Nope, nothing yet.

Any estimate as to when this may occur? Would be nice to be able to version everything in one project instead of having to consider script scatted elsewhere, well, okay, one more place, but that is still elsewhere :slight_smile:

Thanks,

Rick

So I think the current version is well passed the point of needing a toggle to turn this off/on in a project without causing a breaking change.

Sure would be nice to have script in the same project as the SFC … that the SFC can reference. Currently we are forced to share global so checking into the repo means a build signal is triggered for something that doesn’t need to be. Had the script change been local to the project then only that project needs to be deployed. As of now code management a little more tedious but even more when it’s time to use pipeline/workflows they can’t be fully automated otherwise more change are deployed than required.

Any estimate as to when we might see this come to fruition?

Thanks,

Rick

I installed 8.1.4 and tested a project that has been in use through most all the 8.0.x versions up through 8.1.1. After the installation we noticed an SFC wasn’t working.

The SFC referenced script that was in the designated “global” project. No longer could the SFC see the script so I though for a test I would copy the script into the same project as the SFC … and to my surprise it worked!

I’m glad to see an SFC can now use script within the same project, but I’m surprised it could no longer use the script in the “global” project, any idea why that may be?

Thanks,

Rick

SFCs were mistakenly executing scripts using the context of whatever is designated as the "Gateway Scripting Project", which is the "global" project on an upgrade.

This was recently fixed so that it correctly uses the context of its project (and any parent projects it may have).

edit: fixed in 8.1.2 with this release note:

SFC Python scripts and expressions can now reference Project Scripts.

Perhaps it should have also mentioned that the previous context would no longer be available.

1 Like