NavigationUser login |
End Task PipelineIs there any way from within a task to tell the server to halt the currently executing task pipeline? E.g. If I was to create a task and add it as the first task in the task pipeline and all this task did was to check certain pre-requisites required for the execution of the task pipeline. If these checks fail is there any way I can just abort the whole task pipeline without processing any items? Basically, I see some task pipelines that rely on certain things being set, e.g. this is a PLACEHOLDER load or it relies on a certain resource being in place etc. I think it would be good if we could add a task at the start of the pipeline that would check for the existence of the pre-requisites and abort the task if they were not in place as they should be. It would be even better if this could be preformed before the batch preparation. By adrianc at Jun 26 2008 - 02:09 | Using Vamosa Content Migrator | login or register to post comments
Re: End Task PipelineHi, There is an option on the job in the client to abort the currently running job, its not instantaneous, but it does eventually stop it. However not sure if this is accessible from the code. Probably the best solution would be to perform your checks in the first script and then set a project property to say that the data is valid, and then in your scripts check this flag to see if it is safe to run. Another option may be to see if you can get the project property in a query and use this as your batch prepare query as it will return no objects. Stewart. Another optionAnother option would be to have a task that is used to check the pre-requisites required for the execution of a set of tasks are in place, and if so execute another task pipeline. If the pre-requisites are not met you don't start the additonal task pipeline. Ross If...As you can see from the comments above... there's a lot of IF-ing going on, and there in lies your answer. In the past this problem has always been solved, by "gate-ing" a set of dependent tasks by having an IF-statement at the top of a Python code that checks for a set of pre-conditions to exist before the body of the script is executed. However, these pre-conditions have been stored as metadata on content descriptors. Regards, That's fine but you can'tThat's fine but you can't really store in metadata that the content project was supposed to be run against PLACEHOLDER instead of CONTENT or that a specific resource is supposed to exist in the project, plus it's going to take a while for the script to finish even if it's just checking some value and not doing anything if it isn't set. I understand that I can set a value in metadata and check this either in a batch prepare query or in the task definitions. I just think it would be a much cleaner solution to be able to define certain pre-requisites that would stop a job instantly or better yet, stop it from starting. Re: That's fine but you can'tHi, Looks like for the solution you are looking for, Ross's suggestion looks like the best. One per project script that determines what to run then uses executeNextPipeline() to kick off your run. Stewart. That sounds like something IThat sounds like something I could work with. I've had a look through the API and managed to find the pipelineRunner interface which has an executePipeline method, is that the method you were meaning? Are there any examples of this kind of thing being used anywhere? Don't do this...Executing pipelines from within pipelines is not supported. And will probably through an error because the project will be 'locked' anyway. Regards, Re Don't do this...You can execute a pipeline in another project just fine, as long as you make sure that calling the executePipeline method is the last thing you do in the calling pipeline. I haven't seen any abonrmal behaviour of this at all. If you try to get too complicated with it you may get yourself tied in knots, but keep it simple and it works fine. As Ijonas states though, you cannot execute a pipeline in the current project. The way we have done this before is to have a control project and this would kick of the required pipeline in another project. Stewart. That's good to know. ThisThat's good to know. This isn't something that will be going anywhere near a live environment any time soon. I'm really just looking for something to experiment with locally in the vague hope that I might be able to give some input towards improving the best practices and also to get a better idea of how eveything fits together. That's easyInstantly stopping a job from starting is easy... Merely define a query that defines your pre-condition and set that as your batch prepare query. Job done. If your query fails to return any results, then the task pipeline will return pretty much instantly. Regards, Can I access projectCan I access project properties and resources from within a query?
Why would you want to ?Why would you want to ? Explain... Examples... Regards, The issue in my originalThe issue in my original post was to find a way of checking pre-requisites and stopping the job from processing if they aren't in place and as I mentioned back then... "some task pipelines that rely on certain things being set, e.g. this is a PLACEHOLDER load or it relies on a certain resource being in place etc" Hacktastic.How's this for a hack.... Batch Prepare is inserted in any TaskPipelines that uses PER_OBJECT task... so what if you could control the query that Batch Prepare uses to select the objects that we're being processed in the subsequent PER_OBJECT tasks. Well you can... have a PER_PROJECT task at the start of your pipeline which functions as "the gate". In this task you can make all the checks you like using resources and properties or whatever else you can dream of... If any of these checks fail, then you set the batch.query project property to some kind of "NULL QUERY", i.e. a valid query but one that produces no result set. That way all your subsequent tasks will operate on 0 objects. Let me know if this works. Regards, Set to countSetting the batch prepare query to use one of the 'count' queries available will always return a batch size of 0. This should work nicely with the 'hack' Ijonas described :) Ross |
Hi Adrian, I'm not sure if
Hi Adrian,
I'm not sure if this is what you mean, but something like this:
if trimResource == None:
raise "**Warning** No Trim Comments Map Resource Found - No metadata Set"
else:
trimComments = trimResource.getContents()
If the resource is not in place then it would just raise that warning but, granted, it wouldnt be performed before the batch preparation.
Are you enquiring if there is a function call to abort the current job?
Cheers,
Grant