mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 02:08:08 +02:00
Add some python typing
This commit is contained in:
parent
830372b326
commit
8e5f8a55d1
4 changed files with 19 additions and 18 deletions
|
@ -818,11 +818,11 @@ class Graph(BaseObject):
|
|||
nodes = [n for n in self._nodes.values() if isinstance(n.nodeDesc, meshroom.core.desc.InitNode)]
|
||||
return nodes
|
||||
|
||||
def findNodeCandidates(self, nodeNameExpr):
|
||||
def findNodeCandidates(self, nodeNameExpr: str) -> list[Node]:
|
||||
pattern = re.compile(nodeNameExpr)
|
||||
return [v for k, v in self._nodes.objects.items() if pattern.match(k)]
|
||||
|
||||
def findNode(self, nodeExpr):
|
||||
def findNode(self, nodeExpr: str) -> Node:
|
||||
candidates = self.findNodeCandidates('^' + nodeExpr)
|
||||
if not candidates:
|
||||
raise KeyError('No node candidate for "{}"'.format(nodeExpr))
|
||||
|
|
|
@ -13,7 +13,7 @@ import time
|
|||
import types
|
||||
import uuid
|
||||
from collections import namedtuple
|
||||
from enum import Enum
|
||||
from enum import Enum, auto
|
||||
from typing import Callable, Optional
|
||||
|
||||
import meshroom
|
||||
|
@ -55,9 +55,9 @@ class Status(Enum):
|
|||
|
||||
|
||||
class ExecMode(Enum):
|
||||
NONE = 0
|
||||
LOCAL = 1
|
||||
EXTERN = 2
|
||||
NONE = auto()
|
||||
LOCAL = auto()
|
||||
EXTERN = auto()
|
||||
|
||||
|
||||
class StatusData(BaseObject):
|
||||
|
@ -65,7 +65,7 @@ class StatusData(BaseObject):
|
|||
"""
|
||||
dateTimeFormatting = '%Y-%m-%d %H:%M:%S.%f'
|
||||
|
||||
def __init__(self, nodeName='', nodeType='', packageName='', packageVersion='', parent=None):
|
||||
def __init__(self, nodeName='', nodeType='', packageName='', packageVersion='', parent: BaseObject = None):
|
||||
super(StatusData, self).__init__(parent)
|
||||
self.status = Status.NONE
|
||||
self.execMode = ExecMode.NONE
|
||||
|
@ -1221,7 +1221,7 @@ class BaseNode(BaseObject):
|
|||
def globalExecMode(self):
|
||||
return self._chunks.at(0).execModeName
|
||||
|
||||
def getChunks(self):
|
||||
def getChunks(self) -> list[NodeChunk]:
|
||||
return self._chunks
|
||||
|
||||
def getSize(self):
|
||||
|
|
|
@ -4,7 +4,8 @@ from enum import Enum
|
|||
|
||||
import meshroom
|
||||
from meshroom.common import BaseObject, DictModel, Property, Signal, Slot
|
||||
from meshroom.core.node import Status
|
||||
from meshroom.core.node import Status, Node
|
||||
from meshroom.core.graph import Graph
|
||||
import meshroom.core.graph
|
||||
|
||||
|
||||
|
@ -96,7 +97,7 @@ class TaskManager(BaseObject):
|
|||
"""
|
||||
Manage graph - local and external - computation tasks.
|
||||
"""
|
||||
def __init__(self, parent=None):
|
||||
def __init__(self, parent: BaseObject = None):
|
||||
super(TaskManager, self).__init__(parent)
|
||||
self._graph = None
|
||||
self._nodes = DictModel(keyAttrName='_name', parent=self)
|
||||
|
@ -163,7 +164,7 @@ class TaskManager(BaseObject):
|
|||
self._thread = TaskThread(self)
|
||||
self._thread.start()
|
||||
|
||||
def compute(self, graph=None, toNodes=None, forceCompute=False, forceStatus=False):
|
||||
def compute(self, graph: Graph = None, toNodes: list[Node] = None, forceCompute: bool = False, forceStatus: bool = False):
|
||||
"""
|
||||
Start graph computation, from root nodes to leaves - or nodes in 'toNodes' if specified.
|
||||
Computation tasks (NodeChunk) happen in a separate thread (see TaskThread).
|
||||
|
|
|
@ -359,20 +359,20 @@ class UIGraph(QObject):
|
|||
UIGraph exposes undoable methods on its graph and computation in a separate thread.
|
||||
It also provides a monitoring of all its computation units (NodeChunks).
|
||||
"""
|
||||
def __init__(self, undoStack, taskManager, parent=None):
|
||||
def __init__(self, undoStack: commands.UndoStack, taskManager: TaskManager, parent: QObject = None):
|
||||
super(UIGraph, self).__init__(parent)
|
||||
self._undoStack = undoStack
|
||||
self._taskManager = taskManager
|
||||
self._graph = Graph('', self)
|
||||
self._graph: Graph = Graph('', self)
|
||||
|
||||
self._modificationCount = 0
|
||||
self._chunksMonitor = ChunksMonitor(parent=self)
|
||||
self._computeThread = Thread()
|
||||
self._chunksMonitor: ChunksMonitor = ChunksMonitor(parent=self)
|
||||
self._computeThread: Thread = Thread()
|
||||
self._computingLocally = self._submitted = False
|
||||
self._sortedDFSChunks = QObjectListModel(parent=self)
|
||||
self._layout = GraphLayout(self)
|
||||
self._sortedDFSChunks: QObjectListModel = QObjectListModel(parent=self)
|
||||
self._layout: GraphLayout = GraphLayout(self)
|
||||
self._selectedNode = None
|
||||
self._nodeSelection = QItemSelectionModel(self._graph.nodes, parent=self)
|
||||
self._nodeSelection: QItemSelectionModel = QItemSelectionModel(self._graph.nodes, parent=self)
|
||||
self._hoveredNode = None
|
||||
|
||||
self.submitLabel = "{projectName}"
|
||||
|
|
Loading…
Add table
Reference in a new issue