Skip to content

Mocking utils test - #107

Merged
frheault merged 15 commits into
tee-ar-ex:masterfrom
frheault:mocking_utils_test
Aug 17, 2026
Merged

Mocking utils test#107
frheault merged 15 commits into
tee-ar-ex:masterfrom
frheault:mocking_utils_test

Conversation

@frheault

Copy link
Copy Markdown
Collaborator

Experiment with MagicMock, more to follow

@codecov

codecov Bot commented Aug 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.72222% with 37 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.92%. Comparing base (51efc18) to head (9e31bcb).
⚠️ Report is 4 commits behind head on master.

Files with missing lines Patch % Lines
trx/tests/test_utils.py 93.50% 18 Missing ⚠️
trx/tests/test_io.py 11.76% 15 Missing ⚠️
trx/io.py 50.00% 2 Missing ⚠️
trx/tests/test_cli.py 91.30% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #107      +/-   ##
==========================================
+ Coverage   63.57%   70.92%   +7.34%     
==========================================
  Files          12       13       +1     
  Lines        2570     2879     +309     
==========================================
+ Hits         1634     2042     +408     
+ Misses        936      837      -99     
Flag Coverage Δ
unittests 70.92% <89.72%> (+7.34%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI and others added 8 commits August 11, 2026 13:29
@frheault

frheault commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator Author

@arokem I finally came back to this ! (and updated with master)

Could be useful to have this before moving out the materials to TRX-UTILS side repo.

@arokem

arokem commented Aug 11, 2026

Copy link
Copy Markdown
Collaborator

Yes, agreed. Is this still WIP or do you want me to review / merge?

@frheault frheault changed the title (WIP) Mocking utils test Mocking utils test Aug 11, 2026
@frheault

Copy link
Copy Markdown
Collaborator Author

Ready for review !

@arokem arokem left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks good! I spotted some smoketests, which could be made stronger, if you feel that's merited. Also, could use some explanation about the changes in workflows.py.

Comment thread trx/tests/test_utils.py
with tempfile.TemporaryDirectory() as tmpdir:
tmp_name = os.path.join(tmpdir, "test.mmap")
mmap_arr = np.memmap(tmp_name, dtype="float32", mode="w+", shape=(10,))
close_or_delete_mmap(mmap_arr)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This is just a smoke test for now. Do you want to assert anything about the file after this operation/

Comment thread trx/tests/test_utils.py
seq._offsets = offsets
seq._lengths = np.array([2, 2, 2, 2, 2], dtype="uint32")

close_or_delete_mmap(seq)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Same comment here: for now, this is just a smoke test, so maybe add an assertion on properties of the mmap/file.

Comment thread trx/workflows.py
dtype=dict_dtype[key][key_dpv],
mode="w+",
shape=trx.data_per_vertex[key_dpv]._data.shape,
with get_trx_tmp_dir() as tmp_dir_name:

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

What is this change all about?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

My usage of tempfile.NamedTemporaryFile() was failling on Windows GitHub actions (because of the path not being writable and having no fallback). So the creation of a temp memmap was moved to a function that works slightly differently (instead of creating a temp file using the library, it creates a temp file inside an already created temp_dir.

This is safer, in general, in case of usage on a cluster, shared machine or virtual machine (which is why it was failling on Windows tests), but this big change is just the same small changes for each kind of data store in TRX (which makes it look major)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for explaining!

@frheault
frheault merged commit 98bb94d into tee-ar-ex:master Aug 17, 2026
16 checks passed
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