Unanswered
Hi All!
I Have Methods Inside Notebooks That I Made Available To Clis Using Nbdev
Reproducing is simple:
- In a notebook, create a method and decorate it by fastai.script’s
@call_parse
. - Call Task init inside it
- Expose the method with nbdev using settings.ini
- run via bash
The created task contains no repo/branch and has uncommitted changes:
#!/home/ubuntu/miniconda3/bin/python
# EASY-INSTALL-ENTRY-SCRIPT: 'my-package','console_scripts','my-script'
import re
import sys
# for compatibility with easy_install; see #2198
__requires__ = 'my-package'
try:
from importlib.metadata import distribution
except ImportError:
try:
from importlib_metadata import distribution
except ImportError:
from pkg_resources import load_entry_point
def importlib_load_entry_point(spec, group, name):
dist_name, _, _ = spec.partition('==')
matches = (
entry_point
for entry_point in distribution(dist_name).entry_points
if entry_point.group == group and entry_point.name == name
)
return next(matches).load()
globals().setdefault('load_entry_point', importlib_load_entry_point)
if __name__ == '__main__':
sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])
sys.exit(load_entry_point('my-package', 'console_scripts', 'my-script')())
These changes are not in our code base, I suspect they are the result of exporting with bash.
Since this is a key workflow (executing py code via exported script with bash) I wanted to ask if there’s a way to do so without an explicit python entrypoint (what does work is overriding attributes in the task object created so that future tasks in this template will run an actual file. But this still requires a file entrypoint to exist :/)
161 Views
0
Answers
one year ago
one year ago