[core] split uids computation + cache override in updateInternals

* add _computeUids internal method + store computed uids in a dedicated dict
* cache override:
  * add optional cacheDir parameter on updateInternal method to override graph cache directory
  * _buildCmdVars always update member variable '_cmdVars' 
  * CameraInit: ensure node does not belong to a graph and use updateInternals with temp cache directory
This commit is contained in:
Yann Lanthony 2018-07-15 12:35:33 +02:00
parent 727950afef
commit 67ac4bf2ca
2 changed files with 34 additions and 30 deletions

View file

@ -110,15 +110,11 @@ class CameraInit(desc.CommandLineNode):
The updated views and intrinsics as two separate lists
"""
assert isinstance(node.nodeDesc, CameraInit)
origCmdVars = node._cmdVars.copy()
# Python3: with tempfile.TemporaryDirectory(prefix="Meshroom_CameraInit") as tmpCache
assert node.graph is None
tmpCache = tempfile.mkdtemp()
localCmdVars = {
'cache': tmpCache,
'nodeType': node.nodeType,
}
node._buildCmdVars(localCmdVars)
node._cmdVars = localCmdVars
node.updateInternals(tmpCache)
try:
os.makedirs(os.path.join(tmpCache, node.internalFolder))
self.createViewpointsFile(node, additionalViews)
@ -158,8 +154,6 @@ class CameraInit(desc.CommandLineNode):
except Exception:
raise
finally:
node._cmdVars = origCmdVars
node._buildCmdVars(localCmdVars)
shutil.rmtree(tmpCache)
def createViewpointsFile(self, node, additionalViews=()):