How to use your forked open-source project in your colab notebook without need to wait for merge and review.

Abeer Yosef
Analytics Vidhya
Published in
3 min readMar 9, 2020

Github has many open source project which has many features that you would need to use it as a predefined readymade framework. Most of the time we need to update open source project for customization, solving an issue, adding new feature and you might need to use this change in your code without need to wait until your change merged to the main branch (by the framework author or contributors).

In the below article I used colab notebook to run my code.

Below are the steps to override the python open source project and use it in your notebook:

In normal cases to install any framework, you should run the below standard statement to use the open-source framework as it is.

Kindly note that tag like this <-frameworkname-> is variable and should be replaced in your code with the real name.

pip install <-frameworkname->

In our case we will not use the above command we will use a different one as explained in the next steps.

Step 1: First to change the framework code press the button ‘Fork’.

Expected behaviour to step 1: Github will copy the repository to your account.

Step 2: Select the file you want to update (by clicking the file name).

Expected behaviour to step 2: The file will be opened.

Step 3: Click the edit icon as the below screenshot

Expected behaviour to step 3: The file will be opened in the edit mode.

Step 4: do the change you want to code and then, enter the commit changes (comment descript the change you did; what and why). Then select create a new branch (in case you don’t want to merge your change to the main branch yet). In the end, click the Green button “Propose the file change”.

Remember the new branch name ex. “abeermohamed1-patch-1” as you will use it in in the next steps.

Expected behaviour to step 4: new branch will be created with applied change.

Step 5: Install the updated framework to your notebook.

Step 5.1: First go to your framework (your forked repository displayed on your account). Then click the green button “Clone or Download”. To reach the repository URL.

Step 5.2: To produce the repository URL. You should copy and clone it as the below screenshot.

Expected behaviour of Step 5.2: the below URL will be copied to

git+https://github.com/abeermohamed1/frameworkname.git

Step 5.3: Then append the branch name mentioned in step 4 to the above copied URL following to “@” symbol. Then append #egg=frameworkname

i.e

<your-repository-URL>+”@”+<your-branch-name>+”#egg=”+”frameworkname”

The expected result: will be as below URL:

pip install -e git+https://github.com/abeermohamed1/frameworkname.git@ abeermohamed1-patch-1#egg=frameworkname

Step 5.4: Run the below command in your colab notebook to install the updated package:

pip install -e git+https://github.com/abeermohamed1/frameworkname.git@ abeermohamed1-patch-1#egg=frameworkname

Step 5.5: go to framework directory

then go to the framework folder using the below command

%cd ‘/content/src/frameworkname’

Step 5.6: Run the below command to compile your change:

!python ‘setup.py’ install

Step 5.7: Congratulation now you can finally use your updated framework.

I hope this is useful. Please let me know if you have any comment :).

Feel free to connect with me on the below:

My Github profile: https://github.com/abeermohamed1

Linkedin: https://www.linkedin.com/in/abeer-mohamed-7a32671b/

--

--