[Runtimes] Fix Pickling in MLRun Function Due to Improper Dynamic Import #5636
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.
https://iguazio.atlassian.net/browse/ML-2872
According to https://docs.python.org/3/library/importlib.html#importing-a-source-file-directly, we were missing a step in how we dynamically import the function handler in the local runtime.
![Screenshot 2024-05-27 at 12 12 17](https://private-user-images.githubusercontent.com/12761913/334039904-8a96157f-dff0-48d4-bb52-40e9c019b8c5.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjE4MzAyMzgsIm5iZiI6MTcyMTgyOTkzOCwicGF0aCI6Ii8xMjc2MTkxMy8zMzQwMzk5MDQtOGE5NjE1N2YtZGZmMC00OGQ0LWJiNTItNDBlOWMwMTliOGM1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI0VDE0MDUzOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTkwOTRkZTg0OTY4N2Q4YTUxZDVlYjE0YzJlMTQ4YzU2MjA3NDEyODYxOTAzOGIwMTljMjlkNWYxZDkxM2QxODcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.jAEbiYYQdGtjv2leY1NKLY2uylLGLZr1nhbAgkdNk88)
After adding the missing step, Pickle works properly within the MLRun Function: