-
Notifications
You must be signed in to change notification settings - Fork 639
Fix Pipeline reference leak in PythonFunction. #5668
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
Conversation
Signed-off-by: Michal Zientkiewicz <[email protected]>
if _Pipeline.current(): | ||
self._pipeline = weakref.ref(_Pipeline.current()) | ||
else: | ||
self._pipeline = None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do a very similar thing in ops._OperatorInstance
.
CI MESSAGE: [19141292]: BUILD STARTED |
…ThreadPool. Signed-off-by: Michał Zientkiewicz <[email protected]>
def verify_pipeline(pipeline, input): | ||
assert pipeline is Pipeline.current() | ||
return input | ||
|
||
|
||
def test_current_pipeline(): | ||
pipe1 = Pipeline(13, 4, 0) | ||
with pipe1: | ||
dummy = types.Constant(numpy.ones((1))) | ||
output = fn.python_function(dummy, function=lambda inp: verify_pipeline(pipe1, inp)) | ||
pipe1.set_outputs(output) | ||
|
||
pipe2 = Pipeline(6, 2, 0) | ||
with pipe2: | ||
dummy = types.Constant(numpy.ones((1))) | ||
output = fn.python_function(dummy, function=lambda inp: verify_pipeline(pipe2, inp)) | ||
pipe2.set_outputs(output) | ||
|
||
pipe1.build() | ||
pipe2.build() | ||
pipe1.run() | ||
pipe2.run() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- It's illegal to capture the pipeline.
- Now there's a stub in pipeline.current - not the same object, so the test is invalid.
CI MESSAGE: [19155838]: BUILD STARTED |
CI MESSAGE: [19155838]: BUILD FAILED |
CI MESSAGE: [19141292]: BUILD FAILED |
Signed-off-by: Michal Zientkiewicz <[email protected]>
CI MESSAGE: [19172437]: BUILD STARTED |
CI MESSAGE: [19172437]: BUILD PASSED |
Category:
Bug fix (non-breaking change which fixes an issue)
Description:
This PR removes a back-link from PythonFunction operator to the pipeline, which caused the pipeline to not be properly shut down and leaking resources.
For backward compatibility, a pipeline stub is exposed, carrying the same properties as the original pipeline, but with the native pipeline removed and functions depending on the native pipeline short-circuited to throw an exception.
Additional information:
Affected modules and functionalities:
PythonFunction and its flavors
It's officially illegal now to hold a reference to the Pipeline in PythonFunction's
function
. Some tests that depended on that were removed.Key points relevant for the review:
N/A
Tests:
Checklist
Documentation
DALI team only
Requirements
REQ IDs: N/A
JIRA TASK: N/A