Beispiel #1
0
        private static TaskSpecification ConvertExtToInt(this TaskSpecificationExt taskSpecificationExt, JobSpecification jobSpecification)
        {
            var result = new TaskSpecification
            {
                Name            = taskSpecificationExt.Name,
                MinCores        = taskSpecificationExt.MinCores,
                MaxCores        = taskSpecificationExt.MaxCores,
                WalltimeLimit   = taskSpecificationExt.WalltimeLimit,
                PlacementPolicy = taskSpecificationExt.PlacementPolicy,
                RequiredNodes   = taskSpecificationExt.RequiredNodes?
                                  .Select(s => new TaskSpecificationRequiredNode
                {
                    NodeName = s
                })
                                  .ToList(),
                Priority                = taskSpecificationExt.Priority.ConvertExtToInt(),
                Project                 = jobSpecification.Project,
                JobArrays               = taskSpecificationExt.JobArrays,
                IsExclusive             = taskSpecificationExt.IsExclusive ?? false,
                IsRerunnable            = !string.IsNullOrEmpty(taskSpecificationExt.JobArrays) || (taskSpecificationExt.IsRerunnable ?? false),
                StandardInputFile       = taskSpecificationExt.StandardInputFile,
                StandardOutputFile      = taskSpecificationExt.StandardOutputFile ?? "stdout.txt",
                StandardErrorFile       = taskSpecificationExt.StandardErrorFile ?? "stderr.txt",
                ClusterTaskSubdirectory = taskSpecificationExt.ClusterTaskSubdirectory,
                ProgressFile            = new FileSpecification
                {
                    RelativePath        = taskSpecificationExt.ProgressFile,
                    NameSpecification   = FileNameSpecification.FullName,
                    SynchronizationType = FileSynchronizationType.IncrementalAppend
                },
                LogFile = new FileSpecification
                {
                    RelativePath        = taskSpecificationExt.LogFile,
                    NameSpecification   = FileNameSpecification.FullName,
                    SynchronizationType = FileSynchronizationType.IncrementalAppend
                },
                ClusterNodeTypeId    = taskSpecificationExt.ClusterNodeTypeId.Value,
                CommandTemplateId    = taskSpecificationExt.CommandTemplateId ?? 0,
                EnvironmentVariables = taskSpecificationExt.EnvironmentVariables?
                                       .Select(s => s.ConvertExtToInt())
                                       .ToList(),
                CpuHyperThreading = taskSpecificationExt.CpuHyperThreading,
                JobSpecification  = jobSpecification,
                TaskParalizationSpecifications = taskSpecificationExt.TaskParalizationParameters?
                                                 .Select(s => s.ConvertExtToInt())
                                                 .ToList(),
                CommandParameterValues = taskSpecificationExt.TemplateParameterValues?
                                         .Select(s => s.ConvertExtToInt())
                                         .ToList(),
            };

            result.DependsOn = taskSpecificationExt.DependsOn?
                               .Select(s => new TaskDependency
            {
                TaskSpecification       = result,
                ParentTaskSpecification = s.ConvertExtToInt(jobSpecification)
            })
                               .ToList();
            return(result);
        }
