Skip to content

Conversation

@CormickKneey
Copy link

Summary

This PR enhances the ORAS Python client to support multiple compression formats by implementing suffix-based compression detection, replacing hardcoded media type comparison with a flexible approach. So we can use this to support various media types (for example, from https://github.com/modelpack/model-spec/blob/main/specs-go/v1/mediatype.go) instead of the original specific one.

Key Changes

1. New Compression Functions (oras/utils/fileio.py)

  • extract_tar(): Handles uncompressed tar archives
  • extract_tar_zstd(): Supports zstd-compressed archives (requires zstandard package)
  • get_compression_from_media_type(): Detects compression format from media type suffixes
  • extract_by_compression(): Generic extraction dispatcher

2. Enhanced Provider Logic (oras/provider.py)

  • Replaced hardcoded media type check with suffix-based detection
  • Dynamic compression format handling based on media type suffixes
  • Proper file extension mapping (.tar.gz, .tar.zst, .tar)

Compression Detection

Uses suffix matching to identify formats:

  • +gzip suffix → gzip compression
  • +zstd suffix → zstd compression
  • .tar suffix → uncompressed tar
  • .raw suffix → raw files (no extraction)
  • Default → gzip (backward compatibility)

Dependencies

  • Optional: pip install zstandard for zstd support

@vsoch
Copy link
Contributor

vsoch commented Jul 18, 2025

Is this something you've discussed with the primary oras maintainers in slack, or is this feature already implemented in oras go?

)

# ModelPack annotations, refer to https://github.com/modelpack/model-spec/blob/main/specs-go/v1/annotations.go
annotation_filepath = "org.cnai.model.filepath"
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
annotation_filepath = "org.cnai.model.filepath"
annotation_filepath = "org.cncf.model.filepath"

to align with latest since Sandboxing.

Ref: https://github.com/modelpack/model-spec/blob/d96289821ac99a777baaec74c8f3ee2625255adc/docs/annotations.md?plain=1#L9

@CormickKneey
Copy link
Author

Is this something you've discussed with the primary oras maintainers in slack, or is this feature already implemented in oras go?

Sorry for the late response — I missed the email. I haven’t discussed this with the primary ORAS maintainers yet. Let me start a thread on Slack later this week!

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.

3 participants