public bool AbortJob(Job j) { //Try and find a job in the pending jobs dict that matches j foreach (var pendingJobPair in PendingJobs) { if (pendingJobPair.Value == j) { return(Service.CancelJob(pendingJobPair.Key)); } } return(false); }
public void EnqueueJob(Job j) { // TODO: ZIP the job instead of using placeholder try { j.Status = Job.StatusEnum.ZippingPackage; string zipFilename = ZipWorkingDirectory(j.WorkingDirectory); j.Status = Job.StatusEnum.UploadPackage; string zipArtifactId = ""; using (var fileStream = File.OpenRead(zipFilename)) { zipArtifactId = Service.UploadArtifact(fileStream); } var runCommand = ""; if (File.Exists(Path.Combine(j.WorkingDirectory, "testbench_manifest.json"))) { // TODO: How do we want to specify which Python to use? //runCommand = "\"" + META.VersionInfo.PythonVEnvExe + "\"" + runCommand = "python" + " -m testbenchexecutor --detailed-errors testbench_manifest.json"; } else { runCommand = j.RunCommand; } var relativeWorkingDirectory = new DirectoryInfo(j.WorkingDirectory).Name; var labels = j.Labels != null ? j.Labels : ""; var newJobId = Service.CreateJob(runCommand, relativeWorkingDirectory, zipArtifactId, labels); PendingJobs.Add(newJobId, j); j.Status = Job.StatusEnum.PostedToServer; } catch (ZipFailedException e) { j.Status = Job.StatusEnum.Failed; } catch (RemoteExecutionService.RequestFailedException e) { j.Status = Job.StatusEnum.FailedToUploadServer; } catch (Exception) { j.Status = Job.StatusEnum.FailedToUploadServer; } }