How can I change my Python scripts and simultaneously running bash script, without the bash script picking up on the new changes?
For example I run bash script.sh whose content is

python train1.py
python train2.py

While train1.py is running, I edit train2.py. This means that train2.py will use the old code not the new one.
How to set up such that train2.py uses the old code?
Running and editing on two different PCs is not really a solution since I need the GPU to debug for editting. Merging them is also not a good idea because of the abstraction.
Specs:
Remote Server
Ubuntu 20.04
Python - Pytorch
I imagine there is some git solution but have not found one.
Any changes done to train2.py, which are commited to disk before the bash script executes train2.py will be used by the script.
There is no avoiding that because contents of train2.py are not loaded into memory until the shell attempts to execute train2.py .  That behaviour is the same regardless of the OS distro or release.
Keep the "master" for train2.py in a sub-directory, then have the bash script remove train2.done at the start of the script, and touch train2.done when it has completed that step.
Then have a routine that only "copies" train2.py from the subdir to the production dir if it sees the file train2.done is present, and wait for it if it missing.
If you are doing this constantly during repeated runs of the bash script, you probably want to have the script that copies train2.py touch train2.update before copying the file and remove that after successful copy of train2.py ... then have the bash script check for the presence of train2.update and if present, go into a loop for a short sleep, then check for the presence again, before continuing with the script ONLY if that file has been removed.
Editing Python scripts while running bash script that contains the Python scripts