Using Git files in Python (2023-09-26 10:40:32)
One of the ways to store project files and functions in different versions is GitHub. Now, if we want to reuse these files in our own Python projects, we need a functional script. which we will get to know later.
We consider three steps for this. We have to clone the relevant repository from Git. Move the relevant folder or files out of it and delete the folder containing the extra files. Finally, call the existing functions. Since these codes are different for Windows and Linux, we will present them separately as a practical example.
#Windows OS
import os
os.system("git clone https://github.com/dmahdipour/pytorch")
os.system("move pytorch/py_functions .")
os.system("rmdir /s /q pytorch")
from py_functions import data_setup, engine)
#Linux OS
import os
os.system("git clone https://github.com/dmahdipour/pytorch")
os.system("mv pytorch/py_functions .")
os.system("rm -rf pytorch")
from py_functions import data_setup, engine
Comments