-
Notifications
You must be signed in to change notification settings - Fork 88
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
Import tracking #66
Import tracking #66
Conversation
statements that were used in end-user scripts. Helper functions _get_cova_imports, _get_imports_from_source, _scan_source_files, and parse_source_for_imports were added to _shared_files/utils.py to help get external imports. _write_dispatch_to_python_file now inccludes external import statements that were used in end-user scripts. A helper function, _remove_import_dupes, was written to remove duplicate entries from the result of _write_dispatch_to_python_file Added function get_imports to executors/base.py which is just a call to imports_from_sources in utils.py.
being included in serialization strings.
(dispatch_source.py) created in _write_dispatch_to_python_file.
Codecov Report
@@ Coverage Diff @@
## develop #66 +/- ##
===========================================
+ Coverage 71.50% 72.46% +0.95%
===========================================
Files 27 27
Lines 1509 1565 +56
===========================================
+ Hits 1079 1134 +55
- Misses 430 431 +1
Continue to review full report at Codecov.
|
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.
I'm getting a problem in a very simple example, written in the Python console, which is not inspectable:
import covalent as ct
from covalent._shared_files.utils import get_serialized_function_str
@ct.electron
def test_func(input1: str, input2: int) -> str:
return f"{input1} {input2}"
funcstr = get_serialized_function_str(test_func)
print(funcstr)
This says the source is not inspectable.
@jkanem make sure all your commits use the email associated with your GitHub account. You can do this with |
_write_dispatch_to_python_file.
The main work-horse of this functionality is the inspect module. Which works with files. Trying to use it in a console |
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.
For the following workflow ran on a jupyter notebook,
import covalent as ct
@ct.electron
def sample_task(x):
"""Sample task."""
return x ** 2
@ct.lattice
def sample_workflow(a, b):
"""Sample workflow."""
c = sample_task(a)
d = sample_task(b)
return c, d
Sadly the dispatch_source
file that I'm getting contains a huge list of imports. Maybe there is an already open issue for that or maybe we want to solve it in this one, I'm not sure.
Fixed typo in docstring in executor/base.py (get_imports).
This is a Jupyter issue; Jupyter is external to the covalent code-base, and is seen as part of the end-user scripts. Possibly, making this work with Jupyter should be a separate issue. |
I agree. Just curious, were you able to reproduce this too? |
@jkanem Approved! Looks great, I'll merge this to develop once the tests pass and its synced with develop. |
We'll need to fix the slowdown caused by get_serialized_str
before this gets merged as it will make things worse.
flag whose default is False.
import statements in the serialized string.
now determined by a configuration parameter. Added some if/then clauses in the import scanning in order to avoid errors.
… that determines whether imports are scanned in get_serialized_function_str.
I think this is ready for another look. The scanning for imports is now behind a configuration parameter in the
I'm open to a different name or section. |
This shouldn't be merged until #92 is. |
This PR is now deprecated by #123 |
The serialization of the workflow, which results in dispatch_source.py, now includes imports from files external to the Covalent code-base.