Pybricks lets you run MicroPython scripts on the hub. Once loaded onto the hub, you can just start the script again by pressing the button. No constant connection required.
You can even add sensors that count the track sleepers so you can get a constant speed no matter the load. Here's a demo with code.