Skip to content

Commit

Permalink
Frame dropDepends now drops all depend types (#976)
Browse files Browse the repository at this point in the history
* Frame dropDepends now drops all depend types

MenuActions calling frame.dropDepends only drops FRAME_ON_FRAME
dependencies, DependDoJdbc query only checks "pk_frame_depend_er"
returns empty list if none found. This does not drop any other types
of dependencies. Users create complicated dependency types like
FRAME_ON_JOB, FRAME_ON_LAYER etc. that don't always have FRAME_ON_FRAME,
so this function would fail to drop the dependencies and caused the
frame to be "stuck" in Depend state because all depend types need to
be satisfied before the frame is allowed to run. Changed loop to
getWhatThisDependsOn() and drop them one by one, allowing the frame to
go in "Waiting" and ready to run.

(cherry picked from commit 9741efe5f21e524e5c0353115da644698a971488)

* Cuegui dropDepends unittest uses depends

The changes to dropDepends broke the MenuActions
unittest, because the fn now calls
`getWhatThisDependsOn`, which threw a `'Mock' object
is not iterable` error. Needed to add depend object
for it to pass.

* Change dropDepends unittests for github

Cuegui MenuActions_tests.py's test_dropDepends
unittest no longer applies since the fn no longer
calls the pycue's dropDepends with a target
parameter. This is a bug fix to dropDepends and
now the fn iterates over each dependency and calls
"depend.satisfy" instead to remove since the
pycue'sdropDepends only applys to "one" depend
target, so it will not remove different multiple
different dependency types linked to the one frame.
Hence, this caused the Cuegui unittest to fail on
the Github PR. Opting to put the dropDepends test
in pycue (which didn't have one) and remove the test
in Cuegui, since Cuegui already has a test coverage
for depend.satisfy.
  • Loading branch information
roulaoregan-spi committed Jun 20, 2024
1 parent cc265b4 commit dd67131
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
6 changes: 5 additions & 1 deletion cuegui/cuegui/MenuActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1117,8 +1117,12 @@ def dropDepends(self, rpcObjects=None):
"Drop dependencies on selected frames?\n"
"(Drops all of the frame's dependencies)",
names):
# Remove all dependency types
# - get what frame depends on and remove each one
for frame in frames:
frame.dropDepends(opencue.api.depend_pb2.ANY_TARGET)
dependencies = frame.getWhatThisDependsOn()
for d in dependencies:
d.satisfy()
self._update()

dependWizard_info = ["Dependency &Wizard...", None, "configure"]
Expand Down
11 changes: 0 additions & 11 deletions cuegui/tests/MenuActions_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,17 +971,6 @@ def test_markAsWaiting(self, yesNoMock):

self.job.markAsWaiting.assert_called_with(name=[frame_name])

@mock.patch('opencue.search.FrameSearch')
@mock.patch('cuegui.Utils.questionBoxYesNo', return_value=True)
def test_dropDepends(self, yesNoMock, frameSearchMock):
frame_name = 'arbitrary-frame-name'
frame = opencue.wrappers.frame.Frame(opencue.compiled_proto.job_pb2.Frame(name=frame_name))
frame.dropDepends = mock.Mock()

self.frame_actions.dropDepends(rpcObjects=[frame])

frame.dropDepends.assert_called_with(opencue.api.depend_pb2.ANY_TARGET)

@mock.patch('cuegui.DependWizard.DependWizard')
def test_dependWizard(self, dependWizardMock):
frames = [opencue.wrappers.frame.Frame()]
Expand Down
13 changes: 13 additions & 0 deletions pycue/tests/wrappers/frame_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,19 @@ def testMarkAsWaiting(self, getStubMock):
stubMock.MarkAsWaiting.assert_called_with(
job_pb2.FrameMarkAsWaitingRequest(frame=frame.data), timeout=mock.ANY)

def testDropDepends(self, getStubMock):
stubMock = mock.Mock()
stubMock.DropDepends.return_value = job_pb2.FrameDropDependsResponse()
getStubMock.return_value = stubMock

target = depend_pb2.ANY_TARGET
frame = opencue.wrappers.frame.Frame(job_pb2.Frame(name='arbitrary-frame-name'))
frame.dropDepends(target)

stubMock.DropDepends.assert_called_with(
job_pb2.FrameDropDependsRequest(frame=frame.data, target=target),
timeout=mock.ANY)

def testRunTimeZero(self, getStubMock):
zeroFrame = opencue.wrappers.frame.Frame(
job_pb2.Frame(name=TEST_FRAME_NAME, start_time=0, stop_time=1000))
Expand Down

0 comments on commit dd67131

Please sign in to comment.