Beispiel #2
0
        private static JobSpecificationExt CreateJobSpecification()
        {
            TaskSpecificationExt testTask = new TaskSpecificationExt();

            testTask.Name          = "ASBTestJob";
            testTask.MinCores      = 1;
            testTask.MaxCores      = 36;
            testTask.WalltimeLimit = 900;
            //testTask.RequiredNodes = null;
            //testTask.IsExclusive = false;
            //testTask.IsRerunnable = false;
            //testTask.StandardInputFile = null;
            testTask.StandardOutputFile = "stdout";
            testTask.StandardErrorFile  = "stderr";
            testTask.ProgressFile       = "stdprog";
            testTask.LogFile            = "stdlog";
            //testTask.ClusterTaskSubdirectory = null;
            testTask.ClusterNodeTypeId = 2;
            testTask.CommandTemplateId = 2;
            //testTask.EnvironmentVariables = new EnvironmentVariableExt[0];
            //testTask.RequiredNodes = new string[] { "r2i4n2" };
            //testTask.PlacementPolicy= "vscatter";
            //testTask.TaskParalizationParameters = new TaskParalizationParameterExt[]
            //{
            //   new TaskParalizationParameterExt
            //   {
            //       MaxCores = 24,
            //       MPIProcesses = 2,
            //       OpenMPThreads = 1
            //   }
            //};
            //testTask.DependsOn = null;
            testTask.Priority                = TaskPriorityExt.Average;
            testTask.EnvironmentVariables    = null;
            testTask.TemplateParameterValues = new CommandTemplateParameterValueExt[0];
            //testTask.JobArrays = "1-2";
            //testTask.TemplateParameterValues = new CommandTemplateParameterValueExt[] {
            //        new CommandTemplateParameterValueExt() { CommandParameterIdentifier = "inputParam", ParameterValue = "someStringParam" }
            //    };


            JobSpecificationExt testJob = new JobSpecificationExt();

            testJob.Name         = "ASBTestJob";
            testJob.Project      = "ExpTests";
            testJob.WaitingLimit = 0;
            //testJob.NotificationEmail = "*****@*****.**";
            //testJob.PhoneNumber = "999111000";
            //testJob.NotifyOnAbort = false;
            //testJob.NotifyOnFinish = false;
            //testJob.NotifyOnStart = false;
            testJob.FileTransferMethodId = 1;
            testJob.ClusterId            = 1;

            testJob.EnvironmentVariables = new EnvironmentVariableExt[0];
            testJob.Tasks = new TaskSpecificationExt[] { testTask };

            return(testJob);
        }
