Now I’ll show you how to make changes to the program, and how to upload your changes so that the whole community can benefit from them.
Let’s imagine that you want to add some new functionality to the program. You want it to greet us with “Hello world!” when we run
Create a folder for storing EV-Fleet-Sim’s source code.
Clone the source code from the internet to this folder. We will calll this folder’s directory
git clone https://gitlab.com/eputs/ev-fleet-sim.git <source-dir> # Clone the git repository into the new folder.
Create a python virtual environment for this project.
python -m venv --prompt ev-fleet-sim <source-dir>/.venv/
Activate the virtual environment for this project.
If you haven’t done so before, you may first need to run the following command to allow PowerShell to run scripts:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Install the program in “developer-mode”.
pip install -e <source-dir>
Note: If you are installing the program outside of a virtual environment (not recommended) in Linux or MacOS, then use the following command instead:
pip install --prefix ~/.local/ -e <source-dir>
<source-dir>/src/data_processing_ev/__init__.py in your in your favourite text-editor.
Go down to the line which says:
If that is line
x, insert in line
import time; time.sleep(2) # Wait two seconds after printing the above.
Save the file, open a terminal and run
ev-fleet-sim. It should now say “Hello
world!” before continuing with the program.
NB: Note that you need to activate the virtual environment before running
You will see that
__init__.py defines a function called
run(). This function is
responsible for running the sub-modules corresponding each of the steps.
If you want to edit the functionality of a particular step, you have to open
the module corresponding to that step. Each module is contained in a folder in
<source-dir>/src/data_processing_ev folder. Simply open the folder of that module
and edit its python scripts.
If you have made any changes that are worth contributing back to the main project, we would gratefully accept them. This is how you do it:
Open the EV-Fleet-Sim repository in GitLab, and press the Fork button.
Clone your fork to your PC by running the following command in a terminal (replacing
git clone https://gitlab.com/<user-name>/ev-fleet-sim.git <source-dir-fork>
and then make the changes that you want to make on your fork.
Commit the changes to the local copy of your fork, using the following commands.
git add <file-you-changed>
git add <another-file-you-changed>
git commit -m <a-short-summary-of-the-changes>
Push the commits to the online copy of your fork.
Open your fork’s repository in GitLab and create a merge request. This will notify me that you would like to send some changes (commits) to me. With a few clicks I will be able to accept the changes that I like, and reject the changes that I don’t.
Why don’t you create a fork, do this Hello-World exercise on your fork, and create a pull-request. Of course, I will reject the pull-request, but consider it the “initiation rites” of EV-Fleet-Sim 😉.
Also remember to press the “star” and “notification bell” on the top of the project’s GitLab page. That way, more people will be made aware of the software.