Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion VERSION.in
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.25
1.26
6 changes: 6 additions & 0 deletions api_docs/modules/opencue.wrappers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ opencue.wrappers.deed module
.. automodule:: opencue.wrappers.deed
:members:

opencue.wrappers.department module
----------------------------------

.. automodule:: opencue.wrappers.department
:members:

opencue.wrappers.depend module
------------------------------

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ public void replaceTasks(DeptReplaceTaskRequest request,
responseObserver.onCompleted();
}

@Override
public void setManagedCores(DeptSetManagedCoresRequest request,
StreamObserver<DeptSetManagedCoresResponse> responseObserver) {
PointDetail deptConfig =
Expand Down
2 changes: 1 addition & 1 deletion cuegui/cuegui/MenuActions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2264,7 +2264,7 @@ def setMinCores(self, rpcObjects=None):
def clearAdjustment(self, rpcObjects=None):
tasks = self._getSelected(rpcObjects)
for task in tasks:
task.clearAdjustment()
task.clearAdjustments()
self._update()

delete_info = ["Delete Task", None, "configure"]
Expand Down
4 changes: 2 additions & 2 deletions cuegui/tests/test_menu_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1738,11 +1738,11 @@ def test_setMinCores(self, getDoubleMock):

def test_clearAdjustment(self):
task = opencue.wrappers.task.Task(opencue_proto.task_pb2.Task())
task.clearAdjustment = mock.MagicMock()
task.clearAdjustments = mock.MagicMock()

self.task_actions.clearAdjustment(rpcObjects=[task])

task.clearAdjustment.assert_called()
task.clearAdjustments.assert_called()

@mock.patch('cuegui.Utils.questionBoxYesNo', new=mock.Mock(return_value=True))
def test_delete(self):
Expand Down
2 changes: 1 addition & 1 deletion proto/src/department.proto
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ service DepartmentInterface {
rpc ReplaceTasks(DeptReplaceTaskRequest) returns (DeptReplaceTaskResponse);

// Sets the minimum number of cores for the department to manage between its tasks.
rpc SetMangedCores(DeptSetManagedCoresRequest) returns (DeptSetManagedCoresResponse);
rpc SetManagedCores(DeptSetManagedCoresRequest) returns (DeptSetManagedCoresResponse);
}


Expand Down
27 changes: 25 additions & 2 deletions pycue/opencue/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
# pylint: disable=cyclic-import
from .wrappers.allocation import Allocation
from .wrappers.comment import Comment
from .wrappers.department import Department
from .wrappers.depend import Depend
from .wrappers.filter import Action
from .wrappers.filter import Filter
Expand All @@ -62,8 +63,8 @@
filter_pb2, host_pb2, job_pb2, renderPartition_pb2, report_pb2, service_pb2,
show_pb2, subscription_pb2, task_pb2]

__wrappers = [Action, Allocation, Comment, Depend, Filter, Frame, Group, Host, Job, Layer, Matcher,
NestedHost, Proc, Show, Subscription, Task]
__wrappers = [Action, Allocation, Comment, Department, Depend, Filter, Frame, Group, Host, Job,
Layer, Matcher, NestedHost, Proc, Show, Subscription, Task]


#
Expand Down Expand Up @@ -187,6 +188,28 @@ def getDepartmentNames():
department_pb2.DeptGetDepartmentNamesRequest(), timeout=Cuebot.Timeout).names)


@util.grpcExceptionParser
def addDepartmentName(name):
"""Adds a department name to the list of allowed department names.

:type name: str
:param name: a department name to allow
"""
Cuebot.getStub('department').AddDepartmentName(
department_pb2.DeptAddDeptNameRequest(name=name), timeout=Cuebot.Timeout)


@util.grpcExceptionParser
def removeDepartmentName(name):
"""Removes a department name from the list of allowed department names.

:type name: str
:param name: the department name to remove
"""
Cuebot.getStub('department').RemoveDepartmentName(
department_pb2.DeptRemoveDepartmentNameRequest(name=name), timeout=Cuebot.Timeout)


#
# Shows
#
Expand Down
143 changes: 143 additions & 0 deletions pycue/opencue/wrappers/department.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
# 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.

"""Module for classes related to departments."""

from opencue_proto import department_pb2
from opencue.cuebot import Cuebot
import opencue.wrappers.task


