Skip to content
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

Fix scripts not executing #449

Merged
merged 1 commit into from
Aug 4, 2022
Merged

Fix scripts not executing #449

merged 1 commit into from
Aug 4, 2022

Conversation

renato145
Copy link
Contributor

I noticed my scripts using @call_parse where not working because when checking if the script was being called from main there was some quotes missing in the code:
if getattr(mod, __name__, '') =="__main__": ...
instead of:
if getattr(mod, '__name__', '') =="__main__": ...

@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@jph00 jph00 merged commit cbfe41b into fastai:master Aug 4, 2022
@jph00 jph00 added the bug Something isn't working label Aug 4, 2022
@renato145 renato145 deleted the fix-call-parse branch August 4, 2022 23:41
@yegeniy
Copy link

yegeniy commented Aug 8, 2022

Interesting. Thanks @renato145.
I think this caused a hack I had to get around this issue to regress.

Mentioning that only in case someone else was using fastcore's call_parse with PySpark (or a similar indirect runner). Having something like this at the bottom of each script shouldn't be necessary anymore:

#|export
#|eval: false

# This is a hack because spark-submit doesn't actually play nice with fastcore's call_parse out of the box
# https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/deploy/PythonRunner.scala#L75
# https://github.com/fastai/fastcore/blob/1dc01246e4553487157099221f0085676919d746/nbs/08_script.ipynb

if __name__ == "__main__":
  locals().get("my_method")()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants