From 81a272a18c298ac1a3bbcd53b2cf9d7daad03248 Mon Sep 17 00:00:00 2001 From: Akim Ruslanov Date: Sat, 4 Jun 2022 11:14:16 -0700 Subject: [PATCH] Add layer max cores. (#1125) --- VERSION.in | 2 +- .../com/imageworks/spcue/dao/LayerDao.java | 12 +++++++++- .../spcue/dao/postgres/LayerDaoJdbc.java | 7 ++++++ .../spcue/service/FilterManagerService.java | 6 ++++- .../test/service/FilterManagerTests.java | 2 +- cuegui/cuegui/FilterDialog.py | 24 +++++++++++++++---- proto/filter.proto | 9 +++++-- pycue/opencue/wrappers/filter.py | 6 +++-- 8 files changed, 55 insertions(+), 13 deletions(-) diff --git a/VERSION.in b/VERSION.in index 50653ad0a..a4d2aceeb 100644 --- a/VERSION.in +++ b/VERSION.in @@ -1 +1 @@ -0.17 +0.18 diff --git a/cuebot/src/main/java/com/imageworks/spcue/dao/LayerDao.java b/cuebot/src/main/java/com/imageworks/spcue/dao/LayerDao.java index ba8295462..9343c3aa0 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dao/LayerDao.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dao/LayerDao.java @@ -124,7 +124,7 @@ public interface LayerDao { LayerInterface findLayer(JobInterface job, String name); /** - * update the number of cores the layer requires + * update the number of min cores the layer requires * * @param layer * @param val @@ -270,6 +270,16 @@ public interface LayerDao { */ void updateMinGpuMemory(JobInterface job, long mem, LayerType type); + /** + * Update all layers of the set type in the specified job + * with the new max cores requirement. + * + * @param job + * @param cores + * @param type + */ + void updateMaxCores(JobInterface job, int cores, LayerType type); + /** * Update all layers of the set type in the specified job * with the new min cores requirement. diff --git a/cuebot/src/main/java/com/imageworks/spcue/dao/postgres/LayerDaoJdbc.java b/cuebot/src/main/java/com/imageworks/spcue/dao/postgres/LayerDaoJdbc.java index 212963519..15941a196 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/dao/postgres/LayerDaoJdbc.java +++ b/cuebot/src/main/java/com/imageworks/spcue/dao/postgres/LayerDaoJdbc.java @@ -641,6 +641,13 @@ public void updateMinCores(JobInterface job, int cores, LayerType type) { cores, job.getJobId(), type.toString()); } + @Override + public void updateMaxCores(JobInterface job, int cores, LayerType type) { + getJdbcTemplate().update( + "UPDATE layer SET int_cores_max=? WHERE pk_job=? AND str_type=?", + cores, job.getJobId(), type.toString()); + } + @Override public void updateMinGpus(JobInterface job, int gpus, LayerType type) { getJdbcTemplate().update( diff --git a/cuebot/src/main/java/com/imageworks/spcue/service/FilterManagerService.java b/cuebot/src/main/java/com/imageworks/spcue/service/FilterManagerService.java index f27541884..6d4382714 100644 --- a/cuebot/src/main/java/com/imageworks/spcue/service/FilterManagerService.java +++ b/cuebot/src/main/java/com/imageworks/spcue/service/FilterManagerService.java @@ -396,10 +396,14 @@ public boolean applyAction(ActionEntity action, JobDetail job, Context context) layerDao.updateMinMemory(job, (int) action.intValue, LayerType.RENDER); break; - case SET_ALL_RENDER_LAYER_CORES: + case SET_ALL_RENDER_LAYER_MIN_CORES: layerDao.updateMinCores(job, Convert.coresToCoreUnits(action.floatValue), LayerType.RENDER); break; + case SET_ALL_RENDER_LAYER_MAX_CORES: + layerDao.updateMaxCores(job, Convert.coresToCoreUnits(action.floatValue), LayerType.RENDER); + break; + case SET_MEMORY_OPTIMIZER: List layers = layerDao.getLayers(job); for (LayerInterface layer : layers) { diff --git a/cuebot/src/test/java/com/imageworks/spcue/test/service/FilterManagerTests.java b/cuebot/src/test/java/com/imageworks/spcue/test/service/FilterManagerTests.java index 4bce07507..13da1c7de 100644 --- a/cuebot/src/test/java/com/imageworks/spcue/test/service/FilterManagerTests.java +++ b/cuebot/src/test/java/com/imageworks/spcue/test/service/FilterManagerTests.java @@ -359,7 +359,7 @@ public void testApplyActionSetRenderCoreLayers() { filterDao.insertFilter(f); ActionEntity a1 = new ActionEntity(); - a1.type = ActionType.SET_ALL_RENDER_LAYER_CORES; + a1.type = ActionType.SET_ALL_RENDER_LAYER_MIN_CORES; a1.filterId = f.getFilterId(); a1.valueType = ActionValueType.FLOAT_TYPE; a1.floatValue = 40f; diff --git a/cuegui/cuegui/FilterDialog.py b/cuegui/cuegui/FilterDialog.py index 73b4153da..46126050b 100644 --- a/cuegui/cuegui/FilterDialog.py +++ b/cuegui/cuegui/FilterDialog.py @@ -480,11 +480,22 @@ def createAction(self): 2) value = int(value * 1048576) - elif actionType in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_CORES,): + elif actionType in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MIN_CORES,): (value, choice) = QtWidgets.QInputDialog.getDouble( self, "Create Action", - "How many cores should every render layer require?", + "How many min cores should every render layer require?", + 1, + 0.1, + 100, + 2) + value = float(value) + + elif actionType in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MAX_CORES,): + (value, choice) = QtWidgets.QInputDialog.getDouble( + self, + "Create Action", + "How many max cores should every render layer require?", 1, 0.1, 100, @@ -728,7 +739,8 @@ def __setValue(self, value=None): elif self.rpcObject.type() in (opencue.api.filter_pb2.SET_JOB_MAX_CORES, opencue.api.filter_pb2.SET_JOB_MIN_CORES, - opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_CORES): + opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MIN_CORES, + opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MAX_CORES): value = float(widget.value()) elif self.rpcObject.type() in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_TAGS,): @@ -765,7 +777,8 @@ def updateWidgets(self): widget.editingFinished.connect(self.__setValue) # pylint: disable=no-member elif self.rpcObject.type() in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MEMORY, - opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_CORES): + opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MIN_CORES, + opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MAX_CORES): widget = NoWheelDoubleSpinBox(self.parent()) widget.setDecimals(2) widget.setSingleStep(.10) @@ -817,7 +830,8 @@ def updateWidgets(self): elif self.rpcObject.type() in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_TAGS,): self.__widgets["ActionValue"].setText(self.rpcObject.value()) - elif self.rpcObject.type() in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_CORES, + elif self.rpcObject.type() in (opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MIN_CORES, + opencue.api.filter_pb2.SET_ALL_RENDER_LAYER_MAX_CORES, opencue.api.filter_pb2.SET_JOB_MAX_CORES, opencue.api.filter_pb2.SET_JOB_MIN_CORES): self.__widgets["ActionValue"].setValue(float(str(self.rpcObject.value()))) diff --git a/proto/filter.proto b/proto/filter.proto index fdfae12e6..184097782 100644 --- a/proto/filter.proto +++ b/proto/filter.proto @@ -96,10 +96,15 @@ enum ActionType { SET_ALL_RENDER_LAYER_TAGS = 6; // Sets all layer minimum memory for any layer with the type "Render" SET_ALL_RENDER_LAYER_MEMORY = 7; - // Sets all min cores for any layer with the type "Render" - SET_ALL_RENDER_LAYER_CORES = 8; + // This field is deprecated, use SET_ALL_RENDER_LAYER_MIN_CORES and + // SET_ALL_RENDER_LAYER_MAX_CORES instead. + SET_ALL_RENDER_LAYER_CORES = 8 [deprecated = true]; // Set memory optimizer SET_MEMORY_OPTIMIZER = 9; + // Sets all min cores for any layer with the type "Render" + SET_ALL_RENDER_LAYER_MIN_CORES = 10; + // Sets all max cores for any layer with the type "Render" + SET_ALL_RENDER_LAYER_MAX_CORES = 11; }; enum ActionValueType { diff --git a/pycue/opencue/wrappers/filter.py b/pycue/opencue/wrappers/filter.py index 45e3949ca..e18194a1c 100644 --- a/pycue/opencue/wrappers/filter.py +++ b/pycue/opencue/wrappers/filter.py @@ -270,7 +270,8 @@ class ActionType(enum.IntEnum): SET_JOB_PRIORITY = filter_pb2.SET_JOB_PRIORITY SET_ALL_RENDER_LAYER_TAGS = filter_pb2.SET_ALL_RENDER_LAYER_TAGS SET_ALL_RENDER_LAYER_MEMORY = filter_pb2.SET_ALL_RENDER_LAYER_MEMORY - SET_ALL_RENDER_LAYER_CORES = filter_pb2.SET_ALL_RENDER_LAYER_CORES + SET_ALL_RENDER_LAYER_MIN_CORES = filter_pb2.SET_ALL_RENDER_LAYER_MIN_CORES + SET_ALL_RENDER_LAYER_MAX_CORES = filter_pb2.SET_ALL_RENDER_LAYER_MAX_CORES SET_MEMORY_OPTIMIZER = filter_pb2.SET_MEMORY_OPTIMIZER class ActionValueType(enum.IntEnum): @@ -390,7 +391,8 @@ def setTypeAndValue(self, actionType, value): elif actionType in (filter_pb2.SET_JOB_MIN_CORES, filter_pb2.SET_JOB_MAX_CORES, - filter_pb2.SET_ALL_RENDER_LAYER_CORES): + filter_pb2.SET_ALL_RENDER_LAYER_MIN_CORES, + filter_pb2.SET_ALL_RENDER_LAYER_MAX_CORES): self.data.float_value = float(value) self.data.value_type = filter_pb2.FLOAT_TYPE