joeyutong opened a new pull request, #943:
URL: https://github.com/apache/flink-agents/pull/943

   Linked issue: #941
   
   ### Purpose of change
   
   Flink may rematerialize a job's Python dependencies under a new 
`python-dist-*` directory after task failover, while Pemja's process-level main 
interpreter and its import state remain alive in the TaskManager JVM. Existing 
user modules can therefore keep `__file__`, `__path__`, or `__spec__` entries 
that point to the removed dependency directory.
   
   This change activates each job's current dependency generation before 
loading Python actions or resources. When the generation changes, it:
   
   - clears the Flink Agents Python function cache;
   - evicts modules attributed to the previous generation from `sys.modules`;
   - removes stale `sys.path` and importer-cache entries;
   - prepends the current generation's `PYTHONPATH` entries; and
   - preserves modules and paths owned by other active jobs.
   
   The generation is recorded only after the refresh succeeds, so a failed 
refresh is retried on the next initialization.
   
   ### Tests
   
   - `uv run --project python pytest -q 
python/flink_agents/runtime/tests/test_python_dependency.py` (3 passed)
   - `mvn -B --no-transfer-progress -pl runtime -am 
-Dtest=PythonDependencyGenerationManagerTest 
-Dsurefire.failIfNoSpecifiedTests=false test` (1 passed)
   - Maven Spotless formatting/checks passed as part of the Java verification
   
   ### API
   
   No public API changes.
   
   ### Documentation
   
   - [ ] `doc-needed`
   - [x] `doc-not-needed`
   - [ ] `doc-included`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to