Beispiel #3
0
        private void ValidateTaskSpecificationInput(TaskSpecificationExt task)
        {
            if (string.IsNullOrEmpty(task.Name))
            {
                _messageBuilder.AppendLine("Task name cannot be empty.");
            }

            if (task.Name.Length > ProjectNameLength)
            {
                _messageBuilder.AppendLine($"Task name \"{task.Name}\" cannot be longer than {ProjectNameLength} characters.");
            }

            if (ContainsIllegalCharacters(task.Name))
            {
                _messageBuilder.AppendLine("Task name contains illegal characters.");
            }

            if (task.MinCores <= 0)
            {
                _messageBuilder.AppendLine($"Minimal number of cores for task \"{task.Name}\" has to be greater than 0.");
            }

            if (task.MaxCores <= 0)
            {
                _messageBuilder.AppendLine($"Maximal number of cores for task \"{task.Name}\" has to be greater than 0.");
            }

            if (task.MinCores > task.MaxCores)
            {
                _messageBuilder.AppendLine($"Minimal number of cores for task \"{task.Name}\" cannot be greater than maximal number of cores.");
            }

            if (task.WalltimeLimit <= 0)
            {
                _messageBuilder.AppendLine($"Walltime limit for task \"{task.Name}\" has to be greater than 0.");
            }

            if (task.JobArrays != null)
            {
                if (task.JobArrays == string.Empty)
                {
                    task.JobArrays = null;
                }
                else
                {
                    if (task.JobArrays.Length > 40)
                    {
                        _messageBuilder.AppendLine($"JobArrays specification for task \"{task.Name}\" cannot be longer than 40 characters.");
                    }

                    task.JobArrays = task.JobArrays.Replace(" ", string.Empty);
                    var splittedArray = task.JobArrays.Split(':');
                    if (splittedArray.Length >= 1)
                    {
                        int step     = 1;
                        var interval = splittedArray[0].Split('-');
                        if ((splittedArray.Length == 1 || (splittedArray.Length == 2 && int.TryParse(splittedArray[1], out step))) &&
                            interval.Length == 2 && int.TryParse(interval[0], out int min) && int.TryParse(interval[1], out int max))
                        {
                            if (!(min < max && min + step <= max))
                            {
                                _messageBuilder.AppendLine($"JobArrays parameter for task \"{task.Name}\" has wrong filled minimum or maximum or step value.");
                            }
                        }
                        else
                        {
                            _messageBuilder.AppendLine($"JobArrays parameter for task \"{task.Name}\" has wrong definition.");
                        }
                    }
                }
            }

            if (task.TaskParalizationParameters?.Sum(s => s.MaxCores) > task.MaxCores)
            {
                _messageBuilder.AppendLine($"TaskParalizationSpecifications count of maximal cores for task \"{task.Name}\" must be lower or equals to Maximal number of cores in task.");
            }

            if (!string.IsNullOrEmpty(task.PlacementPolicy))
            {
                if (task.PlacementPolicy.Length > 40)
                {
                    _messageBuilder.AppendLine($"Placement policy specification for task \"{task.Name}\" cannot be longer than 40 characters.");
                }
            }

            if (!string.IsNullOrEmpty(task.StandardInputFile))
            {
                if (task.StandardInputFile.Length > 30)
                {
                    _messageBuilder.AppendLine($"Standard input file for task \"{task.Name}\" cannot be longer than 30 characters.");
                }

                if (ContainsIllegalCharacters(task.StandardInputFile))
                {
                    _messageBuilder.AppendLine($"Standard input file for task \"{task.Name}\" contains illegal characters.");
                }
            }

            if (!string.IsNullOrEmpty(task.StandardOutputFile))
            {
                if (task.StandardOutputFile.Length > 30)
                {
                    _messageBuilder.AppendLine($"Standard output file for task \"{task.Name}\" cannot be longer than 30 characters.");
                }

                if (ContainsIllegalCharacters(task.StandardOutputFile))
                {
                    _messageBuilder.AppendLine($"Standard output file for task \"{task.Name}\" contains illegal characters.");
                }
            }

            if (!string.IsNullOrEmpty(task.StandardErrorFile))
            {
                if (task.StandardErrorFile.Length > 30)
                {
                    _messageBuilder.AppendLine($"Standard error file for task \"{task.Name}\" cannot be longer than 30 characters.");
                }

                if (ContainsIllegalCharacters(task.StandardErrorFile))
                {
                    _messageBuilder.AppendLine(
                        $"Standard error file for task \"{task.Name}\" contains illegal characters.");
                }
            }

            if (!string.IsNullOrEmpty(task.ProgressFile))
            {
                if (task.ProgressFile.Length > 50)
                {
                    _messageBuilder.AppendLine($"Progress file for task \"{task.Name}\" cannot be longer than 50 characters.");
                }

                if (ContainsIllegalCharactersForPath(task.ProgressFile))
                {
                    _messageBuilder.AppendLine($"Progress file for task \"{task.Name}\" contains illegal characters.");
                }
            }
            else
            {
                _messageBuilder.AppendLine($"Progress file for task \"{task.Name}\" is not set.");
            }

            if (!string.IsNullOrEmpty(task.LogFile))
            {
                if (task.LogFile.Length > 50)
                {
                    _messageBuilder.AppendLine($"Log file for task \"{task.Name}\" cannot be longer than 50 characters.");
                }
                if (ContainsIllegalCharactersForPath(task.LogFile))
                {
                    _messageBuilder.AppendLine($"Log file for task \"{task.Name}\" contains illegal characters.");
                }
            }
            else
            {
                _messageBuilder.AppendLine($"Log file for task \"{task.Name}\" is not set.");
            }

            if (!string.IsNullOrEmpty(task.ClusterTaskSubdirectory))
            {
                if (task.ClusterTaskSubdirectory.Length > 50)
                {
                    _messageBuilder.AppendLine($"Cluster task subdirectory for task \"{task.Name}\" cannot be longer than 50 characters.");
                }

                if (ContainsIllegalCharacters(task.ClusterTaskSubdirectory))
                {
                    _messageBuilder.AppendLine($"Cluster task subdirectory for task \"{task.Name}\" contains illegal characters.");
                }
            }

            if (task.RequiredNodes != null)
            {
                foreach (var requiredNode in task.RequiredNodes)
                {
                    if (requiredNode.Length > 40)
                    {
                        _messageBuilder.AppendLine($"Required node \"{requiredNode}\" specification for task \"{task.Name}\" cannot be longer than 40 characters.");
                    }
                    if (ContainsIllegalCharacters(requiredNode))
                    {
                        _messageBuilder.AppendLine($"Required node \"{requiredNode}\" specification for task \"{task.Name}\" contains illegal characters.");
                    }
                }
            }

            if (task.EnvironmentVariables != null)
            {
                foreach (EnvironmentVariableExt variable in task.EnvironmentVariables)
                {
                    if (string.IsNullOrEmpty(variable.Name))
                    {
                        _messageBuilder.AppendLine($"Environment variable's name for task \"{task.Name}\" cannot be empty. ({variable.Name} = {variable.Value})");
                    }
                }
            }
        }