fix(enterprise): detect_label_issues no longer hangs from unguarded scripts; FPE tests pass with pyffx - #433
Merged
Conversation
…est FPE with and without pyffx detect_label_issues passed cleanlab's default n_jobs, which starts one worker per core. On spawn platforms (macOS, Windows) a call from a plain script without a __main__ guard re-imported the script in every worker and never returned. Default n_jobs to 1; an explicit n_jobs is passed through. test_fpe_falls_back_to_surrogate_without_crypto asserted the surrogate mode without hiding pyffx, so it failed whenever the [privacy] or [all] extra was installed. Hide pyffx in that test and add a test for the crypto_fpe path when pyffx is present.
Contributor
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 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. Comment |
FreshData benchmark report —
|
| fixture | n_rows | n_cols | p50 s | p95 s | peak MB | repair % | false-repair % | preserve % | trust | monotonic | export % |
|---|
Authored-code reduction (Metric 6)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two problems that only appear when optional extras are installed. Both were found by the extras install campaign (FDC-L2-003, FDC-L2-004).
detect_label_issuescould hang forever. With the[cleanlab]extra on macOS, calling it from a plain script that has noif __name__ == "__main__"guard never returned.[privacy]or[all]extra.test_fpe_falls_back_to_surrogate_without_cryptofailed whenever those extras were installed, so CI with them was red.Root cause
find_label_issuesat its defaultn_jobs=None, which starts one worker per core.spawn, and each worker re-imports__main__.detect_label_issues. Multiprocessing then raised itsfreeze_supportRuntimeError in a loop and the call never returned.pyffx. Withpyffxinstalled (it ships in[privacy]and[all]),fpe_modeiscrypto_fpe.Behaviour change
detect_label_issuesnow passesn_jobs=1unless the caller setsn_jobs.n_jobs: passed through unchanged.detect_outliers: unchanged. cleanlab'sOutOfDistributiondoes not use multiprocessing.Default-output changes
None. Results are identical.
detect_label_issuesruns in one process unlessn_jobsis given, which can be slower on very large inputs.Tests
tests/test_enterprise_cleaner.py:n_jobs=1by default and keeps an explicitn_jobs=4.detect_label_issuesexits 0 and prints[2], with a 120 s timeout.tests/test_enterprise_privacy.py:pyffxwithmonkeypatch.setitem(sys.modules, "pyffx", None)and asserts the exact surrogate mode string. The oldstartswithcheck was loose, andsurrogate_format_preserving_not_crypto_fpecontainscrypto_fpeas a substring.test_fpe_uses_crypto_when_pyffx_is_installedassertscrypto_fpewith the length and all-digit format preserved. It is skipped whenpyffxis absent.Verification
ruff checkandmypyon the changed files: clean.tests/test_enterprise_cleaner.pyandtests/test_enterprise_privacy.pypassed in:[cleanlab]py3.12 venv (cleanlab 2.9.0), where the real unguarded-script test runs[privacy]venvs on py3.12 and py3.9 (pyffx installed), where both FPE tests runFDC-L2-003-cleanlab-module-level-hang.pyagainst this branch: the unguarded script exits 0 after about 2 s. Onmainit was still running after 60 s and had to be killed.