class Department(object):
"""This class contains the grpc implementation related to a Department."""

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

def addTask(self, shot, minCores):
"""Adds a task to the department and returns it.

:type shot: str
:param shot: name of the shot the task is for
:type minCores: float
:param minCores: the minimum number of cores the task needs
:rtype: opencue.wrappers.task.Task
:return: the newly created task
"""
response = self.stub.AddTask(
department_pb2.DeptAddTaskRequest(
department=self.data, shot=shot, min_cores=minCores),
timeout=Cuebot.Timeout)
return opencue.wrappers.task.Task(response.task)

def addTasks(self, taskMap):
"""Adds a map of tasks to the department and returns them as a list.

:type taskMap: dict<str, int>
:param taskMap: map of shot names to minimum core units
:rtype: list<opencue.wrappers.task.Task>
:return: the newly created tasks
"""
response = self.stub.AddTasks(
department_pb2.DeptAddTasksRequest(department=self.data, tmap=taskMap),
timeout=Cuebot.Timeout)
return [opencue.wrappers.task.Task(task) for task in response.tasks.tasks]

def clearTaskAdjustments(self):
"""Clears all manual task adjustments to managed tasks.

This won't do anything unless the department is Track-It managed.
"""
self.stub.ClearTaskAdjustments(
department_pb2.DeptClearTaskAdjustmentsRequest(department=self.data),
timeout=Cuebot.Timeout)

def clearTasks(self):
"""Clears all tasks from the department."""
self.stub.ClearTasks(
department_pb2.DeptClearTasksRequest(department=self.data),
timeout=Cuebot.Timeout)

def disableTiManaged(self):
"""Disables Track-It management; this also clears all tasks."""
self.stub.DisableTiManaged(
department_pb2.DeptDisableTiManagedRequest(department=self.data),
timeout=Cuebot.Timeout)

def enableTiManaged(self, tiTask, managedCores):
"""Enables Track-It management.

This will pull a task list from Track-It and keep it synced.

:type tiTask: str
:param tiTask: name of the Track-It task to manage the department with
:type managedCores: float
:param managedCores: the number of cores to split up among the active tasks
"""
self.stub.EnableTiManaged(
department_pb2.DeptEnableTiManagedRequest(
department=self.data, ti_task=tiTask, managed_cores=managedCores),
timeout=Cuebot.Timeout)

def getTasks(self):
"""Returns the list of tasks for the department.

:rtype: list<opencue.wrappers.task.Task>
:return: tasks of the department
"""
response = self.stub.GetTasks(
department_pb2.DeptGetTasksRequest(department=self.data),
timeout=Cuebot.Timeout)
return [opencue.wrappers.task.Task(task) for task in response.tasks.tasks]

def replaceTasks(self, taskMap):
"""Replaces a map of tasks; existing tasks are updated, new tasks are inserted.

:type taskMap: dict<str, int>
:param taskMap: map of shot names to minimum core units
:rtype: list<opencue.wrappers.task.Task>
:return: the resulting tasks
"""
response = self.stub.ReplaceTasks(
department_pb2.DeptReplaceTaskRequest(department=self.data, tmap=taskMap),
timeout=Cuebot.Timeout)
return [opencue.wrappers.task.Task(task) for task in response.tasks.tasks]

def setManagedCores(self, managedCores):
"""Sets the minimum number of cores for the department to manage between its tasks.

:type managedCores: float
:param managedCores: the number of cores to manage between the tasks
"""
self.stub.SetManagedCores(
department_pb2.DeptSetManagedCoresRequest(
department=self.data, managed_cores=managedCores),
timeout=Cuebot.Timeout)

def id(self):
"""Returns the unique id of the department.

:rtype: str
:return: department id
"""
return self.data.id

def name(self):
"""Returns the name of the department.

:rtype: str
:return: department name
"""
return self.data.name
26 changes: 26 additions & 0 deletions pycue/opencue/wrappers/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from opencue_proto import show_pb2
from opencue.cuebot import Cuebot
import opencue.wrappers.department
import opencue.wrappers.filter
import opencue.wrappers.group
import opencue.wrappers.subscription
Expand Down Expand Up @@ -257,6 +258,31 @@ def createFilter(self, name):
show=self.data, name=name), timeout=Cuebot.Timeout)
return opencue.wrappers.filter.Filter(response.filter)

