Skip to content

Commit

Permalink
Merge branch 'master' into framespec_token_104
Browse files Browse the repository at this point in the history
  • Loading branch information
Donal McMullan committed Jul 3, 2019
2 parents 1061fcd + 388399d commit 75b8071
Show file tree
Hide file tree
Showing 10 changed files with 435 additions and 5 deletions.
1 change: 0 additions & 1 deletion cuebot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,3 @@ NOTE: Only OpenCue developers will need to do this setup. If you just want to us

View > Tool Windows > Gradle. Refresh the Gradle project and run the build task, which will
run compilation and tests.

2 changes: 1 addition & 1 deletion cuesubmit/cuesubmit/ui/Submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def jobDataChanged(self):
layerType=self.jobTypeSelector.text(),
cmd=self.settingsWidget.getCommandData(),
layerRange=self.frameBox.frameSpecInput.text(),
chunk=None,
chunk=self.chunkInput.text(),
cores=self.coresInput.text(),
env=None,
services=[i.strip() for i in self.servicesSelector.text().split(',')],
Expand Down
5 changes: 3 additions & 2 deletions pycue/opencue/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from .wrappers.host import Host, NestedHost
from .wrappers.job import Job
from .wrappers.layer import Layer
from .wrappers.owner import Owner
from .wrappers.proc import Proc
from .wrappers.service import Service
from .wrappers.show import Show
Expand Down Expand Up @@ -500,8 +501,8 @@ def getHost(uniq):
@util.grpcExceptionParser
def getOwner(id):
"""Return an Owner object from the id or name."""
return Cuebot.getStub('owner').GetOwner(
host_pb2.OwnerGetOwnerRequest(name=id), timeout=Cuebot.Timeout).owner
return Owner(Cuebot.getStub('owner').GetOwner(
host_pb2.OwnerGetOwnerRequest(name=id), timeout=Cuebot.Timeout).owner)

#
# Filters
Expand Down
93 changes: 93 additions & 0 deletions pycue/opencue/wrappers/deed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright (c) 2018 Sony Pictures Imageworks Inc.
#
# 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.



"""
Project: opencue
Module: deed.py - deed object
"""

import opencue.wrappers.host
from opencue.compiled_proto import host_pb2
from opencue.cuebot import Cuebot


class Deed(object):

def __init__(self, comment=None):
self.data = comment
self.stub = Cuebot.getStub('comment')

def delete(self):
"""Delete this comment"""
self.stub.Delete(host_pb2.DeedDeleteRequest(deed=self.data), timeout=Cuebot.Timeout)

def getHost(self):
"""Return the host for this deed
@rtype: Host Wrapper
@return: Host associated with this deed"""
return opencue.wrappers.host.Host(
self.stub.GetHost(host_pb2.DeedGetHostRequest(deed=self.data),
timeout=Cuebot.Timeout).host)

def getOwner(self):
"""Returns the owner for these settings."""
return opencue.wrappers.owner.Owner(
self.stub.GetOwner(host_pb2.DeedGetOwnerRequest(deed=self.data),
timeout=Cuebot.Timeout).owner)

def setBlackoutTime(self, startTime, stopTime):
"""Sets a blackout time for the host.
@type startTime: int
@param startTime: blackout start time
@type stopTime: int
@param stopTime: blackout stop time"""
self.stub.SetBlackoutTime(
host_pb2.DeedSetBlackoutTimeRequest(deed=self.data,
start_time=startTime,
stop_time=stopTime),
timeout=Cuebot.Timeout)

def setBlackoutTimeEnabled(self, enabled):
"""Enable/Disable blackout time without changing the times.
@type enabled: bool
@param enabled: enable/disable blackout time"""
self.stub.SetBlackoutTimeEnabled(
host_pb2.DeedSetBlackoutTimeEnabledRequest(deed=self.data,
enabled=enabled),
timeout=Cuebot.Timeout)

def id(self):
return self.data.id

def host(self):
return self.data.host

def owner(self):
return self.data.owner

def show(self):
return self.data.show

def blackout(self):
return self.data.blackout

def blackoutStartTime(self):
return self.data.blackout_start_time

