Skip to content

Conversation

@j-c-cook
Copy link
Contributor

@j-c-cook j-c-cook commented Aug 27, 2022

The current implementation of the BLFWriter requires that the file be negatively sought (#1379 (comment)). The cpython implementation does not allow for GzipFiles to be negatively sought while in write mode. Modifying gzip is outside of the scope of this project. I see two options here:

  1. Modify the BLFWriter to close, seek then re-open (@christiansandberg says this was previously being done)
  2. Inform the user that the GzipFile format is not compatible with the BLFWriter (later enhancing python-can so that zip formats that can be negatively sought are available)

I'm proposing option 2.

closes #1378

@codecov
Copy link

codecov bot commented Aug 27, 2022

Codecov Report

Merging #1385 (7c0e650) into develop (5f485db) will decrease coverage by 5.41%.
The diff coverage is 78.84%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1385      +/-   ##
===========================================
- Coverage    65.28%   59.87%   -5.42%     
===========================================
  Files           81       81              
  Lines         8830     8726     -104     
===========================================
- Hits          5765     5225     -540     
- Misses        3065     3501     +436     

@j-c-cook
Copy link
Contributor Author

j-c-cook commented Aug 27, 2022

Now that I've tried out other zip formats:

I'm uncertain what should be done about #1378.

Comment on lines +398 to +402
if type(file) == gzip.GzipFile:
raise ValueError(
f"The BLFWriter is currently incompatible with "
f"{gzip.GzipFile.__name__}s. Try using a different zip format."
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm unaware of any zip format that could be made compatible with the current implementation of BLFWriter.

@j-c-cook j-c-cook marked this pull request as draft August 27, 2022 22:38
@j-c-cook j-c-cook changed the title Raise error when blf GzipFile is requested Address blf GzipFile negative seek error Aug 27, 2022
@zariiii9003
Copy link
Collaborator

I would move the check here:

real_suffix = pathlib.Path(filename).suffixes[-2].lower()

A comparison of real_suffix against a list of incompatible suffixes (all binary formats) should be sufficient.

I'd suggest to release 4.1.0 once this one is merged.

@j-c-cook j-c-cook marked this pull request as ready for review October 31, 2022 17:36
@j-c-cook
Copy link
Contributor Author

@zariiii9003 Okay, I made modifications.

@j-c-cook
Copy link
Contributor Author

j-c-cook commented Nov 5, 2022

@zariiii9003 tests are passing. Ready for your review.

Copy link
Collaborator

@pierreluctg pierreluctg left a comment

Choose a reason for hiding this comment

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

Hi @j-c-cook, why are we also removing GZip support for the other formats? I was under the impression that this PR was only to remove GZip for the BLF format, wich make sense because already uses compression internally and GZip is not really necessary.

Anything wrong with for example the ASC GZip support?

@pierreluctg pierreluctg added the file-io about reading & writing to files label Nov 10, 2022
@j-c-cook
Copy link
Contributor Author

@pierreluctg I've made a mistake here. I'll open up a new PR.

@j-c-cook j-c-cook closed this Nov 11, 2022
@j-c-cook j-c-cook deleted the issue1378_handleblfgz branch November 12, 2022 02:20
j-c-cook added a commit to j-c-cook/python-can that referenced this pull request Nov 12, 2022
@j-c-cook
Copy link
Contributor Author

@pierreluctg @zariiii9003 This PR is now migrated to #1429.

@felixdivo felixdivo added the bug label Nov 13, 2022
@felixdivo felixdivo added this to the 4.1.0 Release milestone Nov 13, 2022
zariiii9003 added a commit that referenced this pull request Nov 13, 2022
* Add gzip check to compress method

Addresses @zariiii9003 from #1385 (comment)

* Update can/io/logger.py

Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>

* Update logger.py

Co-authored-by: zariiii9003 <52598363+zariiii9003@users.noreply.github.com>
@zariiii9003 zariiii9003 removed this from the 4.1.0 Release milestone Feb 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug file-io about reading & writing to files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GzipFile BLFWriter negative seek error

4 participants