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

Hot fix for python bindings failing (resolve #104) #102

Merged
merged 6 commits into from
Mar 5, 2025
Merged

Conversation

nleroy917
Copy link
Member

@nleroy917 nleroy917 commented Mar 5, 2025

Todo:

  • Bump version
  • Update changelog
  • Test python digests API

Issue for tracking: #104

To test the python API, I will emulate the Rust API tests:

import sys
from gtars.digests import sha512t24u_digest, md5_digest, digest_fasta

digest = sha512t24u_digest(b"hello world")
print("sha512t24u_digest(b'hello world') =>", digest)
assert digest == "MJ7MSJwS1utMxA9QyQLytNDtd-5RGnx6"

# Test sha512t24u_digest on str
digest = sha512t24u_digest("hello world")
print("sha512t24u_digest('hello world') =>", digest)
assert digest == "MJ7MSJwS1utMxA9QyQLytNDtd-5RGnx6"

# Test md5_digest
digest = md5_digest("hello world")
print("md5_digest('hello world') =>", digest)
assert digest == "5eb63bbbe01eeed093cb22bb8f5acdc3"

# Test digest_fasta on an uncompressed file
results = digest_fasta("gtars/tests/data/base.fa")
print("digest_fasta('gtars/tests/data/base.fa') =>", results)
assert len(results) == 3
assert results[0].length == 8
assert results[0].sha512t24u == "iYtREV555dUFKg2_agSJW6suquUyPpMw"
assert results[0].md5 == "5f63cfaa3ef61f88c9635fb9d18ec945"

assert results[1].length == 4
assert results[1].sha512t24u == "YBbVX0dLKG1ieEDCiMmkrTZFt_Z5Vdaj"
assert results[1].md5 == "31fc6ca291a32fb9df82b85e5f077e31"

assert results[2].length == 4
assert results[2].sha512t24u == "AcLxtBuKEPk_7PGE_H4dGElwZHCujwH6"
assert results[2].md5 == "92c6a56c9e9459d8a42b96f7884710bc"

# Test digest_fasta on a gzipped FASTA
results_gz = digest_fasta("gtars/tests/data/base.fa.gz")
print("digest_fasta('gtars/tests/data/base.fa.gz') =>", results_gz)
assert results_gz[0].length == 8
assert results_gz[0].sha512t24u == "iYtREV555dUFKg2_agSJW6suquUyPpMw"
assert results_gz[0].md5 == "5f63cfaa3ef61f88c9635fb9d18ec945"

# Test error handling
try:
    digest_fasta("gtars/tests/data/bogus.fa")
    # If we reach here, no error was raised, so fail
    print("Expected error for bogus file but none raised!")
    sys.exit(1)
except Exception as e:
    print("Got expected error for bogus file:", e)

print("All tests passed!")

Copy link

codecov bot commented Mar 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 62.36%. Comparing base (d345694) to head (9be1f90).
Report is 8 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #102   +/-   ##
=======================================
  Coverage   62.36%   62.36%           
=======================================
  Files          38       38           
  Lines        6438     6438           
=======================================
  Hits         4015     4015           
  Misses       2423     2423           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nleroy917
Copy link
Member Author

Seems to be good -- will bump version and release

@nleroy917 nleroy917 changed the title Hot fix for python bindings failing Hot fix for python bindings failing (resolve #104) Mar 5, 2025
@nleroy917 nleroy917 merged commit de2ac00 into master Mar 5, 2025
4 checks passed
@nleroy917 nleroy917 deleted the hf_to_str branch March 5, 2025 20:04
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.

1 participant