AWS Thinkbox Discussion Forums

Draft event plugin and "import Draft" fail

I’m trying to do something similar to this: GitHub - MikhailPasechnik/AutoFFmpeg: Deadline plugin for automatically creating preview from rendered job using ffmpeg.
So an event plugin that will render Draft job for every completed Job.
I have two questions:

  1. Is it even necessary to do it that way? It’s weird that Draft doesn’t already have similar functionality.
  2. The real question here:
    I can’t import Draft in my event plugin. When I synchronize script that is importing Draft I get this
2023-09-16 21:32:26:  Event plugin 'AutoDraftPlugin' could not be loaded from the repository because: Error executing event plugin script "P:\DeadlineRepository10\events\AutoDraftPlugin\": ModuleNotFoundError : No module named 'Draft' (Deadline.Events.DeadlineEventPluginException)

When I’m importing Draft from here:
C:\Program Files\Thinkbox\Deadline10\bin\python3 I can do it.
I’ve set env variables MAGICK_CONFIGURE_PATH and PYTHONPATH to P:\DeadlineRepository10\draft3\Windows\64bit

When I manually create Draft job by RMB>scripts… everything works fine.

I’m pretty new to all of this and to Python as well. Any help will be highly appreciated!

Mmm. Are you setting the enviornment in the event script? Here’s an example from

    def DraftAutoUpdate( self, localPath ):
        updateNeeded = True

        draftPathComponents = GetDraftPathComponents()
        localFile = os.path.join( localPath, "Version" )
        repoFile = RepositoryUtils.GetRepositoryFilePath( os.path.join( draftPathComponents, "Version" ), False ) 
        if not os.path.exists( repoFile ):
            self.FailRender( "ERROR: Draft was not found in the Deadline Repository!" )
        if ( os.path.exists( localPath ) and os.path.isfile( localFile ) and os.path.isfile( repoFile ) ):
            if filecmp.cmp(localFile, repoFile):
                updateNeeded = False
        elif not os.path.exists( localPath ):
            self.LogInfo( "Creating local Draft directory..." )
            os.makedirs( localPath )
        if ( updateNeeded ):
            repoPath = RepositoryUtils.GetRepositoryPath( draftPathComponents, False ) 
            self.LogInfo( "Draft upgrade detected, copying updated files..." )
            for filePath in Directory.GetFiles( repoPath ):
                fileName = Path.GetFileName( filePath )
                self.LogInfo( "Copying '%s'..." % fileName )
                File.Copy( filePath, Path.Combine(localPath, fileName), True )
            self.LogInfo( "Draft update completed!" )

... some other function:

        self.DraftAutoUpdate( draftLocalPath )
        if SystemUtils.IsRunningOnWindows():
            draftLibrary = Path.Combine( draftLocalPath, "Draft.pyd" )
            draftLibrary = Path.Combine( draftLocalPath, "" )
        if not os.path.isfile( draftLibrary ):
            self.FailRender( "Could not find local Draft installation." )
            self.LogInfo( "Found Draft python module at: '%s'" % draftLibrary )
        self.DraftDirectory = draftLocalPath
        #preserve existing env vars by appending/prepending
        newPythonPath = self.DraftDirectory
        if Environment.GetEnvironmentVariable( "PYTHONPATH" ) != None:
            newPythonPath = newPythonPath + Path.PathSeparator + Environment.GetEnvironmentVariable( "PYTHONPATH" )
        newMagickPath =  self.DraftDirectory
        if Environment.GetEnvironmentVariable( "MAGICK_CONFIGURE_PATH" ) != None:
            #give locally set MAGICK path priority over the Draft one
            newMagickPath =  Environment.GetEnvironmentVariable( "MAGICK_CONFIGURE_PATH" ) + Path.PathSeparator + newMagickPath
        self.SetEnvironmentVariable( 'PYTHONPATH', newPythonPath )
        self.SetEnvironmentVariable( 'MAGICK_CONFIGURE_PATH', newMagickPath )

Sorry if that’s a bit overwhelming. It may be easier for you to do something like this:

import os

path_to_draft = 'P:\DeadlineRepository10\draft3\Windows\64bit'
os.environ['PYTHONPATH'] = path_to_draft
os.environ['MAGICK_CONFIGURE_PATH'] = path_to_draft

One reason it may not import is if the event is running in Python2 mode. The libraries are built to target very specific versions of Python (3.7 and 2.7) any other major.minor like Python 3.10 will fail to import the library.

Privacy | Site terms | Cookie preferences