Skip to content

Commit

Permalink
Fix service override delete and update operations
Browse files Browse the repository at this point in the history
- Implements ServiceOverride wrapper class in pycue
- Fixes handling of ServiceOverride objects in the GUI
- Resolves bug in cuebot that incorrectly processes ServiceOverrideDeleteRequest and ServiceOverrideUpdateRequest

(cherry picked from commit ab4e0c195f1f3df4f9c625b62ff9532b438ee5a4)
  • Loading branch information
yaash45 authored and DiegoTavares committed Dec 11, 2020
1 parent eaa4951 commit 696abdc
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

import io.grpc.stub.StreamObserver;

import com.imageworks.spcue.ServiceEntity;
import com.imageworks.spcue.ServiceOverrideEntity;
import com.imageworks.spcue.grpc.service.Service;
import com.imageworks.spcue.grpc.service.ServiceOverrideDeleteRequest;
import com.imageworks.spcue.grpc.service.ServiceOverrideDeleteResponse;
Expand All @@ -39,15 +39,17 @@ public class ManageServiceOverride extends ServiceOverrideInterfaceGrpc.ServiceO
@Override
public void delete(ServiceOverrideDeleteRequest request,
StreamObserver<ServiceOverrideDeleteResponse> responseObserver) {
serviceManager.deleteService(toServiceEntity(request.getService()));
// Passing null on showId as the interface doesn't require a showId in this situation
serviceManager.deleteService(toServiceOverrideEntity(request.getService(), null));
responseObserver.onNext(ServiceOverrideDeleteResponse.newBuilder().build());
responseObserver.onCompleted();
}

@Override
public void update(ServiceOverrideUpdateRequest request,
StreamObserver<ServiceOverrideUpdateResponse> responseObserver) {
serviceManager.updateService(toServiceEntity(request.getService()));
// Passing null on showId as the interface doesn't require a showId in this situation
serviceManager.updateService(toServiceOverrideEntity(request.getService(), null));
responseObserver.onNext(ServiceOverrideUpdateResponse.newBuilder().build());
responseObserver.onCompleted();
}
Expand All @@ -60,8 +62,8 @@ public void setServiceManager(ServiceManager serviceManager) {
this.serviceManager = serviceManager;
}

