It appears that when using the standalone python api and calling the method
results = dl.Jobs.GetJobsInStates(['Active', 'Pending']))
from within a custom event during the def OnJobSubmitted(self, job):
event…the results from the above method will not include the currently active job you’ve just submitted… not sure why this would be.
Have you tried the same using the Scripting API?
No reason to use standalone api from inside an event plugin.
In short we have tools we have written that run outside the custom events and also during events. It would be redundant to rewrite and manage two code bases that do the same thing. The best solution was to have the custom deadline event trigger the standalone python code in this case.
Then we are only managing one code. Since that code is able to be run by an artist on their desktops and inside of other applications. Hopefully that makes sense.
OnJobSubmitted invoked just before a Job is flagged as submitted in the database, this way you can make changes to the job before it’s available to be picked up by Workers. That’s why GetJobsInStates doesn’t include the job you’re in the process of submitting.
1 Like
I figured that may be the case.
I noticed even if I call GetJobs instead of GetJobsInStates, neither of them return the job I’m trying to modify.
Are there any work arounds for this issue? Is there a method in which I can actually retrieve the job and modify it with the stand alone api from within a custom deadline event?
Well in the OnJobSubmitted
handler you get the job as argument, so you can treat it together with the ones from GetJobs
.
GetJobs does not include the job just submitted. that is the problem im encoutering. None of the methods in the standalone api actually give me the job in return.
Not GetJobs, but the handler gets the current one
def OnJobSubmitted(self, job)
- isn’t the second argument the job that you are missing?
I see what you are saying. however if i use the job supplied from OnJobSubmitted(self, job)
and try to modify and update it using the Standalone Python api, it does not work. It says the job does not exist. That is where this breaks. I need to modify the job with the standalone python api from a Custom Deadline Event.
Ok, I see now. Yeah not sure what to recommend.
An outside process cannot have OnJobSubmitted, so I would keep this logic using the Scripting API.
Then some of the shared logic can be extracted into a library used by both places. The data structures in the scripting and standalone apis are quite different though, so that limits the amount that can be easily shared.
Could you tell me what code you’re trying to run? And why are you using the standalone python api from inside an event plugin, you can instead use the internal API that’s used for our other plugins. (Application plugins, event plugins, that sort of thing)
Though if you’ve just got the names mixed up that’s very reasonable.
He said he wants to reuse the same code inside an event plugin, and in user-facing instruments.
it still feels weird to use the standalone api from a plugin…
Moreover, you can still use the scripting api from outside if you do deadlinecommand -ExecuteScript scriptname.py
.
I’d be more than glad to go over what im doing with you. It would be something I’d prefer to setup and call and visually go over it with you to better explain what we are doing. It will make more sense for you.
Cut a ticket to us at awsthinkbox.zendesk.com and we’ll get a time for that figured out.
1 Like