Frequently Asked Questions

I’m importing functions from a Python module, but when I change the module, Bluelake doesn’t see the changes

Placing re-usable functions into your own Python modules can be a good way to share code between automation scripts. For instance, say you have the following two files:

# --- script.py
import bluelake
import mymodule

mymodule.say_hello()


# --- mymodule.py
def say_hello():
    print('Hello')

Running the script from Bluelake should work fine. However, if you now make a change in mymodule.py and run script.py again, you’ll see that Bluelake keeps running the old version.

This is a known limitation of importing Python modules: they are not automatically refreshed if the module’s source file changes. To work around this, you have two options:

  1. Restart Bluelake.

  2. Use the following code to import your module in script.py:

    from importlib import reload
    import mymodule
    reload(mymodule)
    
    mymodule.say_hello()
    

For more information, see the Python documentation of importlib.