Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add datetime to CSV #1009

Merged
merged 9 commits into from
May 19, 2021
Merged

Add datetime to CSV #1009

merged 9 commits into from
May 19, 2021

Conversation

rok-cesnovar
Copy link
Member

Summary:

Adds the timestamp to the resulting CSV to close #1006

Example:

# stan_version_major = 2
# stan_version_minor = 26
# stan_version_patch = 1
# model = bernoulli_model
# start_time = 2021-05-07 20:09:04
# method = sample (Default)

Copyright and Licensing

Please list the copyright holder for the work you are submitting (this will be you or your assignee, such as a university or company): Rok Češnovar

By submitting this pull request, the copyright holder is agreeing to license the submitted work under the following licenses:

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.16 3.06 1.03 3.09% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.0 0.03% faster
eight_schools/eight_schools.stan 0.11 0.12 0.94 -6.62% slower
gp_regr/gp_regr.stan 0.17 0.16 1.05 4.35% faster
irt_2pl/irt_2pl.stan 6.05 5.99 1.01 0.93% faster
performance.compilation 89.55 87.49 1.02 2.31% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.72 8.84 0.99 -1.47% slower
pkpd/one_comp_mm_elim_abs.stan 29.87 31.5 0.95 -5.45% slower
sir/sir.stan 122.65 132.57 0.93 -8.09% slower
gp_regr/gen_gp_data.stan 0.04 0.04 1.02 1.87% faster
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.06 3.03 1.01 0.93% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.38 0.41 0.92 -8.29% slower
arK/arK.stan 1.89 1.85 1.02 2.33% faster
arma/arma.stan 0.76 0.86 0.89 -12.86% slower
garch/garch.stan 0.56 0.6 0.94 -6.89% slower
Mean result: 0.98032593597

Jenkins Console Log
Blue Ocean
Commit hash: 2f2e69a


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.15 3.07 1.03 2.61% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 1.05 4.32% faster
eight_schools/eight_schools.stan 0.11 0.11 0.98 -1.97% slower
gp_regr/gp_regr.stan 0.16 0.16 1.01 1.19% faster
irt_2pl/irt_2pl.stan 5.99 5.95 1.01 0.76% faster
performance.compilation 89.86 87.12 1.03 3.05% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 9.08 8.66 1.05 4.57% faster
pkpd/one_comp_mm_elim_abs.stan 29.96 29.11 1.03 2.81% faster
sir/sir.stan 124.34 135.8 0.92 -9.22% slower
gp_regr/gen_gp_data.stan 0.03 0.04 0.97 -2.93% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.03 3.01 1.01 0.74% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.4 0.38 1.05 4.58% faster
arK/arK.stan 1.87 1.9 0.98 -1.64% slower
arma/arma.stan 0.75 0.85 0.88 -13.24% slower
garch/garch.stan 0.56 0.6 0.94 -6.26% slower
Mean result: 0.99541744593

Jenkins Console Log
Blue Ocean
Commit hash: 1537ec5


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.09 3.13 0.99 -1.04% slower
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.98 -2.45% slower
eight_schools/eight_schools.stan 0.11 0.12 0.92 -8.12% slower
gp_regr/gp_regr.stan 0.16 0.16 0.96 -3.92% slower
irt_2pl/irt_2pl.stan 6.06 6.23 0.97 -2.9% slower
performance.compilation 89.74 87.39 1.03 2.62% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 8.61 8.61 1.0 -0.04% slower
pkpd/one_comp_mm_elim_abs.stan 29.29 31.73 0.92 -8.31% slower
sir/sir.stan 124.04 121.38 1.02 2.15% faster
gp_regr/gen_gp_data.stan 0.04 0.04 0.98 -2.39% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.08 3.05 1.01 1.12% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.39 0.4 0.96 -4.02% slower
arK/arK.stan 1.91 1.87 1.02 1.89% faster
arma/arma.stan 0.74 0.85 0.87 -14.29% slower
garch/garch.stan 0.57 0.57 0.99 -0.91% slower
Mean result: 0.975407946451

Jenkins Console Log
Blue Ocean
Commit hash: 4eab50a


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

<< curr_tm->tm_hour << ":" << std::setw(2)
<< curr_tm->tm_min << ":" << std::setw(2)
<< curr_tm->tm_sec;
writer(current_datetime_msg.str());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not pretty and can be replaced by

const std::time_t current_datetime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
std::stringstream current_datetime_msg;
current_datetime_msg << std::put_time(std::localtime(&current_datetime), "%F %T");
writer("start_datetime = " + current_datetime_msg.str());

once we up the minimum required g++ to 5+. g++ 4.9 does not have std::put_time even though its part of C++11...

I also tried using std::strftime and char arrays but that produced a few garbage characters.

@rok-cesnovar
Copy link
Member Author

Ready for review.

