Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cuegui] feat: Add job node graph plugin v2 #1400

Open
wants to merge 36 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7f57691
Switch to PySide6
lithorus Jun 15, 2024
66eee00
Update qtpy to 2.4.1
lithorus Jun 15, 2024
33dfa16
Update PySide2/PySide6 support matrix
lithorus Jun 15, 2024
0f8ee7e
Update code to use qtpy and fork of NodeGraphQt that supports PySide6
lithorus Jun 29, 2024
a558840
Fix pylint
lithorus Jun 29, 2024
cb22c46
Lock nodes names to be non-editable
lithorus Jun 29, 2024
9918fc5
Fix some small linting warnings
lithorus Jun 29, 2024
22634ff
Import fork of NodeGraphQt and remove reference to external repo
lithorus Jun 29, 2024
a258bc0
Fix python linting
lithorus Jun 29, 2024
effb801
Make QUndoStack compatible with both PySide2 and PySide6
lithorus Jun 29, 2024
6fbf2d1
Add simple test for JobGraphPlugin
lithorus Jun 30, 2024
d68c930
Switch to use packaging instead of distutils
lithorus Jun 30, 2024
a1ead15
Don't update graph if job has not been selected yet
lithorus Jun 30, 2024
7f81326
Fix for having a single plugin in a window (.ini files are bad for sa…
lithorus Jun 30, 2024
ea1b9f8
Interpret the value of "Open" correctly in the ini file for Window state
lithorus Jun 30, 2024
8f766ee
Merge branch 'AcademySoftwareFoundation:master' into nodegraph
lithorus Jul 16, 2024
de3bed3
Merge branch 'AcademySoftwareFoundation:master' into nodegraph
lithorus Jul 17, 2024
acde3f9
Merge remote-tracking branch 'origin/master' into nodegraph
lithorus Jul 23, 2024
8fd8db9
Merge branch 'AcademySoftwareFoundation:master' into nodegraph
lithorus Jul 30, 2024
e172f01
Merge remote-tracking branch 'origin/master' into nodegraph
lithorus Aug 2, 2024
d011718
Merge branch 'AcademySoftwareFoundation:master' into nodegraph
lithorus Aug 14, 2024
4bb0d0f
Merge remote-tracking branch 'origin/master' into nodegraph
lithorus Aug 20, 2024
b40fdcd
Merge branch 'AcademySoftwareFoundation:master' into nodegraph
lithorus Sep 6, 2024
7dfe035
Merge branch 'AcademySoftwareFoundation:master' into nodegraph
lithorus Sep 11, 2024
d6d0209
Remove local copy of NodeGraphQqt and add as submodule
lithorus Sep 11, 2024
2922a20
Small change to maintain support for PySide2
lithorus Sep 11, 2024
7c6c159
Small change to maintain support for PySide2
lithorus Sep 11, 2024
d7f190e
Test with changes to CI/CD
lithorus Sep 11, 2024
a67eac0
Small yaml structure fix
lithorus Sep 11, 2024
548790a
Test with checkout v4
lithorus Sep 11, 2024
36aee1d
Remove PySide6 test and downgrade checkout in vfx 2022 tests
lithorus Sep 11, 2024
9f7acab
Update lint python tests to vfx 2023
lithorus Sep 11, 2024
3611402
Delete pyside6 test script
lithorus Sep 11, 2024
2a4b0d3
Remove external repo and add pypi package instead
lithorus Dec 3, 2024
df8c823
Merge remote-tracking branch 'origin/master' into nodegraph
lithorus Dec 3, 2024
887333b
Fix linting
lithorus Dec 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 10 additions & 13 deletions .github/workflows/testing-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ jobs:
runs-on: ubuntu-latest
container: aswf/ci-opencue:2023
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run Python Tests
run: ci/run_python_tests.sh

Expand All @@ -58,7 +60,9 @@ jobs:
runs-on: ubuntu-latest
container: aswf/ci-opencue:2024
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Run Python Tests
run: ci/run_python_tests.sh

Expand All @@ -74,23 +78,16 @@ jobs:
chown -R aswfuser:aswfgroup .
su -c "cd cuebot && ./gradlew build --stacktrace --info" aswfuser

test_pyside6:
name: Run CueGUI Tests using PySide6
runs-on: ubuntu-latest
container: almalinux:9
steps:
- uses: actions/checkout@v3
- name: Run CueGUI Tests
run: ci/test_pyside6.sh

lint_python:
name: Lint Python Code
runs-on: ubuntu-latest
container: aswf/ci-opencue:2022
container: aswf/ci-opencue:2023
env:
ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION: true
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
submodules: true
- name: Lint Python Code
run: ci/run_python_lint.sh

Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "external/NodeGraphQt"]
path = external/NodeGraphQt
url = https://github.com/lithorus/NodeGraphQt.git
branch = pyside2+6
36 changes: 0 additions & 36 deletions ci/test_pyside6.sh

