Update tasks.py

Using globals so any import in the executed script can be used in the script scope (otherwise will use locals)
adding ctx to globals exposes the context to the script even with the new setup