Skip to content

feat: add --compression none for decompression support (#66)#78

Open
DhanashreePetare wants to merge 2 commits into
dbpedia:gsoc-2026from
DhanashreePetare:gsoc-2026
Open

feat: add --compression none for decompression support (#66)#78
DhanashreePetare wants to merge 2 commits into
dbpedia:gsoc-2026from
DhanashreePetare:gsoc-2026

Conversation

@DhanashreePetare

Copy link
Copy Markdown
Collaborator

Pull Request

Description

Adds --compression none as a valid value for the --compression flag, enabling users to decompress downloaded files without recompressing them to another format.
Previously, --compression only supported bz2, gz, and xz — meaning users could convert between compression formats or compress uncompressed files, but had no way to simply decompress a file and save it as-is. With this change, --compression none decompresses the file and saves it without any compression extension.

# Download a bz2 file and save it uncompressed
databusclient download https://databus.dbpedia.org/dbpedia/mappings/mappingbased-literals/2022.12.01/mappingbased-literals_lang=az.ttl.bz2 --compression none
# Result: mappingbased-literals_lang=az.ttl (no compression)

If the file is already uncompressed, --compression none is a no-op.

Related Issues
closes #66

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • This change requires a documentation update
  • Housekeeping

Checklist:

  • My code follows the ruff code style of this project.
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation (if applicable)
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
    • poetry run pytest - all tests passed
    • poetry run ruff check - no linting errors

@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b9d196b8-3752-43f8-8fbd-48ea967e2393

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment on lines +741 to +742
# 'none' means no recompression after format conversion
final_compression = None if compression.lower() == "none" else compression

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When a compressed file already matches the requested --format (for example file.ttl.bz2 --format ttl --compression none), the earlier same-format branch returns before reaching this new none guard and passes "none" into _convert_compression_format, which rejects it as an unsupported target format

databusclient download https://databus.dev.dbpedia.link/fhofer/gsoc26/test-data/v1.0/test-data_count=9.nq.bz2 --format nq --compression non
e
SPARQL endpoint https://databus.dev.dbpedia.link/sparql
Downloading file: https://databus.dev.dbpedia.link/fhofer/gsoc26/test-data/v1.0/test-data_count=9.nq.bz2
Local directory not given, using /home/fhofer/ddrive/dev/infai/dbpedia/databus-python-client/fhofer/gsoc26/test-data/v1.0
Download file: https://databus.dev.dbpedia.link/fhofer/gsoc26/test-data/v1.0/test-data_count=9.nq.bz2
Redirects url:  https://raw.githubusercontent.com/Integer-Ctrl/gsoc-2026/refs/heads/main/test-data/sample.nq.bz2
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 353/353 [00:00<00:00, 831kiB/s]
Error: Unsupported target compression format: none. Supported formats: ['bz2', 'gz', 'xz']

Result: test-data_count=9.nq.bz2 is downloaded

Comment on lines +223 to +241
def test_decompress_bz2_to_plain():
"""--compression none on bz2 file produces plain uncompressed file."""
with tempfile.TemporaryDirectory() as tmpdir:
test_data = b"Decompression test data" * 50

bz2_file = os.path.join(tmpdir, "test.txt.bz2")
with bz2.open(bz2_file, "wb") as f:
f.write(test_data)

plain_file = os.path.join(tmpdir, "test.txt")
with bz2.open(bz2_file, "rb") as sf:
with open(plain_file, "wb") as tf:
shutil.copyfileobj(sf, tf)
os.remove(bz2_file)

assert not os.path.exists(bz2_file)
assert os.path.exists(plain_file)
with open(plain_file, "rb") as f:
assert f.read() == test_data

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Test seams useless. It only proves that Python’s bz2.open plus shutil.copyfileobj works, so it
would pass even if the actual implementation were broken. I would expect that a method is called for this, e.g. _convert_compression_format or whatever is responsible for this. Please refactor

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.

2 participants