Skip to content

Commit

Permalink
Make scheduler really skip invalid sessions (#163)
Browse files Browse the repository at this point in the history
The scheduler expected that invalid sessions would be flagged with a
`blockingErrors` property, but that property was never set. The schedule
command now sets a `blockingError` flag, and the scheduler is slightly more
resilient on invalid sessions.
  • Loading branch information
tidoust authored Sep 6, 2024
1 parent 028dc89 commit 9b5ecf5
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
47 changes: 47 additions & 0 deletions test/check-invalid-scheduling.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import * as assert from 'node:assert';
import { initTestEnv } from './init-test-env.mjs';
import { getEnvKey, setEnvKey } from '../tools/lib/envkeys.mjs';
import { fetchProject } from '../tools/lib/project.mjs';
import { validateGrid } from '../tools/lib/validate.mjs';
import { suggestSchedule } from '../tools/lib/schedule.mjs';
import { convertProjectToHTML } from '../tools/lib/project2html.mjs';

async function fetchTestProject() {
const project = await fetchProject(
await getEnvKey('PROJECT_OWNER'),
await getEnvKey('PROJECT_NUMBER'));
return project;
}

function stripDetails(errors) {
return errors.map(err => {
if (err.details) {
delete err.details;
}
return err;
});
}

describe('When given invalid sessions, the scheduler', function () {
before(function () {
initTestEnv();
setEnvKey('PROJECT_NUMBER', 'session-validation');
setEnvKey('ISSUE_TEMPLATE', 'test/data/template-breakout.yml');
});

it('skips invalid sessions', async function () {
const project = await fetchTestProject();
project.sessions = project.sessions.filter(s => [1, 2, 3].includes(s.number));
await validateGrid(project);

const session1 = project.sessions.find(s => s.number === 1);
const session2 = project.sessions.find(s => s.number === 2);
const session3 = project.sessions.find(s => s.number === 3);
session2.blockingError = true;
suggestSchedule(project, { seed: 'schedule' });

assert.deepStrictEqual(session1.meetings, undefined);
assert.deepStrictEqual(session2.meetings, undefined);
assert.deepStrictEqual(session3.meetings?.length, 1);
});
});
2 changes: 1 addition & 1 deletion test/check-tpac-scheduling.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as assert from 'node:assert';
import { readFile, writeFile } from 'node:fs/promises';
import { initTestEnv } from './init-test-env.mjs';
import { getEnvKey, setEnvKey } from '../tools/lib/envkeys.mjs';
import { fetchProject, convertProjectToJSON } from '../tools/lib/project.mjs';
import { fetchProject } from '../tools/lib/project.mjs';
import { validateSession, validateGrid } from '../tools/lib/validate.mjs';
import { suggestSchedule } from '../tools/lib/schedule.mjs';
import { convertProjectToHTML } from '../tools/lib/project2html.mjs';
Expand Down
5 changes: 2 additions & 3 deletions test/check-vip-room.mjs
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as assert from 'node:assert';
import { readFile, writeFile } from 'node:fs/promises';
import { initTestEnv } from './init-test-env.mjs';
import { getEnvKey, setEnvKey } from '../tools/lib/envkeys.mjs';
import { fetchProject, convertProjectToJSON } from '../tools/lib/project.mjs';
import { validateSession, validateGrid } from '../tools/lib/validate.mjs';
import { fetchProject } from '../tools/lib/project.mjs';
import { validateGrid } from '../tools/lib/validate.mjs';
import { suggestSchedule } from '../tools/lib/schedule.mjs';
import { convertProjectToHTML } from '../tools/lib/project2html.mjs';

Expand Down
3 changes: 3 additions & 0 deletions tools/commands/schedule.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ export default async function (project, options) {
error.type !== 'irc');
const validSessions = project.sessions.filter(s =>
!errors.find(error => error.number === s.number));
project.sessions
.filter(s => errors.find(error => error.number === s.number))
.forEach(s => s.blockingError = true);
console.warn(`- found ${validSessions.length} valid sessions among them: ${validSessions.map(s => s.number).join(', ')}`);
console.warn(`Validate sessions... done`);

Expand Down
4 changes: 2 additions & 2 deletions tools/lib/schedule.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export function suggestSchedule(project, { seed }) {

// Filter out invalid sessions
sessions = sessions.filter(session =>
!session.blockingErrors ||
(session.blockingErrors.length === 0));
session.description &&
!session.blockingError);

// Initialize the list of tracks
// Note: for the purpose of scheduling, a "_plenary" track gets artificially
Expand Down

0 comments on commit 9b5ecf5

Please sign in to comment.