Commit b95a5ea
Force MLflow URI override in xdist workers to prevent yaml race
The previous attempt set MLFLOW_TRACKING_URI per-worker in
pytest_configure, guarded by 'if MLFLOW_TRACKING_URI not in os.environ'.
That guard hid a subtle bug:
1. The main pytest process runs pytest_configure first, sees the
env var is unset, and exports file:///tmp/flaml_mlruns_main_PID.
2. xdist worker subprocesses (gw0, gw1) inherit that env var from
the main process.
3. When each worker re-runs pytest_configure, the guard now
evaluates to True (the var IS set), so workers skip the
override and end up sharing the main process's tracking dir.
4. Concurrent writes from both workers to the same
EXP/RUN/meta.yaml produce partial files, triggering
'yaml.parser.ParserError: while parsing a block mapping' in
every subsequent FLAML+MLflow test on that worker.
Fix: in xdist workers, force-override the URI when the inherited
value is one we previously set (path contains 'flaml_mlruns_');
externally-set URIs (e.g. by the user) are still respected. The new
per-worker path is 'flaml_mlruns_WORKER_PID'.
Verified locally: 'pytest test/fabric/test_mlflow_coverage.py -n 2
--dist=loadfile' now creates per-worker dirs (flaml_mlruns_gw0_*
distinct from main) and all 66 tests pass.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 8fba35a commit b95a5ea
1 file changed
Lines changed: 16 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
26 | 38 | | |
| 39 | + | |
27 | 40 | | |
28 | | - | |
| 41 | + | |
29 | 42 | | |
30 | 43 | | |
31 | 44 | | |
32 | 45 | | |
33 | 46 | | |
34 | 47 | | |
35 | 48 | | |
36 | | - | |
| 49 | + | |
37 | 50 | | |
38 | 51 | | |
39 | | - | |
40 | | - | |
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
| |||
0 commit comments