Skip to content
Snippets Groups Projects
Commit ebc7ecb9 authored by Dillenn Terumalai's avatar Dillenn Terumalai :speech_balloon:
Browse files

fix: Fixed bug #1 and #2

parent 25773229
Branches
Tags v1.1.2
No related merge requests found
Pipeline #2646 passed
......@@ -12,6 +12,7 @@ use Dterumal\LaravelCluster\Events\JobCompleted;
use Dterumal\LaravelCluster\Events\JobFailed;
use Dterumal\LaravelCluster\Events\JobQueued;
use Dterumal\LaravelCluster\Storage\JobModel;
use Illuminate\Support\Carbon;
use Illuminate\Support\Collection;
use Illuminate\Support\Str;
use Symfony\Component\Process\Exception\ProcessFailedException;
......@@ -70,9 +71,12 @@ class SlurmConnector implements ClusterInterface
case 'CANCELLED':
$event = 'cancelled_at';
break;
case 'FAILED' || 'TIMEOUT' || 'DEADLINE' || 'REVOKED':
case 'FAILED':
$event = 'failed_at';
break;
case 'TIMEOUT':
$event = 'timed_out_at';
break;
default:
$event = null;
break;
......@@ -96,6 +100,7 @@ class SlurmConnector implements ClusterInterface
$collection->each(function ($job) {
$clusterJob = JobModel::findOrFail($job['id']);
event(new JobQueued($clusterJob, $job['queued_at']));
if (array_key_exists('event', $job)) {
if ($job['event'] === 'completed_at') {
event(new JobCompleted($clusterJob, $job['datetime']));
} elseif ($job['event'] === 'failed_at') {
......@@ -103,6 +108,7 @@ class SlurmConnector implements ClusterInterface
} elseif ($job['event'] === 'cancelled_at') {
event(new JobCancelled($clusterJob, $job['datetime']));
}
}
});
}
......@@ -212,6 +218,8 @@ class SlurmConnector implements ClusterInterface
*/
public function run($job): void
{
$job->created_at = Carbon::now();
// We format the array of commands to a string with newlines between commands
$content = implode("\n", $job->handle());
......@@ -259,7 +267,8 @@ EOF",
/**
* @inheritDoc
*/
public function monitorStatus(): void {
public function monitorStatus(): void
{
$output = $this->execute([
'scontrol',
'ping'
......
......@@ -30,7 +30,7 @@ class DatabaseJobRepository implements JobRepository
'std_out_path' => "{$job->exportPath}/{$job->name}_{$job->id}.out",
'std_err_path' => "{$job->exportPath}/{$job->name}_{$job->id}.err",
'export_path' => $job->exportPath,
'created_at' => Carbon::now()
'created_at' => $job->created_at
]);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment