Skip to content

1210 Add compressed file methods #1221

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

Merged
merged 17 commits into from
Jan 27, 2022
Merged

1210 Add compressed file methods #1221

merged 17 commits into from
Jan 27, 2022

Conversation

Tbruno25
Copy link
Contributor

@Tbruno25 Tbruno25 commented Jan 18, 2022

This closes #1210 by adding LogReader.decompress / Logger.compress methods.

Changes:

  • add io/gz.py
  • add GzipReader class
  • add GzipReader to LogReader message readers
  • edit LogReader to check for last suffix only
  • edit LogReader docstring
  • add decompress method to LogReader
  • add unittest for compressed player
  • edit Logger to check for last suffix only
  • edit Logger docstring
  • add compress method to Logger
  • add unittest for compressed logger
  • add multiple dot suffix to test_extension_matching
  • remove GzipASCReader / GzipASCWriter and subsequent unittests

@codecov
Copy link

codecov bot commented Jan 18, 2022

Codecov Report

Merging #1221 (bfc3283) into develop (2807da1) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop    #1221      +/-   ##
===========================================
- Coverage    65.86%   65.84%   -0.02%     
===========================================
  Files           86       86              
  Lines         8873     8868       -5     
===========================================
- Hits          5844     5839       -5     
  Misses        3029     3029              

@felixdivo felixdivo added bug enhancement api file-io about reading & writing to files labels Jan 18, 2022
@felixdivo
Copy link
Collaborator

Looks simple and good! 😄

Once this is merged, I suggest opening the first pre-release.

@felixdivo felixdivo added this to the 4.0.0 Release milestone Jan 20, 2022
@felixdivo felixdivo mentioned this pull request Jan 20, 2022
@Tbruno25 Tbruno25 marked this pull request as ready for review January 21, 2022 06:14
@zariiii9003
Copy link
Collaborator

This does not really close #1210 yet. The same issue exists in can.io.logger. Also there should be a test, which reads and writes files with multiple dots.

@felixdivo
Copy link
Collaborator

This does not really close #1210 yet. The same issue exists in can.io.logger. Also there should be a test, which reads and writes files with multiple dots.

@Tbruno25 Do you have time for that too?

@Tbruno25
Copy link
Contributor Author

This does not really close #1210 yet. The same issue exists in can.io.logger. Also there should be a test, which reads and writes files with multiple dots.

@Tbruno25 Do you have time for that too?

Definitely! I can probably wrap this up this weekend.

@felixdivo
Copy link
Collaborator

Awesome!

As soon as that is merged, I'll update the changelog, publish a pre-release and create an announcement-issue.

Co-authored-by: Felix Divo <[email protected]>

Rename method to decompress
Add protection against memory error
@Tbruno25
Copy link
Contributor Author

Tbruno25 commented Jan 24, 2022

This does not really close #1210 yet. The same issue exists in can.io.logger. Also there should be a test, which reads and writes files with multiple dots.

I'm not sure we need to explicitly read/write with multiple dots -- just that only the last suffix is used as a key to select a message reader/writer. I added a suffix with multiple dots to test_extension_matching which I think satisfies this, although we could make it a separate unittest as well if required.

@Tbruno25
Copy link
Contributor Author

LogReader.decompress and Logger.compress are almost identical except for the mode. It probably makes sense in the future to unify them as a single function that both classes either import/inherit.

@felixdivo
Copy link
Collaborator

felixdivo commented Jan 24, 2022

LogReader.decompress and Logger.compress are almost identical except for the mode. It probably makes sense in the future to unify them as a single function that both classes either import/inherit.

Yeah, maybe. One could also easily add zip/... support too. For now, I think it is okay as is since it only requires three lines.

@zariiii9003
Copy link
Collaborator

There are still some typing errors left after the cleanup of @zariiii9003 in #1224, would you mind fixing them (they were skipped to avoid merge conflicts)?

GzipASCReader and GzipASCWriter can be deleted, right?

@Tbruno25 Tbruno25 marked this pull request as draft January 24, 2022 16:14
@pierreluctg
Copy link
Collaborator

There are still some typing errors left after the cleanup of @zariiii9003 in #1224, would you mind fixing them (they were skipped to avoid merge conflicts)?

GzipASCReader and GzipASCWriter can be deleted, right?

Yes, they can be removed.

@Tbruno25 Tbruno25 changed the title 1210 Add GzipReader 1210 Add compressed file methods Jan 26, 2022
@Tbruno25 Tbruno25 marked this pull request as ready for review January 26, 2022 06:10
@Tbruno25 Tbruno25 marked this pull request as draft January 26, 2022 06:42
@Tbruno25 Tbruno25 marked this pull request as ready for review January 26, 2022 06:52
Copy link
Collaborator

@felixdivo felixdivo left a comment

Choose a reason for hiding this comment

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

Wonderful, thank you @Tbruno25!

@felixdivo
Copy link
Collaborator

@zariiii9003 Do you agree on merging this?

@zariiii9003
Copy link
Collaborator

@zariiii9003 Do you agree on merging this?

I'll review it after work.

@felixdivo
Copy link
Collaborator

Ahh, one thing: The linter complains. Seems like this is unrelated though, so we can do this in a subsequent PR. I'll open an issue for this.

Copy link
Collaborator

@zariiii9003 zariiii9003 left a comment

Choose a reason for hiding this comment

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

Well done! The docstring could be a little more precise though.

@felixdivo I do not agree with the typehints here but i will follow up with another PR that takes care of the IO type annotations in general. There are some inconsistencies that are masked by casting.

@Tbruno25
Copy link
Contributor Author

Well done! The docstring could be a little more precise though.

@felixdivo I do not agree with the typehints here but i will follow up with another PR that takes care of the IO type annotations in general. There are some inconsistencies that are masked by casting.

I'm interested to see the solution regarding type hints! I don't have much experience with mypy but I couldn't seem to get it happy unless I used the very vague Any.

@zariiii9003 zariiii9003 merged commit d142257 into hardbyte:develop Jan 27, 2022
@felixdivo
Copy link
Collaborator

@Tbruno25 work is continued in #1238

@Tbruno25 Tbruno25 deleted the 1210_add-gzipreader branch January 27, 2022 16:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api blocker bug enhancement file-io about reading & writing to files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

can.LogReader error on opening "filename.with.too.many.dots.blf"
4 participants