@@ -40,7 +40,6 @@ def renameWritingToFinalPath(writingFilepath: str, filepath: str) -> str:
4040 pass
4141 os .rename (writingFilepath , filepath )
4242
43-
4443class Status (Enum ):
4544 """
4645 """
@@ -75,24 +74,20 @@ def __init__(self, nodeName='', nodeType='', packageName='', packageVersion='',
7574 self .nodeType : str = nodeType
7675 self .packageName : str = packageName
7776 self .packageVersion : str = packageVersion
78- self .mrNodeType : MrNodeType = mrNodeType
79- self .chunks : NodeChunkSetup = None
77+ self .mrNodeType : str = mrNodeType
78+ self .reset ()
79+
80+ def reset (self ):
81+ self .resetChunkInfos ()
8082 self .resetDynamicValues ()
8183
84+ def resetChunkInfos (self ):
85+ self .chunks : NodeChunkSetup = None
86+
8287 def resetDynamicValues (self ):
83- self .statusInheritedFromChunks : bool = False
8488 self .status : Status = Status .NONE
8589 self .execMode : ExecMode = ExecMode .NONE
8690 self .jobInfos : dict = {}
87- # TODO : move all possible infos from ChunkStatusData to this place
88-
89- def reset (self ):
90- self .nodeName : str = ""
91- self .nodeType : str = ""
92- self .packageName : str = ""
93- self .packageVersion : str = ""
94- self .mrNodeType : str = MrNodeType .NONE
95- self .resetDynamicValues ()
9691
9792 def setNode (self , node ):
9893 """ Set the node information from one node instance. """
@@ -113,6 +108,13 @@ def initExternSubmit(self):
113108 self .resetDynamicValues ()
114109 self .status = Status .SUBMITTED
115110 self .execMode = ExecMode .EXTERN
111+
112+ def setJob (self , jid , submitterName ):
113+ """ Set Job infos on the node so that """
114+ self .jobInfos = {
115+ "jid" : str (jid ),
116+ "submitterName" : str (submitterName ),
117+ }
116118
117119 def initLocalSubmit (self ):
118120 """
@@ -127,15 +129,8 @@ def initEndCompute(self):
127129 pass # TODO
128130
129131 def setComputationStatusToInheritChunks (self ):
130- self .statusInheritedFromChunks = True
131132 self .status : Status = Status .NONE
132133
133- def setJob (self , jid , submitterName ):
134- self .jobInfos = {
135- "jid" : str (jid ),
136- "submitterName" : str (submitterName ),
137- }
138-
139134 def setNodeType (self , node ):
140135 """
141136 Set the node type and package information from the given node.
@@ -149,38 +144,39 @@ def setNodeType(self, node):
149144 def toDict (self ):
150145 keys = list (self .__slots__ ) or []
151146 d = {key :getattr (self , key ) for key in keys }
152- chunks = [ - 1 , - 1 , - 1 ]
147+ chunks = None
153148 if self .chunks :
154149 chunks = list (self .chunks )
155150 d ["chunks" ] = chunks
156151 return d
157152
158- def fromDict (self , d ):
153+ def updateFromDict (self , d ):
159154 self .reset ()
160155 self .mrNodeType = d .pop ("mrNodeType" , MrNodeType .NONE )
161156 if not isinstance (self .mrNodeType , MrNodeType ):
162157 self .mrNodeType = MrNodeType [self .mrNodeType ]
163- self .chunks = NodeChunkSetup (* d .pop ("chunks" , [- 1 , - 1 , - 1 ]))
158+ if "chunks" in d :
159+ chunks = d .pop ("chunks" )
160+ if chunks :
161+ self .chunks = NodeChunkSetup (* chunks )
164162 if "status" in d :
165163 statusName = d .pop ("status" )
166164 self .status : Status = Status [statusName ]
167165 if "execMode" in d :
168166 execModeName = d .pop ("execMode" )
169- self .execMode = Status [execModeName ]
167+ self .execMode = ExecMode [execModeName ]
170168 for _key , _value in d .items ():
171169 if _key in self .__slots__ :
172170 setattr (self , _key , _value )
173171
174172 def loadFromCache (self , statusFile ):
175- print (f"[NodeStatusData](loadFromCache) { statusFile } " )
176173 self .reset ()
177174 try :
178175 with open (statusFile ) as jsonFile :
179176 statusData = json .load (jsonFile )
180- print (f"statusData :\n { statusData } " )
181- self .fromDict (statusData )
177+ self .updateFromDict (statusData )
182178 except Exception as e :
183- logging .warning (f"[NodeStatusData] (loadFromCache) { self .nodeName } : Error while loading status file { statusFile } : { e } " )
179+ logging .warning (f"(loadFromCache) { self .nodeName } : Error while loading status file { statusFile } : { e } " )
184180 self .reset ()
185181
186182 @property
@@ -534,7 +530,6 @@ def updateStatusFromCache(self):
534530 """
535531 Update chunk status based on status file content/existence.
536532 """
537- print (f"updateStatusFromCache { self } " )
538533 # TODO : If this is a placeholder chunk
539534 # Then we shouldn't do anything here
540535
@@ -651,7 +646,6 @@ def isFinished(self):
651646 return self ._status .status == Status .SUCCESS
652647
653648 def process (self , forceCompute = False , inCurrentEnv = False ):
654- print (f"[NodeChunk] (process) { self } " )
655649 if not forceCompute and self ._status .status == Status .SUCCESS :
656650 logging .info (f"Node chunk already computed: { self .name } " )
657651 return
@@ -698,7 +692,6 @@ def process(self, forceCompute=False, inCurrentEnv=False):
698692 self .statThread .join ()
699693 self .statistics = stats .Statistics ()
700694 del runningProcesses [self .name ]
701- print (f"[NodeChunk] (process) -> done" )
702695
703696
704697 def _processInIsolatedEnvironment (self ):
@@ -1529,9 +1522,6 @@ def updateNodeStatusFromCache(self):
15291522 # TODO : integrate statusFileLastModTime ?
15301523 Returns True if a change on the chunk setup has been detected
15311524 """
1532- if self .label == "E" :
1533- chunksInfos = [f"<{ hex (id (c ._status ))} , { c ._status .status .name } >" for c in self ._chunks ]
1534- print (f"[BaseNode] (updateNodeStatusFromCache) E ({ self } ) ({ chunksInfos } )" )
15351525 chunksRangeHasChanged = False
15361526 if os .path .exists (self .nodeStatusFile ):
15371527 oldChunkSetup = self ._nodeStatus .chunks
@@ -1548,7 +1538,6 @@ def updateStatusFromCache(self):
15481538 """
15491539 Update node status based on status file content/existence.
15501540 """
1551- print (f"updateStatusFromCache { self } " )
15521541 # Update nodeStatus from cache
15531542 chunkChanged = self .updateNodeStatusFromCache ()
15541543 # Create chunks if we found info on them on the node cache
@@ -1580,13 +1569,11 @@ def saveNodeStatusFile(self):
15801569 renameWritingToFinalPath (statusFilepathWriting , statusFilepath )
15811570
15821571 def setJobId (self , jid , submitterName ):
1583- print ("[BaseNode] (setJobId)" , self .label , "->" , jid , f"({ submitterName } )" )
15841572 self ._nodeStatus .setJob (jid , submitterName )
15851573 self .saveNodeStatusFile ()
15861574
15871575 def initStatusOnSubmit (self , forceCompute = False ):
15881576 """ Prepare chunks status when the node is in a graph that was submitted """
1589- print (f"[BaseNode] (initStatusOnSubmit) { self .label } ({ self } )" )
15901577 if not self ._chunksCreated :
15911578 self ._nodeStatus .setNode (self ) # ???
15921579 self ._nodeStatus .initExternSubmit ()
@@ -1600,7 +1587,6 @@ def initStatusOnSubmit(self, forceCompute=False):
16001587 chunk .upgradeStatusFile ()
16011588
16021589 def beginSequence (self , forceCompute = False ):
1603- print (f"[BaseNode] (beginSequence) { self .label } ({ self } )" )
16041590 if not self ._chunksCreated :
16051591 self ._nodeStatus .setNode (self ) # ???
16061592 self ._nodeStatus .initLocalSubmit ()
@@ -1721,7 +1707,9 @@ def endSequence(self):
17211707
17221708 def stopComputation (self ):
17231709 """ Stop the computation of this node. """
1710+ print (f"[BaseNode] (stopComputation) { self } " )
17241711 for chunk in self ._chunks .values ():
1712+ print (f"[BaseNode] (stopComputation) stop chunk { chunk } " )
17251713 chunk .stopProcess ()
17261714
17271715 def getGlobalStatus (self ):
@@ -1807,7 +1795,6 @@ def getLocked(self):
18071795 return self ._locked
18081796
18091797 def setLocked (self , lock ):
1810- print (f"(setLocked) { self .label } ({ self } ) -> { lock } " )
18111798 if self ._locked == lock :
18121799 return
18131800 self ._locked = lock
@@ -1816,17 +1803,14 @@ def setLocked(self, lock):
18161803 @Slot ()
18171804 def updateDuplicatesStatusAndLocked (self ):
18181805 """ Update status of duplicate nodes without any latency and update locked. """
1819- print (f"[BaseNode] (updateDuplicatesStatusAndLocked) { self } " )
18201806 if self .isMainNode ():
18211807 for node in self ._duplicates :
18221808 node .updateStatusFromCache ()
18231809
18241810 self .updateLocked ()
18251811
18261812 def updateLocked (self ):
1827- print (f"(updateLocked) { self .label } ({ self } )" )
18281813 currentStatus = self .getGlobalStatus ()
1829- print (f" currentStatus: { currentStatus } " )
18301814
18311815 lockedStatus = (Status .RUNNING , Status .SUBMITTED )
18321816
@@ -1850,7 +1834,6 @@ def updateLocked(self):
18501834 if not self ._locked and currentStatus == Status .SUCCESS :
18511835 return
18521836
1853- print (f" a" )
18541837 if currentStatus == Status .SUCCESS :
18551838 # At this moment, the node is necessarily locked because of previous if statement
18561839 inputNodes = self .getInputNodes (recursive = True , dependenciesOnly = True )
@@ -1869,14 +1852,12 @@ def updateLocked(self):
18691852 node .setLocked (False )
18701853 return
18711854 elif currentStatus in lockedStatus and self .isMainNode ():
1872- print (f" b" )
18731855 self .setLocked (True )
18741856 inputNodes = self .getInputNodes (recursive = True , dependenciesOnly = True )
18751857 for node in inputNodes :
18761858 node .setLocked (True )
18771859 return
18781860
1879- print (f" c" )
18801861 self .setLocked (False )
18811862
18821863 def updateDuplicates (self , nodesPerUid ):
@@ -2178,15 +2159,13 @@ def _resetChunks(self):
21782159 """
21792160 if isinstance (self .nodeDesc , desc .InputNode ):
21802161 return
2181- print ("[Node] (_resetChunks)" , self .label )
21822162 # Disconnect signals
21832163 for chunk in self ._chunks :
2184- print (f"[Node] (_resetChunks) -> remove { chunk } " )
21852164 chunk .statusChanged .disconnect (self .globalStatusChanged )
21862165 # Empty list
21872166 self ._chunks .setObjectList ([])
21882167 # Clear cache
2189-
2168+ self . _nodeStatus . resetChunkInfos ()
21902169 # Recreate list with reset values (1 chunk or the static size)
21912170 if not self .isParallelized :
21922171 self ._chunksCreated = True
@@ -2198,8 +2177,6 @@ def _resetChunks(self):
21982177 self ._chunksCreated = False
21992178 self .setSize (0 )
22002179 # Create chunks when possible
2201- print (f"[Node] (_resetChunks) <{ self .label } |{ self ._uid [:5 ] + ('..' if len (self ._uid ) > 5 else '' )} > ({ self .size } )" , end = "" )
2202- print (f" parallel={ 1 if self .isParallelized else 0 } chunksCreated={ 1 if self ._chunksCreated else 0 } " , end = "" )
22032180 if self ._chunksCreated and self .isParallelized :
22042181 try :
22052182 ranges = self .nodeDesc .parallelization .getRanges (self )
@@ -2216,7 +2193,6 @@ def _resetChunks(self):
22162193 self ._chunks [0 ].statusChanged .connect (self .globalStatusChanged )
22172194 else :
22182195 self ._chunks .setObjectList ([])
2219- print (f" -> ranges={ [_c .range for _c in self ._chunks ]} " )
22202196 self .chunksCreatedChanged .emit ()
22212197 self .chunksChanged .emit ()
22222198 self .globalStatusChanged .emit ()
@@ -2251,14 +2227,14 @@ def __createChunks(self, ranges):
22512227
22522228 def _createChunksFromCache (self ):
22532229 """Create chunks when a node cache exists"""
2254- print ("[Node] (_createChunksFromCache)" , self .label , end = "" )
2230+ # print("[Node] (_createChunksFromCache)", self.label, end="")
22552231 try :
22562232 # Get size from cache
22572233 size = self ._nodeStatus .nbChunks
22582234 self .setSize (size )
22592235 ranges = self ._nodeStatus .getChunkRanges ()
22602236 self .__createChunks (ranges )
2261- print (" -> ranges =" , [_c .range for _c in self ._chunks ])
2237+ # print(" -> ranges =", [_c.range for _c in self._chunks])
22622238 except Exception as e :
22632239 logging .error (f"Failed to create chunks for { self .name } " )
22642240 self ._chunks .clear ()
0 commit comments