protected override TaskProcessResult RunExternalTaskProcess(ITask task, TaskExecutionSettings settings)
        {
            // Get the one and only asset/file associated with this particular task
            // (the job splitter will have created a task for each video file passed in).
            var inputFile = task.RequiredFiles[0].Name;

            // As this example just gets ffmpeg to rewrite the input file, we will
            // use the same file extension as the input file.
            // The output file will be written as {TaskId}.{extension} e.g. 1.mp4
            var outputFile = string.Concat(task.TaskId.ToString(), Path.GetExtension(inputFile));

            // Add the name of the application exe to the drive letter/path of the mounted VHD.
            var externalProgramPath = ExecutablePath("ffmpeg.exe");

            // We aren't going to tell ffmepg to do any transcoding or compression or anything,
            // but you could imagine that user defined settings could be passed in with the job
            // when it was submitted.  The job splitter could then set these in turn against each
            // of the tasks it created.  Then the task processor could use those settings to
            // set up particular arguments for ffmpeg.

            //NOTE: usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...
            var externalProgramArguments = String.Format("-i \"{0}\" \"{1}\"", inputFile, outputFile);

            // Run ffmpeg
            var ffmpegResult = new ExternalProcess
            {
                CommandPath = externalProgramPath,
                Arguments = externalProgramArguments,
                WorkingDirectory = LocalStoragePath,
            }.Run();

            // Return the output file that has been created.
            return TaskProcessResult.FromExternalProcessResult(ffmpegResult, outputFile);
        }
        protected override TaskProcessResult RunExternalTaskProcess(ITask task, TaskExecutionSettings settings)
        {
            var parameters = task.Parameters;
            var outFile    = String.Format("{0}_{1}.txt", "out", task.TaskId);

            var process = new ExternalProcess {
                CommandPath      = ExecutablePath(@"ModelBatchTest/Model.exe"),
                Arguments        = String.Format("{0} {1} {2}", parameters["l0"], parameters["omega"], outFile),
                WorkingDirectory = LocalStoragePath
            };

            try
            {
                ExternalProcessResult processOutput = process.Run();
                return(TaskProcessResult.FromExternalProcessResult(processOutput, outFile));
            }
            catch (ExternalProcessException ex)
            {
                string outputInfo = "No program output";
                if (!string.IsNullOrEmpty(ex.StandardError) || !string.IsNullOrEmpty(ex.StandardOutput))
                {
                    outputInfo = Environment.NewLine + "stderr: " + ex.StandardError + Environment.NewLine + "stdout: " + ex.StandardOutput;
                }

                Log.Error("Failed to invoke command {0} {1}: exit code was {2}.  {3}", ex.CommandPath, ex.Arguments, ex.ExitCode, outputInfo);
            }
            catch (Exception ex)
            {
                Log.Error("Error in task processor: {0}", ex.ToString());
            }
            return(new TaskProcessResult {
                Success = TaskProcessSuccess.RetryableFailure
            });
        }
 protected override JobResult RunExternalMergeProcess(ITask mergeTask, TaskExecutionSettings settings)
 {
     // We're not doing any merging in this case so just return an empty file.
     var outputFile = LocalPath("JobOutput.txt");
     File.WriteAllText(outputFile, String.Empty);
     return new JobResult { OutputFile = outputFile };
 }
        protected override JobResult RunExternalMergeProcess(ITask mergeTask, TaskExecutionSettings settings)
        {
            var inputFilter = string.Format(CultureInfo.InvariantCulture, "{0}*", "out");
            var inputFiles  = CollectFiles(LocalStoragePath, inputFilter);

            var completionFile = LocalPath("results.zip");

            var result = ZipOutputs(inputFiles, completionFile);

            return(result);
        }
