0

When working with AI models because of the long load times, I want do develop with juypter notebook. However, I want to release/publish as a normal python script. You can use the jupyter nbconvert --to py command to convert your notebooks into python scripts.

What are the best patterns to use for this? I came up with

dev_mode = 'ipykernel' in sys.modules

each cell is

def func():
    pass

if dev_mode:
    func()

And the final cell which I never actually run in the notebook.

def main()
    pass

if __name__ == "__main__":
    main()

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.