diff --git a/tests/everest/snapshots/test_export/test_export_all_batches/export.csv b/tests/everest/snapshots/test_export/test_export_all_batches/export.csv index f01ce3d8787..1ed55ab4955 100644 --- a/tests/everest/snapshots/test_export/test_export_all_batches/export.csv +++ b/tests/everest/snapshots/test_export/test_export_all_batches/export.csv @@ -1,9 +1,9 @@ -,batch,sim_avg_obj,is_gradient,realization,start_time,end_time,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z -0,0,-2.3333,0,0,1725344867.0882,1725344867.1048,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1.0,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 -1,0,0.0,1,0,1725344867.1005,,1,1,0,,,,,,,0.0077,-0.005,-0.0205,,,,,,,, -2,0,-2.3402,1,0,1725344867.101,1725344867.106,1,1,1,-0.75,-1.125,-0.75,-4.7708,-4.7708,-1.5903,-0.0001,0.0053,-0.0051,,,,,,,, -3,0,-2.3272,1,0,1725344867.1016,1725344867.1072,1,1,2,-0.7553,-1.133,-0.7553,-4.7157,-4.7157,-1.5719,-0.0029,-0.007,0.0047,,,,,,,, -4,0,-2.3263,1,0,1725344867.1021,1725344867.1083,1,1,3,-0.7417,-1.1126,-0.7417,-4.7537,-4.7537,-1.5846,-0.0115,0.0145,0.0057,,,,,,,, -5,0,-2.3113,1,0,1725344867.1026,1725344867.1095,1,1,4,-0.7334,-1.1001,-0.7334,-4.7338,-4.7338,-1.5779,0.0013,-0.0012,0.0168,,,,,,,, -6,1,-2.3335,0,0,1725344867.4911,1725344867.4928,1,1,0,-0.7657,-1.1485,-0.7657,-4.7036,-4.7036,-1.5679,-0.0042,-0.0113,1.0,-2.3335,0.0,,,,,, -7,2,-2.0,0,0,1725344867.8464,1725344867.8476,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1.0,,,,,, +,batch,sim_avg_obj,is_gradient,realization,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z +0,0,-2.3333,0,0,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1.0,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 +1,0,0.0,1,0,1,1,0,,,,,,,0.0077,-0.005,-0.0205,,,,,,,, +2,0,-2.3402,1,0,1,1,1,-0.75,-1.125,-0.75,-4.7708,-4.7708,-1.5903,-0.0001,0.0053,-0.0051,,,,,,,, +3,0,-2.3272,1,0,1,1,2,-0.7553,-1.133,-0.7553,-4.7157,-4.7157,-1.5719,-0.0029,-0.007,0.0047,,,,,,,, +4,0,-2.3263,1,0,1,1,3,-0.7417,-1.1126,-0.7417,-4.7537,-4.7537,-1.5846,-0.0115,0.0145,0.0057,,,,,,,, +5,0,-2.3113,1,0,1,1,4,-0.7334,-1.1001,-0.7334,-4.7338,-4.7338,-1.5779,0.0013,-0.0012,0.0168,,,,,,,, +6,1,-2.3335,0,0,1,1,0,-0.7656,-1.1485,-0.7656,-4.7036,-4.7036,-1.5679,-0.0042,-0.0113,1.0,-2.3335,0.0,,,,,, +7,2,-2.0,0,0,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1.0,,,,,, diff --git a/tests/everest/snapshots/test_export/test_export_batches_progress/export.csv b/tests/everest/snapshots/test_export/test_export_batches_progress/export.csv index 6fc9b667334..dfa2522a630 100644 --- a/tests/everest/snapshots/test_export/test_export_batches_progress/export.csv +++ b/tests/everest/snapshots/test_export/test_export_batches_progress/export.csv @@ -1,21 +1,2 @@ -sim_date,FOPR,FOPT,batch,sim_avg_obj,is_gradient,realization,success,realization_weight,npv_function,npv_function_norm,npv_function_weighted_norm,group_sum,group_sum_norm,group_sum_weighted_norm,group_w00,group_w01,group_w02,group_w03 -2010-11-21,3240.0,3240.0,2,1115.317,1,0,1,0.5,1886.01,1886.01,943.005,0.3446,344.624,172.312,0.0825,0.0987,0.0818,0.0816 -2010-11-21,3240.0,3240.0,2,1117.514,1,0,1,0.5,1886.01,1886.01,943.005,0.349,349.018,174.509,0.0888,0.0969,0.0796,0.0838 -2010-11-21,3240.0,3240.0,2,1109.3895,1,1,1,0.5,1886.01,1886.01,943.005,0.3328,332.769,166.3845,0.0752,0.0984,0.0783,0.0808 -2010-11-21,3240.0,3240.0,2,1110.811,1,1,1,0.5,1886.01,1886.01,943.005,0.3356,335.612,167.806,0.082,0.0944,0.0809,0.0782 -2011-11-21,6890.0,6890.0,2,1115.317,1,0,1,0.5,1886.01,1886.01,943.005,0.3446,344.624,172.312,0.0825,0.0987,0.0818,0.0816 -2011-11-21,6890.0,6890.0,2,1117.514,1,0,1,0.5,1886.01,1886.01,943.005,0.349,349.018,174.509,0.0888,0.0969,0.0796,0.0838 -2011-11-21,6890.0,6890.0,2,1109.3895,1,1,1,0.5,1886.01,1886.01,943.005,0.3328,332.769,166.3845,0.0752,0.0984,0.0783,0.0808 -2011-11-21,6890.0,6890.0,2,1110.811,1,1,1,0.5,1886.01,1886.01,943.005,0.3356,335.612,167.806,0.082,0.0944,0.0809,0.0782 -2012-11-20,10540.0,10540.0,2,1115.317,1,0,1,0.5,1886.01,1886.01,943.005,0.3446,344.624,172.312,0.0825,0.0987,0.0818,0.0816 -2012-11-20,10540.0,10540.0,2,1117.514,1,0,1,0.5,1886.01,1886.01,943.005,0.349,349.018,174.509,0.0888,0.0969,0.0796,0.0838 -2012-11-20,10540.0,10540.0,2,1109.3895,1,1,1,0.5,1886.01,1886.01,943.005,0.3328,332.769,166.3845,0.0752,0.0984,0.0783,0.0808 -2012-11-20,10540.0,10540.0,2,1110.811,1,1,1,0.5,1886.01,1886.01,943.005,0.3356,335.612,167.806,0.082,0.0944,0.0809,0.0782 -2013-11-20,14190.0,14190.0,2,1115.317,1,0,1,0.5,1886.01,1886.01,943.005,0.3446,344.624,172.312,0.0825,0.0987,0.0818,0.0816 -2013-11-20,14190.0,14190.0,2,1117.514,1,0,1,0.5,1886.01,1886.01,943.005,0.349,349.018,174.509,0.0888,0.0969,0.0796,0.0838 -2013-11-20,14190.0,14190.0,2,1109.3895,1,1,1,0.5,1886.01,1886.01,943.005,0.3328,332.769,166.3845,0.0752,0.0984,0.0783,0.0808 -2013-11-20,14190.0,14190.0,2,1110.811,1,1,1,0.5,1886.01,1886.01,943.005,0.3356,335.612,167.806,0.082,0.0944,0.0809,0.0782 -2014-11-20,17840.0,17840.0,2,1115.317,1,0,1,0.5,1886.01,1886.01,943.005,0.3446,344.624,172.312,0.0825,0.0987,0.0818,0.0816 -2014-11-20,17840.0,17840.0,2,1117.514,1,0,1,0.5,1886.01,1886.01,943.005,0.349,349.018,174.509,0.0888,0.0969,0.0796,0.0838 -2014-11-20,17840.0,17840.0,2,1109.3895,1,1,1,0.5,1886.01,1886.01,943.005,0.3328,332.769,166.3845,0.0752,0.0984,0.0783,0.0808 -2014-11-20,17840.0,17840.0,2,1110.811,1,1,1,0.5,1886.01,1886.01,943.005,0.3356,335.612,167.806,0.082,0.0944,0.0809,0.0782 +batch,sim_avg_obj,is_gradient,realization,success,realization_weight,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit +2,-2.0,0,0,1,1,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1 diff --git a/tests/everest/snapshots/test_export/test_export_gradients/export.csv b/tests/everest/snapshots/test_export/test_export_gradients/export.csv index f8ade2fc421..f92c9450fa7 100644 --- a/tests/everest/snapshots/test_export/test_export_gradients/export.csv +++ b/tests/everest/snapshots/test_export/test_export_gradients/export.csv @@ -1,3 +1,3 @@ -,batch,sim_avg_obj,is_gradient,realization,start_time,end_time,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z -0,0,-2.3333,0,0,1725344867.0882,1725344867.1048,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 -1,2,-2.0,0,0,1725344867.8464,1725344867.8476,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1,,,,,, +,batch,sim_avg_obj,is_gradient,realization,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z +0,0,-2.3333,0,0,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 +1,2,-2.0,0,0,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1,,,,,, diff --git a/tests/everest/snapshots/test_export/test_export_only_give_batches/export.csv b/tests/everest/snapshots/test_export/test_export_only_give_batches/export.csv index 5c240f5a18f..9ba7d51b637 100644 --- a/tests/everest/snapshots/test_export/test_export_only_give_batches/export.csv +++ b/tests/everest/snapshots/test_export/test_export_only_give_batches/export.csv @@ -1,2 +1,2 @@ -,batch,sim_avg_obj,is_gradient,realization,start_time,end_time,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit -0,2,-2.0,0,0,1725344867.8464,1725344867.8476,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1 +,batch,sim_avg_obj,is_gradient,realization,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit +0,2,-2.0,0,0,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1 diff --git a/tests/everest/snapshots/test_export/test_export_only_increased_merit/export.csv b/tests/everest/snapshots/test_export/test_export_only_increased_merit/export.csv index 9452566d15e..cce2580326f 100644 --- a/tests/everest/snapshots/test_export/test_export_only_increased_merit/export.csv +++ b/tests/everest/snapshots/test_export/test_export_only_increased_merit/export.csv @@ -1,8 +1,8 @@ -,batch,sim_avg_obj,is_gradient,realization,start_time,end_time,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z -0,0,-2.3333,0,0,1725344867.0882,1725344867.1048,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1.0,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 -1,0,0.0,1,0,1725344867.1005,,1,1,0,,,,,,,0.0077,-0.005,-0.0205,,,,,,,, -2,0,-2.3402,1,0,1725344867.101,1725344867.106,1,1,1,-0.75,-1.125,-0.75,-4.7708,-4.7708,-1.5903,-0.0001,0.0053,-0.0051,,,,,,,, -3,0,-2.3272,1,0,1725344867.1016,1725344867.1072,1,1,2,-0.7553,-1.133,-0.7553,-4.7157,-4.7157,-1.5719,-0.0029,-0.007,0.0047,,,,,,,, -4,0,-2.3263,1,0,1725344867.1021,1725344867.1083,1,1,3,-0.7417,-1.1126,-0.7417,-4.7537,-4.7537,-1.5846,-0.0115,0.0145,0.0057,,,,,,,, -5,0,-2.3113,1,0,1725344867.1026,1725344867.1095,1,1,4,-0.7334,-1.1001,-0.7334,-4.7338,-4.7338,-1.5779,0.0013,-0.0012,0.0168,,,,,,,, -6,2,-2.0,0,0,1725344867.8464,1725344867.8476,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1.0,,,,,, +,batch,sim_avg_obj,is_gradient,realization,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z +0,0,-2.3333,0,0,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1.0,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 +1,0,0.0,1,0,1,1,0,,,,,,,0.0077,-0.005,-0.0205,,,,,,,, +2,0,-2.3402,1,0,1,1,1,-0.75,-1.125,-0.75,-4.7708,-4.7708,-1.5903,-0.0001,0.0053,-0.0051,,,,,,,, +3,0,-2.3272,1,0,1,1,2,-0.7553,-1.133,-0.7553,-4.7157,-4.7157,-1.5719,-0.0029,-0.007,0.0047,,,,,,,, +4,0,-2.3263,1,0,1,1,3,-0.7417,-1.1126,-0.7417,-4.7537,-4.7537,-1.5846,-0.0115,0.0145,0.0057,,,,,,,, +5,0,-2.3113,1,0,1,1,4,-0.7334,-1.1001,-0.7334,-4.7338,-4.7338,-1.5779,0.0013,-0.0012,0.0168,,,,,,,, +6,2,-2.0,0,0,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1.0,,,,,, diff --git a/tests/everest/snapshots/test_export/test_export_only_non_gradient/export.csv b/tests/everest/snapshots/test_export/test_export_only_non_gradient/export.csv index 8cfd90a870a..1293103a166 100644 --- a/tests/everest/snapshots/test_export/test_export_only_non_gradient/export.csv +++ b/tests/everest/snapshots/test_export/test_export_only_non_gradient/export.csv @@ -1,4 +1,4 @@ -,batch,sim_avg_obj,is_gradient,realization,start_time,end_time,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z -0,0,-2.3333,0,0,1725344867.0882,1725344867.1048,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 -1,1,-2.3335,0,0,1725344867.4911,1725344867.4928,1,1,0,-0.7657,-1.1485,-0.7657,-4.7036,-4.7036,-1.5679,-0.0042,-0.0113,1.0,-2.3335,0,,,,,, -2,2,-2.0,0,0,1725344867.8464,1725344867.8476,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1,,,,,, +,batch,sim_avg_obj,is_gradient,realization,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z +0,0,-2.3333,0,0,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 +1,1,-2.3335,0,0,1,1,0,-0.7656,-1.1485,-0.7656,-4.7036,-4.7036,-1.5679,-0.0042,-0.0113,1.0,-2.3335,0,,,,,, +2,2,-2.0,0,0,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1,,,,,, diff --git a/tests/everest/snapshots/test_export/test_export_only_non_gradient_with_increased_merit/export.csv b/tests/everest/snapshots/test_export/test_export_only_non_gradient_with_increased_merit/export.csv index f8ade2fc421..f92c9450fa7 100644 --- a/tests/everest/snapshots/test_export/test_export_only_non_gradient_with_increased_merit/export.csv +++ b/tests/everest/snapshots/test_export/test_export_only_non_gradient_with_increased_merit/export.csv @@ -1,3 +1,3 @@ -,batch,sim_avg_obj,is_gradient,realization,start_time,end_time,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z -0,0,-2.3333,0,0,1725344867.0882,1725344867.1048,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 -1,2,-2.0,0,0,1725344867.8464,1725344867.8476,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1,,,,,, +,batch,sim_avg_obj,is_gradient,realization,success,realization_weight,simulation,distance_p,distance_p_norm,distance_p_weighted_norm,distance_q,distance_q_norm,distance_q_weighted_norm,point_x,point_y,point_z,real_avg_obj,increased_merit,gradient-distance_p-point_x,gradient-distance_p-point_y,gradient-distance_p-point_z,gradient-distance_q-point_x,gradient-distance_q-point_y,gradient-distance_q-point_z +0,0,-2.3333,0,0,1,1,0,-0.75,-1.125,-0.75,-4.75,-4.75,-1.5833,0.0,0.0,0.0,-2.3333,1,0.9959,0.9887,1.0047,-3.0046,-3.0114,1.0045 +1,2,-2.0,0,0,1,1,0,-0.5078,-0.7617,-0.5078,-4.4768,-4.4768,-1.4923,-0.0021,-0.0056,0.4999,-2.0,1,,,,,, diff --git a/tests/everest/test_export.py b/tests/everest/test_export.py index 315a2545c36..6649911df3c 100644 --- a/tests/everest/test_export.py +++ b/tests/everest/test_export.py @@ -1,5 +1,6 @@ import os import shutil +from pathlib import Path import pandas as pd import pytest @@ -9,10 +10,7 @@ from everest.config import EverestConfig from everest.config.export_config import ExportConfig from everest.export import check_for_errors, export_data -from tests.everest.utils import create_cached_mocked_test_case, relpath -CONFIG_FILE_MOCKED_TEST_CASE = "mocked_multi_batch.yml" -CASHED_RESULTS_FOLDER = relpath("test_data", "cached_results_config_multiobj") CONFIG_FILE = "config_multiobj.yml" DATA = pd.DataFrame( { @@ -27,11 +25,6 @@ pytestmark = pytest.mark.xdist_group(name="starts_everest") -@pytest.fixture() -def cache_dir(request, monkeypatch): - return create_cached_mocked_test_case(request, monkeypatch) - - def assertEqualDataFrames(x, y): assert set(x.columns) == set(y.columns) for col in x.columns: @@ -65,16 +58,9 @@ def test_filter_double_wildcard(): ) -def test_export_only_non_gradient_with_increased_merit( - copy_math_func_test_data_to_tmp, snapshot -): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) - +def test_export_only_non_gradient_with_increased_merit(cached_example, snapshot): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Default export functionality when no export section is defined df = export_data( export_config=config.export, @@ -84,16 +70,14 @@ def test_export_only_non_gradient_with_increased_merit( # Test that the default export functionality generated data frame # contains only non gradient simulations - snapshot.assert_match(df.round(4).to_csv(), "export.csv") + snapshot.assert_match( + df.drop(["start_time", "end_time"], axis=1).round(4).to_csv(), "export.csv" + ) -def test_export_only_non_gradient(copy_math_func_test_data_to_tmp, snapshot): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) +def test_export_only_non_gradient(cached_example, snapshot): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Add export section to config config.export = ExportConfig(discard_rejected=False) @@ -104,16 +88,14 @@ def test_export_only_non_gradient(copy_math_func_test_data_to_tmp, snapshot): data_file=config.model.data_file if config.model else None, ) - snapshot.assert_match(df.round(4).to_csv(), "export.csv") + snapshot.assert_match( + df.drop(["start_time", "end_time"], axis=1).round(4).to_csv(), "export.csv" + ) -def test_export_only_increased_merit(copy_math_func_test_data_to_tmp, snapshot): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) +def test_export_only_increased_merit(cached_example, snapshot): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Add export section to config config.export = ExportConfig(discard_gradient=False) @@ -124,16 +106,15 @@ def test_export_only_increased_merit(copy_math_func_test_data_to_tmp, snapshot): data_file=config.model.data_file if config.model else None, ) - snapshot.assert_match(df.round(4).to_csv(), "export.csv") + snapshot.assert_match( + df.drop(["start_time", "end_time"], axis=1).round(4).to_csv(), + "export.csv", + ) -def test_export_all_batches(copy_math_func_test_data_to_tmp, snapshot): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) +def test_export_all_batches(cached_example, snapshot): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Add export section to config config.export = ExportConfig(discard_gradient=False, discard_rejected=False) @@ -144,16 +125,14 @@ def test_export_all_batches(copy_math_func_test_data_to_tmp, snapshot): data_file=config.model.data_file if config.model else None, ) - snapshot.assert_match(df.round(4).to_csv(), "export.csv") + snapshot.assert_match( + df.drop(["start_time", "end_time"], axis=1).round(4).to_csv(), "export.csv" + ) -def test_export_only_give_batches(copy_math_func_test_data_to_tmp, snapshot): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) +def test_export_only_give_batches(cached_example, snapshot): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Add export section to config config.export = ExportConfig(discard_gradient=True, batches=[2]) @@ -164,17 +143,14 @@ def test_export_only_give_batches(copy_math_func_test_data_to_tmp, snapshot): data_file=config.model.data_file if config.model else None, ) - snapshot.assert_match(df.round(4).to_csv(), "export.csv") - + snapshot.assert_match( + df.drop(["start_time", "end_time"], axis=1).round(4).to_csv(), "export.csv" + ) -def test_export_batches_progress(cache_dir, copy_mocked_test_data_to_tmp, snapshot): - config = EverestConfig.load_file(CONFIG_FILE_MOCKED_TEST_CASE) - shutil.copytree( - cache_dir / "mocked_multi_batch_output", - "mocked_multi_batch_output", - dirs_exist_ok=True, - ) +def test_export_batches_progress(cached_example, snapshot): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Add export section to config config.export = ExportConfig(discard_gradient=True, batches=[2]) @@ -183,18 +159,14 @@ def test_export_batches_progress(cache_dir, copy_mocked_test_data_to_tmp, snapsh # Check only simulations from given batches are present in export # drop non-deterministic columns df = df.drop(["start_time", "end_time", "simulation"], axis=1) - df = df.sort_values(by=["sim_date", "realization", "batch", "sim_avg_obj"]) + df = df.sort_values(by=["realization", "batch", "sim_avg_obj"]) snapshot.assert_match(df.round(4).to_csv(index=False), "export.csv") -def test_export_nothing_for_empty_batch_list(copy_math_func_test_data_to_tmp, snapshot): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) +def test_export_nothing_for_empty_batch_list(cached_example): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Add discard gradient flag to config file config.export = ExportConfig( @@ -210,13 +182,9 @@ def test_export_nothing_for_empty_batch_list(copy_math_func_test_data_to_tmp, sn assert df.empty -def test_export_nothing(copy_math_func_test_data_to_tmp): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) +def test_export_nothing(cached_example): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Add discard gradient flag to config file config.export = ExportConfig( @@ -232,8 +200,9 @@ def test_export_nothing(copy_math_func_test_data_to_tmp): assert df.empty -def test_get_export_path(copy_math_func_test_data_to_tmp): - config = EverestConfig.load_file(CONFIG_FILE) +def test_get_export_path(cached_example): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) # Test default export path when no csv_output_filepath is defined expected_export_path = os.path.join( @@ -268,14 +237,11 @@ def test_get_export_path(copy_math_func_test_data_to_tmp): assert expected_export_path == new_config.export_path -def test_validate_export(cache_dir, copy_mocked_test_data_to_tmp): - config = EverestConfig.load_file(CONFIG_FILE_MOCKED_TEST_CASE) - - shutil.copytree( - cache_dir / "mocked_multi_batch_output", - "mocked_multi_batch_output", - dirs_exist_ok=True, +def test_validate_export(cached_example): + config_path, config_file, _ = cached_example( + "../../tests/everest/test_data/mocked_test_case/mocked_multi_batch.yml" ) + config = EverestConfig.load_file(Path(config_path) / config_file) def check_error(expected_error, reported_errors): expected_error_msg, expected_export_ecl = expected_error @@ -374,13 +340,9 @@ def check_error(expected_error, reported_errors): assert config.export.batches == [0] -def test_export_gradients(copy_math_func_test_data_to_tmp, snapshot): - config = EverestConfig.load_file(CONFIG_FILE) - os.makedirs(config.optimization_output_dir) - shutil.copy( - os.path.join(CASHED_RESULTS_FOLDER, "seba.db"), - os.path.join(config.optimization_output_dir, "seba.db"), - ) +def test_export_gradients(cached_example, snapshot): + config_path, config_file, _ = cached_example("math_func/config_multiobj.yml") + config = EverestConfig.load_file(Path(config_path) / config_file) df = export_data( export_config=config.export, @@ -388,4 +350,6 @@ def test_export_gradients(copy_math_func_test_data_to_tmp, snapshot): data_file=config.model.data_file if config.model else None, ) - snapshot.assert_match(df.round(4).to_csv(), "export.csv") + snapshot.assert_match( + df.drop(["start_time", "end_time"], axis=1).round(4).to_csv(), "export.csv" + )