The PR contains rewrite of the code for loading IPython-style startup files. The changes are intended to fix a number of existing problems with loading of scripts. The existing startup scripts written for the previous version are expected to work with the new version without changes. The functions for loading modules, Python scripts and uploading scripts were modified to handle exceptions consistent with the new version of the IPython script loading code.
Description
The new code for loading scripts is based on exec instead of runpy. The changes are expected to fix the following issues observed with the previous version:
Functions that are defined in a script file may now use objects or call functions that are defined in subsequent files. This is the behavior of IPython, which we are trying to emulate. For example if we load a sequence of two files f1.py and f2.py:
# f1.py
def func1():
func2()
and
# f2.py
def func2():
pass
and those files are loaded in alphabetical order into the namespace, the call func1() is successful with the new version of the code and fails with the old version.
In case of an exception raised while loading the script, the traceback shows correct file names and line numbers. The traceback used to refer to a patched file in temporary location.
In case of an exception raised while executing a function or a plan, the traceback also shows correct file names and line numbers.
Motivation and Context
Summary of Changes for Release Notes
Fixed
Added
Changed
Improved handling of IPython-style startup scripts.
Removed
How Has This Been Tested?
A number of unit tests were implemented to test for the new functionality.
The PR contains rewrite of the code for loading IPython-style startup files. The changes are intended to fix a number of existing problems with loading of scripts. The existing startup scripts written for the previous version are expected to work with the new version without changes. The functions for loading modules, Python scripts and uploading scripts were modified to handle exceptions consistent with the new version of the IPython script loading code.
Description
The new code for loading scripts is based on
exec
instead ofrunpy
. The changes are expected to fix the following issues observed with the previous version:Functions that are defined in a script file may now use objects or call functions that are defined in subsequent files. This is the behavior of IPython, which we are trying to emulate. For example if we load a sequence of two files
f1.py
andf2.py
:and
and those files are loaded in alphabetical order into the namespace, the call
func1()
is successful with the new version of the code and fails with the old version.In case of an exception raised while loading the script, the traceback shows correct file names and line numbers. The traceback used to refer to a patched file in temporary location.
In case of an exception raised while executing a function or a plan, the traceback also shows correct file names and line numbers.
Motivation and Context
Summary of Changes for Release Notes
Fixed
Added
Changed
Removed
How Has This Been Tested?
A number of unit tests were implemented to test for the new functionality.