private ServiceEntity toServiceEntity(Service service) {
ServiceEntity entity = new ServiceEntity();
private ServiceOverrideEntity toServiceOverrideEntity(Service service, String showId){
ServiceOverrideEntity entity = new ServiceOverrideEntity();
entity.id = service.getId();
entity.name = service.getName();
entity.minCores = service.getMinCores();
Expand All @@ -70,6 +72,7 @@ private ServiceEntity toServiceEntity(Service service) {
entity.minGpu = service.getMinGpu();
entity.tags = new LinkedHashSet<>(service.getTagsList());
entity.threadable = service.getThreadable();
entity.showId = showId;
return entity;
}
}
26 changes: 15 additions & 11 deletions cuegui/cuegui/ServiceDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import cuegui.Constants
import cuegui.TagsWidget
import cuegui.Utils
from opencue.wrappers.service import ServiceOverride


class ServiceForm(QtWidgets.QWidget):
Expand Down Expand Up @@ -108,17 +109,15 @@ def setService(self, service):
Update the form with data from the given service.
"""
self.__buttons.setDisabled(False)
self.name.setText(service.data.name)
self.threadable.setChecked(service.data.threadable)
self.min_cores.setValue(service.data.min_cores)
self.max_cores.setValue(service.data.max_cores)
self.min_memory.setValue(service.data.min_memory // 1024)
self.min_gpu.setValue(service.data.min_gpu // 1024)
self._tags_w.set_tags(service.data.tags)
self.__service = service.data

self.name.setText(self.__service.name)
self.threadable.setChecked(self.__service.threadable)
self.min_cores.setValue(self.__service.min_cores)
self.max_cores.setValue(self.__service.max_cores)
self.min_memory.setValue(self.__service.min_memory // 1024)
self.min_gpu.setValue(self.__service.min_gpu // 1024)

self._tags_w.set_tags(self.__service.tags)

def new(self):
"""
Clear the form for a new service.
Expand Down Expand Up @@ -231,11 +230,16 @@ def saved(self, service):

if self.__new_service:
if self.__show:
self.__show.createServiceOverride(service.data)
serviceOverride = self.__show.createServiceOverride(service.data)
else:
opencue.api.createService(service.data)
else:
service.update()
if self.__show:
serviceOverride = ServiceOverride(service)
serviceOverride.id = service.id()
serviceOverride.update()
else:
service.update()

self.refresh()
self.__new_service = False
Expand Down
1 change: 1 addition & 0 deletions pycue/opencue/cuebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ class Cuebot(object):
'proc': host_pb2_grpc.ProcInterfaceStub,
'renderPartition': renderPartition_pb2_grpc.RenderPartitionInterfaceStub,
'service': service_pb2_grpc.ServiceInterfaceStub,
'serviceOverride': service_pb2_grpc.ServiceOverrideInterfaceStub,
'show': show_pb2_grpc.ShowInterfaceStub,
'subscription': subscription_pb2_grpc.SubscriptionInterfaceStub,
'task': task_pb2_grpc.TaskInterfaceStub
Expand Down
23 changes: 23 additions & 0 deletions pycue/opencue/wrappers/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,3 +172,26 @@ def setTags(self, tags):
:type: list<string>
:param: list of tags to set"""
self.data.tags[:] = tags


class ServiceOverride(object):
def __init__(self, serviceOverride=None):
if serviceOverride:
self.id = serviceOverride.id
self.data = serviceOverride.data or service_pb2.Service().data
else:
defaultServiceOverride = service_pb2.ServiceOverride()
self.id = defaultServiceOverride.id
self.data = defaultServiceOverride.data

self.stub = Cuebot.getStub("serviceOverride")

def delete(self):
self.stub.Delete(
service_pb2.ServiceOverrideDeleteRequest(service=self.data),
timeout=Cuebot.Timeout)

def update(self):
self.stub.Update(
service_pb2.ServiceOverrideUpdateRequest(service=self.data),
timeout=Cuebot.Timeout)
25 changes: 24 additions & 1 deletion pycue/opencue/wrappers/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import opencue.wrappers.filter
import opencue.wrappers.group
import opencue.wrappers.subscription
from opencue.wrappers.service import ServiceOverride


class Show(object):
Expand Down Expand Up @@ -68,6 +69,28 @@ def delete(self):
"""Delete this show"""
self.stub.Delete(show_pb2.ShowDeleteRequest(show=self.data), timeout=Cuebot.Timeout)

def createServiceOverride(self, data):
"""Creates a Service Override at the show level.
:type data: opencue.wrapper.service.Service
:param data: Service.data object
"""
self.stub.CreateServiceOverride(show_pb2.ShowCreateServiceOverrideRequest(
show=self.data, service=data),
timeout=Cuebot.Timeout)

def getServiceOverride(self, serviceName):
"""
Returns a service override for a show
:param serviceName: name of the service for the show
:return: service override object
"""
serviceOverride = self.stub.GetServiceOverride(show_pb2.ShowGetServiceOverrideRequest(
show=self.data, name=serviceName),
timeout=Cuebot.Timeout).service_override
return ServiceOverride(serviceOverride)

def getServiceOverrides(self):
"""Returns a list of service overrides on the show.
Expand All @@ -77,7 +100,7 @@ def getServiceOverrides(self):
serviceOverrideSeq = self.stub.GetServiceOverrides(
show_pb2.ShowGetServiceOverridesRequest(show=self.data),
timeout=Cuebot.Timeout).service_overrides
return serviceOverrideSeq.service_overrides
return [ServiceOverride(override) for override in serviceOverrideSeq.service_overrides]

def getSubscriptions(self):
"""Returns a list of all subscriptions.
Expand Down

0 comments on commit 696abdc

Please sign in to comment.