Beispiel #5
0
        /// <summary>
        /// Executes the external process for processing the task
        /// </summary>
        /// <param name="task">The task to be processed.</param>
        /// <param name="settings">Contains information about the processing request.</param>
        /// <returns>The result of task processing.</returns>
        protected override TaskProcessResult RunExternalTaskProcess(ITask task, TaskExecutionSettings settings)
        {
            var taskParameters = BlenderParameters.FromTask(task);
            var initialFiles   = CollectFiles(LocalStoragePath);

            if (!taskParameters.Valid)
            {
                Log.Error(taskParameters.ErrorText);
                return(new TaskProcessResult
                {
                    Success = TaskProcessSuccess.PermanentFailure,
                    ProcessorOutput = "Parameter error: " + taskParameters.ErrorText,
                });
            }

            var inputFile  = LocalPath(taskParameters.JobFile);
            var outputFile = LocalPath(taskParameters.Prefix);

            string externalProcessPath = ExecutablePath(RenderPath);
            string externalProcessArgs = string.Format(CultureInfo.InvariantCulture, RenderArgs, inputFile, outputFile, taskParameters.Format, task.TaskIndex);

            Log.Info("Calling '{0}' with Args '{1}' for Task '{2}' / Job '{3}' .", RenderPath, externalProcessArgs, task.TaskId, task.JobId);
            var processResult = ExecuteProcess(externalProcessPath, externalProcessArgs);

            if (processResult == null)
            {
                return(new TaskProcessResult {
                    Success = TaskProcessSuccess.RetryableFailure
                });
            }

            var newFiles = GetNewFiles(initialFiles, LocalStoragePath);
            var result   = TaskProcessResult.FromExternalProcessResult(processResult, newFiles);

            var thumbnail = CreateThumbnail(task, newFiles);

            if (!string.IsNullOrEmpty(thumbnail))
            {
                var taskPreview = new TaskOutputFile
                {
                    FileName = thumbnail,
                    Kind     = TaskOutputFileKind.Preview
                };
                result.OutputFiles.Add(taskPreview);
            }
            return(result);
        }
Beispiel #6
0
        /// <summary>
        /// Executes the external process for processing the task
        /// </summary>
        /// <param name="task">The task to be processed.</param>
        /// <param name="settings">Contains information about the processing request.</param>
        /// <returns>The result of task processing.</returns>
        protected override TaskProcessResult RunExternalTaskProcess(ITask task, TaskExecutionSettings settings)
        {
            var process = new ExternalProcess
            {
                CommandPath = ExecutablePath(@"TitanSpikeClusterer.exe"),
                Arguments   = string.Format("ClusterWorkerBlockRange {8} {0} {1} {2} {3} {4} {5} {6} {7}",
                                            task.Parameters["HostName"],
                                            task.Parameters["DataFileName"],
                                            task.Parameters["NumChannels"],
                                            task.Parameters["OutFileName"],
                                            task.Parameters["MinTemp"],
                                            task.Parameters["MaxTemp"],
                                            task.Parameters["FirstBlock"],
                                            task.Parameters["NumBlocks"],
                                            LocalPath("Clusterer")),
                WorkingDirectory = LocalStoragePath
            };

            try
            {
                ExternalProcessResult processOutput = process.Run();
                return(new TaskProcessResult {
                    Success = TaskProcessSuccess.Succeeded
                });
            }
            catch (ExternalProcessException ex)
            {
                string outputInfo = "No program output";
                if (!string.IsNullOrEmpty(ex.StandardError) || !string.IsNullOrEmpty(ex.StandardOutput))
                {
                    outputInfo = Environment.NewLine + "stderr: " + ex.StandardError + Environment.NewLine + "stdout: " + ex.StandardOutput;
                }

                Log.Error("Failed to invoke command {0} {1}: exit code was {2}.  {3}", ex.CommandPath, ex.Arguments, ex.ExitCode, outputInfo);
            }
            catch (Exception ex)
            {
                Log.Error("Error in task processor: {0}", ex.ToString());
            }

            return(new TaskProcessResult {
                Success = TaskProcessSuccess.RetryableFailure
            });
        }
Beispiel #7
0
        /// <summary>
        /// Method to execute the external processing for merging the tasks output into job output
        /// </summary>
        /// <param name="mergeTask">The merge task.</param>
        /// <param name="settings">Contains information about the processing request.</param>
        /// <returns>The job outputs resulting from the merge process.</returns>
        protected override JobResult RunExternalMergeProcess(ITask mergeTask, TaskExecutionSettings settings)
        {
            var taskParameters = BlenderParameters.FromTask(mergeTask);

            if (!taskParameters.Valid)
            {
                Log.Error(taskParameters.ErrorText);
                throw new InvalidParameterException(taskParameters.ErrorText);
            }

            var inputFilter = string.Format(CultureInfo.InvariantCulture, "{0}*", taskParameters.Prefix);
            var inputFiles  = CollectFiles(LocalStoragePath, inputFilter);



            var outputFile = LocalPath("output.zip");
            var result     = ZipOutputs(inputFiles, outputFile);

            result.PreviewFile = CreateThumbnail(mergeTask, inputFiles.ToArray());

            return(result);
        }
Beispiel #8
0
 /// <summary>
 /// Method to execute the external processing for merging the tasks output into job output
 /// </summary>
 /// <param name="mergeTask">The merge task.</param>
 /// <param name="settings">Contains information about the processing request.</param>
 /// <returns>The job outputs resulting from the merge process.</returns>
 protected override JobResult RunExternalMergeProcess(ITask mergeTask, TaskExecutionSettings settings)
 {
     return(new JobResult());
 }