-
Notifications
You must be signed in to change notification settings - Fork 373
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
Get rid of time 0.1.* dependency #1408
Conversation
Just to be clear, this PR is not ready to be merged, it's the first step of fixing the |
Thank you so much for working on this! ❤️ Excellent work on figuring out that Getting rid of the use of let time_format = time::format_description::parse("[year]-[month]-[day] [hour]:[minute]:[second]Z")?;
let date_time = time::OffsetDateTime::now_utc().format(&time_format)?; As for the patched crate: we avoid patching our crates because it can easily prevent us from publishing new I'll convert this PR to a draft until it compiles :] |
Noted, I'll try to do the chrono/time swap later tonight. |
I have made some changes in Apparently A few remarks after working on this: The purpose of This seems like a bad idea to me, as you leave some arbitrary implicit condition inside a formatting function. This may lead to weird to track bug in the future. I would see two ways to fix this situation. Either differentiate relative and absolute times in rerun types, with each their own set of rules and functions. A bit like the I also do not like very much the internal logic asking for the current date, to see if we can omit the day part of the displaying logic. It does not seem robust to me because the implicit logic may prove to be annoying to deal with for other use cases. Imagine you want to format times for logging, which will later be analyzed by some other code. While logging the formatted date, they all will follow the "current day" logic, but when reviewing these logs few days later will be impossible because we won't know which date it referred to. Basically, I think it would be better to extract all implicit logic and side effects to caller sites, where someone clearly takes responsibility of these decisions, instead of using a heuristic. Finally, representing dates with unix timestamp in nanoseconds with i64 can only go as far as a couple hundred years. Depending on usage, for things like simulations and such, I can easily imagine weird situations where the i64 representation is not enough. For reference, the PS: I haven't looked at why but arrow2 doesn't like the new polars it seems. |
The remarks above about implicit internal logic and side effects does not matter for this PR, but if you think it is relevant for later, I'll open an issue about it later. Also, the |
We have chosen to use |
crates/re_log_types/src/time.rs
Outdated
@@ -117,16 +101,16 @@ impl Time { | |||
} | |||
|
|||
pub fn format_time(&self, format_str: &str) -> String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this function is unused and can be removed
Awesome! Adding a little unit-test would be great. I should have done so myself when I last touched the code 😬 |
Please also revert |
I don't think it is, actually. It seems like an unused dependency! |
Alright, will try to do that |
Clearing the cargo.lock was the only way I had found to make sure I had gotten rid of the time 0.1 dependency while checking with |
I've removed the
Should I do anything about this or just leave it as is? I've minimized the changes to the cargo lock file by resetting it to its state in the I've updated the formatting function in The only thing left should be adding a unit test for formatting. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code LGTM, and a couple of unit tests would make this ⭐️⭐️⭐️
Co-authored-by: Emil Ernerfeldt <[email protected]>
Co-authored-by: Emil Ernerfeldt <[email protected]>
I've added tests for the formatting. Beware that the test for checking formatting of datetimes for today may flake as It's not guaranteed that |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great!
Checklist
CHANGELOG.md
(if this is a big enough change to warrant it)According to
cargo audit
, rerun dependency totime 0.1.*
is tied to its dependency tochrono 0.4
. And Rerun is dependent onchrono
in three different ways:re_log_types
to format timesBut in fact,
time
has been an optional dependency tochrono
for quite some time, and can be avoided by settingdefault-features = false
. Arrow2 is already doing this, but not polars. Well polars merged a PR last week removing chrono default features, but it hasn't reached a published version yet.So I tried disabling chrono default features in rerun and overriding polars with their latest git commit. This is indeed removing
time 0.1.*
from our dependencies :) Now of coursere_log_types
does not compile anymore because of a call tochrono::offset::Utc::now()
.So in theory, if we fix that, when the next version of polars is published we will be rid of the
time
CVE.