Skip to content

Commit ff1fe90

Browse files
Avoid relying on NeedsReport status for experiments
Updates the places which match on this status to instead use the condition which produces needs-report (i.e., completed == expected total).
1 parent 61d7619 commit ff1fe90

File tree

2 files changed

+29
-20
lines changed

2 files changed

+29
-20
lines changed

src/cli.rs

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,6 @@ impl Crater {
506506
);
507507
workspace.purge_all_build_dirs()?;
508508
res?;
509-
510-
experiment.set_status(&db, Status::NeedsReport)?;
511509
} else {
512510
bail!("missing experiment {}", ex.0);
513511
}
@@ -522,18 +520,18 @@ impl Crater {
522520
let db = Database::open()?;
523521

524522
if let Some(mut experiment) = Experiment::get(&db, &ex.0)? {
525-
// Update the status
526-
match (experiment.status, force) {
527-
(Status::NeedsReport, _) | (Status::ReportFailed, _) | (_, true) => {
528-
experiment.set_status(&db, Status::GeneratingReport)?;
529-
}
530-
(other, false) => bail!(
531-
"can't generate the report of an experiment with status {} \
523+
let (completed, all) = experiment.raw_progress(&db)?;
524+
if !force && completed != all {
525+
bail!(
526+
"can't generate the report of an incomplete experiment: {}/{} results \
532527
(use --force to override)",
533-
other
534-
),
528+
completed,
529+
all,
530+
);
535531
}
536532

533+
experiment.set_status(&db, Status::GeneratingReport)?;
534+
537535
let result_db = DatabaseDB::new(&db);
538536
let res = report::gen(
539537
&result_db,
@@ -564,18 +562,18 @@ impl Crater {
564562
let db = Database::open()?;
565563

566564
if let Some(mut experiment) = Experiment::get(&db, &ex.0)? {
567-
// Update the status
568-
match (experiment.status, force) {
569-
(Status::NeedsReport, _) | (Status::ReportFailed, _) | (_, true) => {
570-
experiment.set_status(&db, Status::GeneratingReport)?;
571-
}
572-
(other, false) => bail!(
573-
"can't publish the report of an experiment with status {} \
565+
let (completed, all) = experiment.raw_progress(&db)?;
566+
if !force && completed != all {
567+
bail!(
568+
"can't publish the report of an incomplete experiment: {}/{} results \
574569
(use --force to override)",
575-
other
576-
),
570+
completed,
571+
all,
572+
);
577573
}
578574

575+
experiment.set_status(&db, Status::GeneratingReport)?;
576+
579577
let result_db = DatabaseDB::new(&db);
580578
let client = report::get_client_for_bucket(&s3_prefix.bucket)?;
581579

src/experiments.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,17 @@ impl Experiment {
305305
pub fn ready_for_report(db: &Database) -> Fallible<Option<Experiment>> {
306306
let unfinished = Self::unfinished(db)?;
307307
for ex in unfinished {
308+
if ex.status == Status::ReportFailed {
309+
// Skip experiments whose report failed to generate. This avoids
310+
// constantly retrying reports (and posting a message each time
311+
// about the attempt); the retry-report command can override the
312+
// failure state. In practice we rarely *fail* to generate
313+
// reports in a clean way (instead OOMing or panicking, in which
314+
// case it is fine to automatically retry the report, as we've
315+
// not posted anything on GitHub -- it may be a problem from a
316+
// performance perspective but no more than that).
317+
continue;
318+
}
308319
let (completed, all) = ex.raw_progress(db)?;
309320
if completed == all {
310321
return Ok(Some(ex));

0 commit comments

Comments
 (0)