This file was deleted.

1 change: 1 addition & 0 deletions cuegui/NodeGraphQt
126 changes: 126 additions & 0 deletions cuegui/cuegui/AbstractGraphWidget.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
# Copyright Contributors to the OpenCue Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Base class for CueGUI graph widgets."""

from qtpy import QtCore
from qtpy import QtWidgets

from NodeGraphQt import NodeGraph
from NodeGraphQt.errors import NodeRegistrationError
from cuegui.nodegraph import CueLayerNode
from cuegui import app


class AbstractGraphWidget(QtWidgets.QWidget):
"""Base class for CueGUI graph widgets"""

def __init__(self, parent=None):
super(AbstractGraphWidget, self).__init__(parent=parent)
self.graph = NodeGraph()
self.setupUI()

self.timer = QtCore.QTimer(self)
# pylint: disable=no-member
self.timer.timeout.connect(self.update)
self.timer.setInterval(1000 * 20)

self.graph.node_selection_changed.connect(self.onNodeSelectionChanged)
app().quit.connect(self.timer.stop)

def setupUI(self):
"""Setup the UI."""
try:
self.graph.register_node(CueLayerNode)
except NodeRegistrationError:
pass
self.graph.viewer().installEventFilter(self)

layout = QtWidgets.QVBoxLayout(self)
layout.addWidget(self.graph.viewer())

def onNodeSelectionChanged(self):
"""Slot run when a node is selected.

Updates the nodes to ensure they're visualising current data.
Can be used to notify other widgets of object selection.
"""
self.update()

def handleSelectObjects(self, rpcObjects):
"""Select incoming objects in graph.
"""
received = [o.name() for o in rpcObjects]
current = [rpcObject.name() for rpcObject in self.selectedObjects()]
if received == current:
# prevent recursing
return

for node in self.graph.all_nodes():
node.set_selected(False)
for rpcObject in rpcObjects:
node = self.graph.get_node_by_name(rpcObject.name())
node.set_selected(True)

def selectedObjects(self):
"""Return the selected nodes rpcObjects in the graph.
:rtype: [opencue.wrappers.layer.Layer]
:return: List of selected layers
"""
rpcObjects = [n.rpcObject for n in self.graph.selected_nodes()]
return rpcObjects

def eventFilter(self, target, event):
"""Override eventFilter

Centre nodes in graph viewer on 'F' key press.

@param target: widget event occurred on
@type target: QtWidgets.QWidget
@param event: Qt event
@type event: QtCore.QEvent
"""
if hasattr(self, "graph"):
viewer = self.graph.viewer()
if target == viewer:
if event.type() == QtCore.QEvent.KeyPress:
if event.key() == QtCore.Qt.Key_F:
self.graph.center_on()
if event.key() == QtCore.Qt.Key_L:
self.graph.auto_layout_nodes()

return super(AbstractGraphWidget, self).eventFilter(target, event)

def clearGraph(self):
"""Clear all nodes from the graph
"""
for node in self.graph.all_nodes():
for port in node.output_ports():
port.unlock()
for port in node.input_ports():
port.unlock()
self.graph.clear_session()

def createGraph(self):
"""Create the graph to visualise OpenCue objects
"""
raise NotImplementedError()

def update(self):
"""Update nodes with latest data

This is run every 20 seconds by the timer.
"""
raise NotImplementedError()
1 change: 1 addition & 0 deletions cuegui/cuegui/App.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class CueGuiApplication(QtWidgets.QApplication):
request_update = QtCore.Signal()
status = QtCore.Signal()
quit = QtCore.Signal()
select_layers = QtCore.Signal(list)

