/// <summary> /// Distributes the task over HPC /// </summary> /// <param name="distributableObject">distributable task</param> public override void Distribute(IDistributable distributableObject) { this.Name = distributableObject.JobName; ClusterSubmitter.SubmitAndWait(this, distributableObject, MaxSubmitAfterTasksFail, OnSubmitted); CopyResults.AddRange(ArgumentCollection.EnumerateValuesOfTypeFromParsable <OutputFile>(distributableObject).Select(file => file.ToString()).Distinct().Where(s => s != "-")); if (CopyResults.Count > 0) { HpcLib.CopyFiles(CopyResults, ExternalRemoteDirectoryName, Environment.CurrentDirectory); } }
private static void SubmitInternal(ClusterSubmitterArgs clusterArgs, IDistributable distributableObj) { lock (_submitterLockObj) // for now, just let one thread submit at a time. { if (string.IsNullOrEmpty(clusterArgs.Name)) { clusterArgs.Name = distributableObj.JobName; } CopyExes(clusterArgs); clusterArgs.StdErrDirName = CreateUniqueDirectory(clusterArgs.ExternalRemoteDirectoryName, "Stderr", distributableObj.JobName); clusterArgs.StdOutDirName = CreateUniqueDirectory(clusterArgs.ExternalRemoteDirectoryName, "Stdout", distributableObj.JobName); if (clusterArgs.CopyInputFiles != null) { if (!(distributableObj is DistributableWrapper)) { clusterArgs.CopyInputFiles.AddRange(ArgumentCollection.EnumerateValuesOfTypeFromParsable <InputFile>(distributableObj).Select(file => file.ToString())); } if (clusterArgs.CopyInputFiles.Count > 0) { CopyInputFiles(clusterArgs.CopyInputFiles, clusterArgs.ExternalRemoteDirectoryName); } } using (ParallelOptionsScope.Suspend()) { switch (clusterArgs.Version) { case 3: SubmitViaAPI3(clusterArgs, distributableObj); break; default: throw new NotSupportedException(string.Format("Cluster version {0} is not supported.", clusterArgs.Version)); } } Console.WriteLine(Resource.Processed_job, clusterArgs.Cluster, clusterArgs.ExternalRemoteDirectoryName); Console.WriteLine(Resource.Writing_log_file); HpcLibSettings.TryWriteToLog(clusterArgs); Console.WriteLine(Resource.Done); } return; }
public void ValidateEnumerateValuesOfTypeFromParsable() { int num = 5; object obj = num; IEnumerable <int> integers = ArgumentCollection.EnumerateValuesOfTypeFromParsable <int>(obj); Assert.AreEqual(5, integers.ElementAt(0)); Assert.AreEqual(null, ArgumentCollection.EnumerateValuesOfTypeFromParsable <int>(null)); OutputFile outFile = new OutputFile(); outFile.FullName = "Outfile"; obj = outFile; IEnumerable <OutputFile> outFiles = ArgumentCollection.EnumerateValuesOfTypeFromParsable <OutputFile>(obj); Assert.AreEqual("Outfile", outFiles.ElementAt(0).FullName); IEnumerable <ParsableFile> parsableFiles = ArgumentCollection.EnumerateValuesOfTypeFromParsable <ParsableFile>(obj); Assert.AreEqual("Outfile", parsableFiles.ElementAt(0).FullName); }