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

Unit tests for staging datasets #258

Merged
merged 8 commits into from
Mar 15, 2023
Merged

Unit tests for staging datasets #258

merged 8 commits into from
Mar 15, 2023

Conversation

ebezzi
Copy link
Member

@ebezzi ebezzi commented Mar 14, 2023

Add unit tests for these 3 functions:

  1. build_step1_get_source_datasets
  2. source_assets
  3. load_manifests

@ebezzi ebezzi marked this pull request as draft March 14, 2023 19:57
@codecov
Copy link

codecov bot commented Mar 14, 2023

Codecov Report

Merging #258 (043e063) into main (4e6fa5f) will increase coverage by 6.53%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main     #258      +/-   ##
==========================================
+ Coverage   85.07%   91.61%   +6.53%     
==========================================
  Files          29       33       +4     
  Lines        1682     1919     +237     
==========================================
+ Hits         1431     1758     +327     
+ Misses        251      161      -90     
Flag Coverage Δ
unittests 91.61% <100.00%> (+6.53%) ⬆️

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

Impacted Files Coverage Δ
tools/cell_census_builder/tests/conftest.py 100.00% <100.00%> (ø)
tools/cell_census_builder/tests/test_builder.py 100.00% <100.00%> (ø)
tools/cell_census_builder/tests/test_manifest.py 100.00% <100.00%> (ø)
...ls/cell_census_builder/tests/test_source_assets.py 100.00% <100.00%> (ø)

... and 7 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@ebezzi ebezzi marked this pull request as ready for review March 14, 2023 20:42
@@ -11,6 +11,10 @@
from .mp import cpu_count, create_process_pool_executor


def _get_n_workers() -> int:
Copy link
Member Author

Choose a reason for hiding this comment

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

Required for testing. In GHA, running with more than 1 worker causes the test to fail.

Copy link
Contributor

@bkmartinjr bkmartinjr Mar 14, 2023

Choose a reason for hiding this comment

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

Can you point me at more information on this constraint? I'm trying to understand why it would fail on GHA.

If it is the case that GHA processes may not fork more than some limited number of child processes, we would be better off just testing this with the command line arg (args param) with a --max-workers 1. This is the only code that calls create_process_pool_executor with the optional override, and it only affects the behavior when args lacks a max_workers value.

This all seems cleaner / simpler than a mock, at least IMHO :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

The error is here:
concurrent.futures.process.BrokenProcessPool: A process in the process pool was terminated abruptly while the future was running or pending.
I didn't notice that the max_workers can be specified in args. Will use that. I'm not sure it's worth investigating the issue above - in my experience testing doesn't always play well with multiprocessing, so since this test isn't specifically meant to test multiprocessing, I think we can just disable it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, this means something killed the child process. Commonly this is an out-of-memory condition on the system, or something else that causes an uncontrolled failure (segv, etc). Super hard to diagnose in that environment.

Copy link
Contributor

@bkmartinjr bkmartinjr left a comment

Choose a reason for hiding this comment

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

Super minor changes requested. Overall it is looking good.

@ebezzi ebezzi requested a review from bkmartinjr March 15, 2023 15:12
Copy link
Contributor

@bkmartinjr bkmartinjr left a comment

Choose a reason for hiding this comment

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

LGTM!

@ebezzi ebezzi merged commit 0f18f94 into main Mar 15, 2023
@ebezzi ebezzi deleted the ebezzi/main-unit-tests branch March 15, 2023 16:05
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