Make task try to open input locally before going over the network.

I noticed that my pipeline jobs were always opening the input's first replica, even if the input existed locally.  This fixes that and if the file is not local, it tries the other replicas in random order rather than always using the first.

Also I had issues with getting the global Task to work correctly with `__globals__`, and switched it to use a module global.