Hi everyone,
I have a question about project inheritance and how to properly separate projects.
In our case, the team originally developed a project called CRVG. Later, using the same gateway, they created another project called CRFLA1981. The CRFLA project inherits a lot of resources from CRVG, and many of those have been overridden.
Right now, the CRFLA project still contains references to CRVG, and a lot of resources are inherited and overridden rather than fully independent.
What I’m trying to do is:
Is there a way to export the CRFLA project so that it only includes the resources that are actually being used and/or overridden, and turn it into a completely independent project (with no inheritance or dependency on CRVG)?
Basically, I want a clean standalone version of CRFLA without any links back to the parent project.
Has anyone done something like this before, or is there a recommended approach for achieving this?
I'm on ignition8.3
Thanks in advance!
This is the kicker:
There's nothing that will reliably determine that. But:
Override everything in the leaf project that you know you need. Then set the project to not have a parent and try to run it. If it works (thoroughly tested), then you got it all.
Only lightly tested. Must be run on the gateway. Use at your own risk. 8.3+.
from com.inductiveautomation.ignition.gateway import IgnitionGateway
from com.inductiveautomation.ignition.common.resourcecollection import ResourceId
def flattenAndCreate(inputProject, outputProject):
projectManager = IgnitionGateway.get().getProjectManager()
optional = projectManager.find(inputProject)
if not optional.isPresent():
raise ValueError("Resource collection not found: " + inputProject)
p = optional.get().validateOrThrow()
remappedResources = {}
for r in p.resources:
replacementId = ResourceId(outputProject, r.resourceId.resourcePath)
replacement = r.toBuilder().setResourceId(replacementId).build()
remappedResources[replacementId] = replacement
manifest = p.manifest.toBuilder().setParent(None).build()
# Persist the new resource collection to disk
projectManager.create(outputProject, manifest, remappedResources.values())