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 LRU eviction with 1gb memory limit for PandasData #392

Merged
merged 15 commits into from
Mar 12, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Encountered this chasing a "Not naive time" exception. Split the line…
… to help future sleuthing.
  • Loading branch information
Jim White committed Mar 10, 2024
commit 93744e2e4e27559270ffbfb9596c871dc17b5dcf
5 changes: 4 additions & 1 deletion lumibot/tools/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,10 @@ def to_datetime_aware(dt_in):
"""Convert naive time to datetime aware on default timezone."""
if not dt_in:
return dt_in
elif isinstance(dt_in, dt.datetime) and (dt_in.tzinfo is None or dt_in.tzinfo.utcoffset(dt_in) is None):
elif isinstance(dt_in, dt.datetime) and (dt_in.tzinfo is None):
return LUMIBOT_DEFAULT_PYTZ.localize(dt_in)
elif isinstance(dt_in, dt.datetime) and (dt_in.tzinfo.utcoffset(dt_in) is None):
# TODO: This will fail because an exception is thrown if tzinfo is not None.
return LUMIBOT_DEFAULT_PYTZ.localize(dt_in)
Comment on lines +147 to 149
Copy link
Contributor

Choose a reason for hiding this comment

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

category Bug Risk priority 7

The code attempts to localize a datetime object that already has a timezone but no UTC offset. However, the comment indicates that this will fail because an exception is thrown if the datetime object's tzinfo attribute is not None. This could lead to unexpected behavior or errors. It would be better to handle this case properly, either by converting the datetime object to a naive datetime before localizing it, or by handling the exception in some way.

else:
return dt_in
Expand Down