# Thread pool
threadpool = None
Expand Down
153 changes: 153 additions & 0 deletions cuegui/cuegui/JobMonitorGraph.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Copyright Contributors to the OpenCue Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


"""Node graph to display Layers of a Job"""


from qtpy import QtWidgets

import cuegui.Utils
import cuegui.MenuActions
from cuegui.nodegraph import CueLayerNode
from cuegui.AbstractGraphWidget import AbstractGraphWidget


class JobMonitorGraph(AbstractGraphWidget):
"""Graph widget to display connections of layers in a job"""

def __init__(self, parent=None):
super(JobMonitorGraph, self).__init__(parent=parent)
self.job = None
self.setupContextMenu()

# wire signals
cuegui.app().select_layers.connect(self.handleSelectObjects)

def onNodeSelectionChanged(self):
"""Notify other widgets of Layer selection.

Emit signal to notify other widgets of Layer selection, this keeps
all widgets with selectable Layers in sync with each other.

Also force updates the nodes, as the timed updates are infrequent.
"""
self.update()
layers = self.selectedObjects()
cuegui.app().select_layers.emit(layers)

def setupContextMenu(self):
"""Setup context menu for nodes in node graph"""
self.__menuActions = cuegui.MenuActions.MenuActions(
self, self.update, self.selectedObjects, self.getJob
)

menu = self.graph.context_menu().qmenu

dependMenu = QtWidgets.QMenu("&Dependencies", self)
self.__menuActions.layers().addAction(dependMenu, "viewDepends")
self.__menuActions.layers().addAction(dependMenu, "dependWizard")
dependMenu.addSeparator()
self.__menuActions.layers().addAction(dependMenu, "markdone")
menu.addMenu(dependMenu)
menu.addSeparator()
self.__menuActions.layers().addAction(menu, "useLocalCores")
self.__menuActions.layers().addAction(menu, "reorder")
self.__menuActions.layers().addAction(menu, "stagger")
menu.addSeparator()
self.__menuActions.layers().addAction(menu, "setProperties")
menu.addSeparator()
self.__menuActions.layers().addAction(menu, "kill")
self.__menuActions.layers().addAction(menu, "eat")
self.__menuActions.layers().addAction(menu, "retry")
menu.addSeparator()
self.__menuActions.layers().addAction(menu, "retryDead")

def setJob(self, job):
"""Set Job to be displayed
@param job: Job to display as node graph
@type job: opencue.wrappers.job.Job
"""
self.timer.stop()
self.clearGraph()

if job is None:
self.job = None
return

job = cuegui.Utils.findJob(job)
self.job = job
self.createGraph()
self.timer.start()

def getJob(self):
"""Return the currently set job
:rtype: opencue.wrappers.job.Job
:return: Currently set job
"""
return self.job

def selectedObjects(self):
"""Return the selected Layer rpcObjects in the graph.
:rtype: [opencue.wrappers.layer.Layer]
:return: List of selected layers
"""
layers = [n.rpcObject for n in self.graph.selected_nodes() if isinstance(n, CueLayerNode)]
return layers

def createGraph(self):
"""Create the graph to visualise the grid job submission
"""
if not self.job:
return

layers = self.job.getLayers()

# add job layers to tree
for layer in layers:
node = CueLayerNode(layer)
self.graph.add_node(node)
node.set_name(layer.name())

# setup connections
self.setupNodeConnections()

self.graph.auto_layout_nodes()
self.graph.center_on()

def setupNodeConnections(self):
"""Setup connections between nodes based on their dependencies"""
for node in self.graph.all_nodes():
for depend in node.rpcObject.getWhatDependsOnThis():
child_node = self.graph.get_node_by_name(depend.dependErLayer())
if child_node:
# todo check if connection exists
child_node.set_input(0, node.output(0))

for node in self.graph.all_nodes():
for port in node.output_ports():
port.lock()
for port in node.input_ports():
port.lock()

def update(self):
"""Update nodes with latest Layer data

This is run every 20 seconds by the timer.
"""
if self.job is not None:
layers = self.job.getLayers()
for layer in layers:
node = self.graph.get_node_by_name(layer.name())
node.setRpcObject(layer)
Loading
Loading