Skip to content

Commit

Permalink
Merge pull request #1028 from andrewkaufman/taskList
Browse files Browse the repository at this point in the history
Added TaskList
  • Loading branch information
johnhaddon committed Oct 10, 2014
2 parents 4f99aa1 + 423a1b2 commit 8e2daf2
Show file tree
Hide file tree
Showing 8 changed files with 193 additions and 2 deletions.
4 changes: 4 additions & 0 deletions python/Gaffer/LocalDispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ def __backgroundDispatch( self, batch, scriptFile, messageTitle ) :

script = batch.node().scriptNode()

if isinstance( batch.node(), Gaffer.TaskList ) :
IECore.msg( IECore.MessageHandler.Level.Info, messageTitle, "Finished " + batch.node().relativeName( script ) )
return

taskContext = batch.context()
frames = str( IECore.frameListFromList( [ int(x) for x in batch.frames() ] ) )

Expand Down
59 changes: 59 additions & 0 deletions python/Gaffer/TaskList.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
##########################################################################
#
# Copyright (c) 2014, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# * Neither the name of John Haddon nor the names of
# any other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import os
import subprocess

import IECore

import Gaffer

# Used to collect Executable tasks for dispatching all at once
class TaskList( Gaffer.ExecutableNode ) :

def __init__( self, name = "TaskList" ) :

Gaffer.ExecutableNode.__init__( self, name )

def hash( self, context ) :

return IECore.MurmurHash()

def execute( self ) :

pass

IECore.registerRunTimeTyped( TaskList, typeName = "Gaffer::TaskList" )
1 change: 1 addition & 0 deletions python/Gaffer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,6 @@
from OutputRedirection import OutputRedirection
from LocalDispatcher import LocalDispatcher
from SystemCommand import SystemCommand
from TaskList import TaskList

__import__( "IECore" ).loadConfig( "GAFFER_STARTUP_PATHS", {}, subdirectory = "Gaffer" )
71 changes: 71 additions & 0 deletions python/GafferTest/TaskListTest.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
##########################################################################
#
# Copyright (c) 2014, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# * Neither the name of John Haddon nor the names of
# any other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import os
import unittest

import IECore

import Gaffer
import GafferTest

class TaskListTest( GafferTest.TestCase ) :

def test( self ) :

n = Gaffer.TaskList()
c = Gaffer.Context()
c2 = Gaffer.Context()
c2["frame"] = 10.0
self.assertEqual( n.hash( c ), n.hash( c2 ) )

n2 = Gaffer.TaskList( "TaskList2" )
self.assertEqual( n.hash( c ), n2.hash( c ) )
self.assertEqual( n.hash( c2 ), n2.hash( c2 ) )

def setUp( self ) :

for f in [ "/tmp/systemCommandTest.txt" ] :
if os.path.exists( f ) :
os.remove( f )

def tearDown( self ) :

self.setUp()

if __name__ == "__main__":
unittest.main()

1 change: 1 addition & 0 deletions python/GafferTest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ def wrapper( self ) :
from MetadataTest import MetadataTest
from StringAlgoTest import StringAlgoTest
from SystemCommandTest import SystemCommandTest
from TaskListTest import TaskListTest

if __name__ == "__main__":
import unittest
Expand Down
46 changes: 46 additions & 0 deletions python/GafferUI/TaskListUI.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
##########################################################################
#
# Copyright (c) 2014, Image Engine Design Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above
# copyright notice, this list of conditions and the following
# disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided with
# the distribution.
#
# * Neither the name of John Haddon nor the names of
# any other contributors to this software may be used to endorse or
# promote products derived from this software without specific prior
# written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
##########################################################################

import Gaffer
import GafferUI

Gaffer.Metadata.registerNodeDescription(

Gaffer.TaskList,

"""Used to collect Executable tasks for dispatching all at once""",

)
12 changes: 10 additions & 2 deletions src/Gaffer/Dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,14 +402,22 @@ Dispatcher::TaskBatchPtr Dispatcher::acquireBatch( const ExecutableNode::Task &t
}
}

tasksToBatches[taskHash] = batch;
if ( taskHash != MurmurHash() )
{
tasksToBatches[taskHash] = batch;
}

return batch;
}
}

TaskBatchPtr batch = new TaskBatch( task );
currentBatches[hash] = batch;
tasksToBatches[taskHash] = batch;
if ( taskHash != MurmurHash() )
{
tasksToBatches[taskHash] = batch;
}

return batch;
}

Expand Down
1 change: 1 addition & 0 deletions startup/gui/menus.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,4 @@ def __shaderNodeCreator( nodeName, shaderName ) :
nodeMenu.append( "/Utility/Reference", GafferUI.ReferenceUI.nodeMenuCreateCommand )
nodeMenu.definition().append( "/Utility/Backdrop", { "command" : GafferUI.BackdropUI.nodeMenuCreateCommand } )
nodeMenu.append( "/Utility/System Command", Gaffer.SystemCommand, searchText = "SystemCommand" )
nodeMenu.append( "/Utility/Task List", Gaffer.TaskList, searchText = "TaskList" )

0 comments on commit 8e2daf2

Please sign in to comment.