Skip to content

Commit f154fea

Browse files
authored
Merge pull request #2864 from stan-dev/dependencies-dist-tests
Conditionally run distribution tests
2 parents 8d3845e + ff81abd commit f154fea

142 files changed

Lines changed: 480 additions & 152 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Jenkinsfile

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def runTests(String testPath, boolean jumbo = false) {
1414
}
1515

1616
def skipRemainingStages = false
17-
17+
def changedDistributionTests = []
1818
def utils = new org.stan.Utils()
1919

2020
def isBranch(String b) { env.BRANCH_NAME == b }
@@ -38,11 +38,12 @@ pipeline {
3838
booleanParam(defaultValue: false, name: 'withRowVector', description: 'Run additional distribution tests on RowVectors (takes 5x as long)')
3939
booleanParam(defaultValue: false, name: 'disableJumbo', description: 'Disable Jumbo tests. This takes longer and should only be used for debugging if it is believed that the jumbo tests are causing failures.')
4040
booleanParam(defaultValue: false, name: 'optimizeUnitTests', description: 'Use O=3 for unit tests (takex ~3x as long)')
41+
booleanParam(defaultValue: false, name: 'runAllDistributions', description: 'Run all distribution tests, even ones which are unchanged compared to develop')
4142
}
4243
options {
4344
skipDefaultCheckout()
4445
preserveStashes(buildCount: 7)
45-
parallelsAlwaysFailFast()
46+
parallelsAlwaysFailFast()
4647
}
4748
environment {
4849
STAN_NUM_THREADS = 4
@@ -123,7 +124,7 @@ pipeline {
123124
}
124125
}
125126
}
126-
}
127+
}
127128

128129
stage('Linting & Doc checks') {
129130
agent {
@@ -445,6 +446,30 @@ pipeline {
445446
}
446447
}
447448

449+
stage ('Discover changed distribution tests') {
450+
when {
451+
expression {
452+
!skipRemainingStages
453+
}
454+
}
455+
agent {
456+
docker {
457+
image 'stanorg/ci:gpu-cpp17'
458+
label 'linux'
459+
}
460+
}
461+
steps {
462+
script {
463+
retry(3) { checkout scm }
464+
if (params.runAllDistributions || isBranch('develop') || isBranch('master')) {
465+
changedDistributionTests = sh(script:"python3 test/prob/getDependencies.py --pretend-all", returnStdout:true).trim().split('\n').toList()
466+
} else {
467+
changedDistributionTests = sh(script:"python3 test/prob/getDependencies.py", returnStdout:true).trim().split('\n').toList()
468+
}
469+
}
470+
}
471+
}
472+
448473
stage ('Distribution tests') {
449474
when {
450475
expression {
@@ -454,10 +479,8 @@ pipeline {
454479
agent { label 'linux && docker' }
455480
steps {
456481
script {
457-
unstash 'MathSetup'
458482
def tests = [:]
459-
def files = sh(script:"find test/prob/* -type d", returnStdout:true).trim().split('\n')
460-
for (f in files.toList().collate(8)) {
483+
for (f in changedDistributionTests.collate(24)) {
461484
def names = f.join(" ")
462485
tests["Distribution Tests: ${names}"] = { node ("linux && docker") {
463486
docker.image('stanorg/ci:gpu-cpp17').inside {

test/prob/bernoulli/bernoulli_ccdf_log_test.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Arguments: Ints, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/bernoulli_ccdf_log.hpp>
3+
#include <stan/math/prim/fun/constants.hpp>
4+
#include <stan/math/prim/fun/log.hpp>
35

46
using stan::math::var;
57
using std::numeric_limits;

test/prob/bernoulli/bernoulli_cdf_log_test.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Arguments: Ints, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/bernoulli_cdf_log.hpp>
3+
#include <stan/math/prim/fun/constants.hpp>
4+
#include <stan/math/prim/fun/log.hpp>
35

46
using stan::math::var;
57
using std::numeric_limits;

test/prob/bernoulli/bernoulli_cdf_test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Arguments: Ints, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/bernoulli_cdf.hpp>
33

44
using stan::math::var;
55
using std::numeric_limits;

test/prob/bernoulli/bernoulli_logit_test.hpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Arguments: Ints, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/bernoulli_logit_log.hpp>
3+
#include <stan/math/prim/fun/exp.hpp>
4+
#include <stan/math/prim/fun/log.hpp>
35

46
using stan::math::var;
57
using std::numeric_limits;
@@ -82,7 +84,6 @@ class AgradDistributionsBernoulliLogistic : public AgradDistributionTest {
8284
const T_prob& theta,
8385
const T2&, const T3&,
8486
const T4&, const T5&) {
85-
using stan::math::log1m;
8687
using std::log;
8788
T_prob ntheta = (2 * n - 1) * theta;
8889
const static double cutoff = 20.0;

test/prob/bernoulli/bernoulli_test.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// Arguments: Ints, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/bernoulli_log.hpp>
3+
#include <stan/math/prim/fun/log1m.hpp>
34
#include <stdexcept>
45

56
using stan::math::var;

test/prob/beta/beta_ccdf_log_test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Arguments: Doubles, Doubles, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/beta_ccdf_log.hpp>
33

44
using stan::math::var;
55
using std::numeric_limits;

test/prob/beta/beta_cdf_log_test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Arguments: Doubles, Doubles, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/beta_cdf_log.hpp>
33

44
using stan::math::var;
55
using std::numeric_limits;

test/prob/beta/beta_cdf_test.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Arguments: Doubles, Doubles, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/beta_cdf.hpp>
33

44
using stan::math::var;
55
using std::numeric_limits;

test/prob/beta/beta_test.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// Arguments: Doubles, Doubles, Doubles
2-
#include <stan/math/prim.hpp>
2+
#include <stan/math/prim/prob/beta_log.hpp>
3+
#include <stan/math/prim/fun/lgamma.hpp>
4+
#include <stan/math/prim/fun/log1m.hpp>
35

46
using stan::math::var;
57
using std::numeric_limits;

0 commit comments

Comments
 (0)