def blackoutStopTime(self):
return self.data.blackout_stop_time
9 changes: 9 additions & 0 deletions pycue/opencue/wrappers/layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,15 @@ def createFrameByFrameDependency(self, layer):
# @param kill: wheather or not to kill the frames as well"""
# self.proxy.unbookProcs([a.proxy for a in subs], number, kill)

def registerOutputPath(self, outputPath):
"""Register an output with the given layer. The output paths are sent in the opencue email.
@type outputPath: str
@param outputPath: Output path to register
"""
self.stub.RegisterOutputPath(
job_pb2.LayerRegisterOutputPathRequest(layer=self.data, spec=outputPath),
timeout=Cuebot.Timeout)

def reorderFrames(self, range, order):
"""Reorders the specified frame range on this layer.
@type range: string
Expand Down
86 changes: 86 additions & 0 deletions pycue/opencue/wrappers/owner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# Copyright (c) 2018 Sony Pictures Imageworks Inc.
#
# 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.


"""
Project: opencue Library
Module: owner.py - opencue Library implementation of a owner
"""

import opencue.wrappers.deed
import opencue.wrappers.host
from opencue import Cuebot
from opencue.compiled_proto import host_pb2


class Owner(object):
def __init__(self, owner=None):
"""Host class initialization"""
self.data = owner
self.stub = Cuebot.getStub('owner')

def delete(self):
"""Delete the owner record"""
self.stub.Delete(host_pb2.OwnerDeleteRequest(owner=self.data), timeout=Cuebot.Timeout)

def getDeeds(self):
"""Return the list of deeds for the owner
@rtype: List<Deed Wrapper>
@return: The list of deeds associated with this owner."""
response = self.stub.GetDeeds(host_pb2.OwnerGetDeedsRequest(owner=self.data),
timeout=Cuebot.Timeout)
return [opencue.wrappers.deed.Deed(deed) for deed in response.deeds.deeds]

def getHosts(self):
"""Get a list of all hosts this owner is responsible for.
@rtype: List<Host Wrapper>
@return: List of hosts the owned by this owner."""
response = self.stub.GetHosts(host_pb2.OwnerGetHostsRequest(owner=self.data),
timeout=Cuebot.Timeout)
return [opencue.wrappers.host.Host(host) for host in response.hosts.hosts]

def getOwner(self, name):
"""Return an owner by name.
@type: str
@param: Name of the owner
@rtype: Owner
@return: Owner that matches the specified name"""
return Owner(self.stub.GetOwner(host_pb2.OwnerGetOwnerRequest(name=name),
timeout=Cuebot.Timeout).owner)

def setShow(self, show):
"""Set the show for the owner.
@type: str
@param: name of the show"""
self.stub.SetShow(host_pb2.OwnerSetShowRequest(owner=self.data, show=show),
timeout=Cuebot.Timeout)

def takeOwnership(self, host):
"""Set the hosts new owner settings."""
self.stub.TakeOwnership(host_pb2.OwnerTakeOwnershipRequest(owner=self.data, host=host),
timeout=Cuebot.Timeout)

def hostCount(self):
return self.data.host_count

def id(self):
return self.data.id

def name(self):
return self.data.name

def show(self):
return self.data.show
2 changes: 1 addition & 1 deletion pycue/tests/api_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,7 @@ def testGetOwner(self, getStubMock):

stubMock.GetOwner.assert_called_with(
host_pb2.OwnerGetOwnerRequest(name=ownerName), timeout=mock.ANY)
self.assertEqual(ownerName, owner.name)
self.assertEqual(ownerName, owner.name())


class FilterTests(unittest.TestCase):
Expand Down
105 changes: 105 additions & 0 deletions pycue/tests/wrappers/deed_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#!/usr/bin/env python

# Copyright (c) 2018 Sony Pictures Imageworks Inc.
#
# 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.


from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
import mock
import unittest

import opencue
from opencue.compiled_proto import host_pb2


TEST_DEED_ID = 'ddd-dd-dddd'
TEST_DEED_OWNER = 'testDeedOwner'
TEST_HOST_ID = 'hhh-hh-hhhh'


@mock.patch('opencue.cuebot.Cuebot.getStub')
class DeedTests(unittest.TestCase):

def testDelete(self, getStubMock):
stubMock = mock.Mock()
stubMock.Delete.return_value = host_pb2.DeedDeleteResponse()
getStubMock.return_value = stubMock

deed = opencue.wrappers.deed.Deed(host_pb2.Deed(id=TEST_DEED_ID))
deed.delete()

stubMock.Delete.assert_called_with(
host_pb2.DeedDeleteRequest(deed=deed.data), timeout=mock.ANY)

def testGetHost(self, getStubMock):
stubMock = mock.Mock()
stubMock.GetHost.return_value = host_pb2.DeedGetHostResponse(
host=host_pb2.Host(id=TEST_HOST_ID))
getStubMock.return_value = stubMock

deed = opencue.wrappers.deed.Deed(host_pb2.Deed(id=TEST_DEED_ID))
host = deed.getHost()

stubMock.GetHost.assert_called_with(
host_pb2.DeedGetHostRequest(deed=deed.data), timeout=mock.ANY)
self.assertEqual(host.id(), TEST_HOST_ID)

def testGetOwner(self, getStubMock):
stubMock = mock.Mock()
stubMock.GetOwner.return_value = host_pb2.DeedGetOwnerResponse(
owner=host_pb2.Owner(name=TEST_DEED_OWNER))
getStubMock.return_value = stubMock

deed = opencue.wrappers.deed.Deed(host_pb2.Deed(id=TEST_DEED_ID))
owner = deed.getOwner()

stubMock.GetOwner.assert_called_with(
host_pb2.DeedGetOwnerRequest(deed=deed.data), timeout=mock.ANY)
self.assertEqual(owner.name(), TEST_DEED_OWNER)

def testSetBlackoutTime(self, getStubMock):
stubMock = mock.Mock()
stubMock.SetBlackoutTime.return_value = host_pb2.DeedSetBlackoutTimeResponse()
getStubMock.return_value = stubMock

testStartTime = 100
testStopTime = 200
deed = opencue.wrappers.deed.Deed(host_pb2.Deed(id=TEST_DEED_ID))
deed.setBlackoutTime(testStartTime, testStopTime)

stubMock.SetBlackoutTime.assert_called_with(
host_pb2.DeedSetBlackoutTimeRequest(deed=deed.data,
start_time=testStartTime,
stop_time=testStopTime),
timeout=mock.ANY)

def testSetBlackoutTimeEnabled(self, getStubMock):
stubMock = mock.Mock()
stubMock.SetBlackoutTimeEnabled.return_value = host_pb2.DeedSetBlackoutTimeEnabledResponse()
getStubMock.return_value = stubMock

testBlackoutEnabled = True
deed = opencue.wrappers.deed.Deed(host_pb2.Deed(id=TEST_DEED_ID))
deed.setBlackoutTimeEnabled(testBlackoutEnabled)

stubMock.SetBlackoutTimeEnabled.assert_called_with(
host_pb2.DeedSetBlackoutTimeEnabledRequest(deed=deed.data,
enabled=testBlackoutEnabled),
timeout=mock.ANY)


if __name__ == '__main__':
unittest.main()
14 changes: 14 additions & 0 deletions pycue/tests/wrappers/layer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,20 @@ def testCreateFrameByFrameDependency(self, getStubMock):
timeout=mock.ANY)
self.assertEqual(depend.id(), dependId)

def testRegisterOutputPath(self, getStubMock):
stubMock = mock.Mock()
stubMock.RegisterOutputPath.return_value = job_pb2.LayerRegisterOutputPathResponse()
getStubMock.return_value = stubMock

outputPath = '/test/output/path'
layer = opencue.wrappers.layer.Layer(
job_pb2.Layer(name=TEST_LAYER_NAME))
layer.registerOutputPath(outputPath)

stubMock.RegisterOutputPath.assert_called_with(
job_pb2.LayerRegisterOutputPathRequest(layer=layer.data, spec=outputPath),
timeout=mock.ANY)

def testReorderFrames(self, getStubMock):
stubMock = mock.Mock()
stubMock.ReorderFrames.return_value = job_pb2.LayerReorderFramesResponse()
Expand Down
Loading

0 comments on commit 75b8071

Please sign in to comment.