def getDepartment(self, department):
"""Gets the department of the show with the matching name.

:type department: str
:param department: name of the department to find
:rtype: opencue.wrappers.department.Department
:return: matching department of the show
"""
response = self.stub.GetDepartment(show_pb2.ShowGetDepartmentRequest(
show=self.data, department=department),
timeout=Cuebot.Timeout)
return opencue.wrappers.department.Department(response.department)

def getDepartments(self):
"""Gets the departments that belong to the show.

:rtype: list<opencue.wrappers.department.Department>
:return: list of departments for this show
"""
response = self.stub.GetDepartments(show_pb2.ShowGetDepartmentsRequest(
show=self.data),
timeout=Cuebot.Timeout)
return [opencue.wrappers.department.Department(dept)
for dept in response.departments.departments]

def getGroups(self):
"""Gets the groups for the show.

Expand Down
5 changes: 5 additions & 0 deletions pycue/opencue/wrappers/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ def setMinCores(self, minCores):
task_pb2.TaskSetMinCoresRequest(task=self.data, new_min_cores=minCores),
timeout=Cuebot.Timeout)

def clearAdjustments(self):
"""Clears any manual adjustments made to the task."""
self.stub.ClearAdjustments(
task_pb2.TaskClearAdjustmentsRequest(task=self.data), timeout=Cuebot.Timeout)

def delete(self):
"""Deletes the task."""
self.stub.Delete(task_pb2.TaskDeleteRequest(task=self.data), timeout=Cuebot.Timeout)
42 changes: 42 additions & 0 deletions pycue/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import mock

from opencue_proto import cue_pb2
from opencue_proto import department_pb2
from opencue_proto import depend_pb2
from opencue_proto import facility_pb2
from opencue_proto import filter_pb2
Expand All @@ -45,6 +46,7 @@
TEST_HOST_NAME = 'wolf1001'
TEST_SUB_NAME = 'pipe.General'
TEST_FACILITY_NAME = 'arbitrary-facility-name'
TEST_DEPARTMENT_NAME = 'arbitrary-department-name'
TEST_TAG = 'General'
TEST_ALLOC_NAME = 'pipe.General'
TEST_PROC_NAME = 'arbitrary-proc-name'
Expand Down Expand Up @@ -619,6 +621,46 @@ def testDeleteFacility(self, getStubMock):
facility_pb2.FacilityDeleteRequest(name=TEST_FACILITY_NAME), timeout=mock.ANY)


class DepartmentTests(unittest.TestCase):

@mock.patch('opencue.cuebot.Cuebot.getStub')
def testGetDepartmentNames(self, getStubMock):
stubMock = mock.Mock()
stubMock.GetDepartmentNames.return_value = department_pb2.DeptGetDepartmentNamesResponse(
names=[TEST_DEPARTMENT_NAME])
getStubMock.return_value = stubMock

names = opencue.api.getDepartmentNames()

stubMock.GetDepartmentNames.assert_called_with(
department_pb2.DeptGetDepartmentNamesRequest(), timeout=mock.ANY)
self.assertEqual([TEST_DEPARTMENT_NAME], names)

@mock.patch('opencue.cuebot.Cuebot.getStub')
def testAddDepartmentName(self, getStubMock):
stubMock = mock.Mock()
stubMock.AddDepartmentName.return_value = department_pb2.DeptAddDeptNameResponse()
getStubMock.return_value = stubMock

opencue.api.addDepartmentName(TEST_DEPARTMENT_NAME)

stubMock.AddDepartmentName.assert_called_with(
department_pb2.DeptAddDeptNameRequest(name=TEST_DEPARTMENT_NAME), timeout=mock.ANY)

@mock.patch('opencue.cuebot.Cuebot.getStub')
def testRemoveDepartmentName(self, getStubMock):
stubMock = mock.Mock()
stubMock.RemoveDepartmentName.return_value = \
department_pb2.DeptRemoveDepartmentNameResponse()
getStubMock.return_value = stubMock

opencue.api.removeDepartmentName(TEST_DEPARTMENT_NAME)

stubMock.RemoveDepartmentName.assert_called_with(
department_pb2.DeptRemoveDepartmentNameRequest(name=TEST_DEPARTMENT_NAME),
timeout=mock.ANY)


class DependTests(unittest.TestCase):

@mock.patch('opencue.cuebot.Cuebot.getStub')
Expand Down
Loading
Loading