@rok-cesnovar rok-cesnovar mentioned this pull request May 16, 2021
20 tasks
@rok-cesnovar
Copy link
Member Author

Last call for reviews.

@wds15
Copy link
Contributor

wds15 commented May 18, 2021

Can you give me today?

@rok-cesnovar
Copy link
Member Author

No one is racing to review this so take your time :)

@wds15
Copy link
Contributor

wds15 commented May 18, 2021

I see no tests. Do we say that comments like these are not required to be tested? What would happen downstream if the date-time is not present or messed up?

@wds15
Copy link
Contributor

wds15 commented May 18, 2021

And would it make sense to add the end time as well?

@wds15
Copy link
Contributor

wds15 commented May 18, 2021

And what about time-zone?

@rok-cesnovar
Copy link
Member Author

rok-cesnovar commented May 18, 2021

I see no tests

Yeah, I am not sure what can we test in Cmdstan without doing some sort of parsing in Python which seems a bit overkill to add another script just for this test. There will be tests in cmdstanr (if this gets in) if that helps. We also dont tests other coments if they are genereated or not (like num_threads, mpi, etc) comments etc.

What would happen downstream if the date-time is not present or messed up?

This does not touch or change anything in downstream (Math/Stan services) so nothing. And CSV readers in upstream (rstan, cmdstanr/py) do not care about the number of comments or position nor should they. They only look for specific comments (if that info is needed, but absence of presece of this comment does not change that).

And would it make sense to add the end time as well?

Hm, maybe, though that can also be obtained from start time + running time. The problem is that the way CSV is printed that would add another comment after the CSV and we are trying to avoid that as the format

# comments
values
# more comments

or even

# comments
values
# adaptiation results
more value
# comments

is causing problems for almost all fast CSV readers in R and Python and they need to be handheld a bit.

And what about time-zone?

Hm, good call. Will add a "UTC+3", "UTC-2".

@wds15
Copy link
Contributor

wds15 commented May 18, 2021

What about stansummary printing out the date time... and that we test?

@rok-cesnovar
Copy link
Member Author

That means touching stansummary and I really dont want to do exapand stansummary for no reason except to test. Will try to add a test to parse in C++.

@rok-cesnovar
Copy link
Member Author

I fixed it to the UTC timezone and added a test. It checks that the start_datetime was found, that the year matches and that the start_datetime ends with "UTC".

@stan-buildbot
Copy link
Contributor


Name Old Result New Result Ratio Performance change( 1 - new / old )
gp_pois_regr/gp_pois_regr.stan 3.08 3.04 1.01 1.39% faster
low_dim_corr_gauss/low_dim_corr_gauss.stan 0.02 0.02 0.95 -5.24% slower
eight_schools/eight_schools.stan 0.11 0.12 0.97 -3.03% slower
gp_regr/gp_regr.stan 0.16 0.16 1.0 0.26% faster
irt_2pl/irt_2pl.stan 6.07 6.0 1.01 1.23% faster
performance.compilation 89.46 87.34 1.02 2.38% faster
low_dim_gauss_mix_collapse/low_dim_gauss_mix_collapse.stan 9.0 8.61 1.05 4.34% faster
pkpd/one_comp_mm_elim_abs.stan 31.37 29.1 1.08 7.22% faster
sir/sir.stan 123.64 133.44 0.93 -7.93% slower
gp_regr/gen_gp_data.stan 0.03 0.04 0.98 -1.56% slower
low_dim_gauss_mix/low_dim_gauss_mix.stan 3.13 3.04 1.03 2.67% faster
pkpd/sim_one_comp_mm_elim_abs.stan 0.4 0.39 1.03 3.29% faster
arK/arK.stan 1.86 1.85 1.0 0.22% faster
arma/arma.stan 0.79 0.78 1.01 1.19% faster
garch/garch.stan 0.6 0.49 1.22 18.08% faster
Mean result: 1.02033602742

Jenkins Console Log
Blue Ocean
Commit hash: 837a2fe


Machine information ProductName: Mac OS X ProductVersion: 10.11.6 BuildVersion: 15G22010

CPU:
Intel(R) Xeon(R) CPU E5-1680 v2 @ 3.00GHz

G++:
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/usr/include/c++/4.2.1
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

Clang:
Apple LLVM version 7.0.2 (clang-700.1.81)
Target: x86_64-apple-darwin15.6.0
Thread model: posix

@rok-cesnovar
Copy link
Member Author

If this PR is merged I would just proceed with the release.

@wds15
Copy link
Contributor

wds15 commented May 19, 2021

Looking at it now.

Copy link
Contributor

@wds15 wds15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for adding the test.

@rok-cesnovar rok-cesnovar merged commit 182c579 into develop May 19, 2021
@rok-cesnovar rok-cesnovar deleted the add_datetime_to_CSV branch May 19, 2021 06:36
@rok-cesnovar
Copy link
Member Author

Thanks for the quick review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add timestamp to csv
4 participants