The Ultimate Guide to Setting up GitHub Codespaces for Ivy š„: Resolving Common Issues
Table of Contents-
- Introduction š
- Reason for writing this blog āļø
- Step by Step explanation to setup codespaces for Ivy (with screenshots)
- Important points to consider ā ļø
- References
- Connect with me! ā¤ļø
1. Introduction š
Ivy is an open source organization which unifies all existing ML frameworks, enabling framework-agnostic functions, layers and libraries. As it is open source, you can contribute to Ivy on GitHub. I am an open source contributor for Ivy and contributes on a daily basis, interact with the community on their Discord handle as well.
2. Reason for writing this blog āļø
When I decided to contribute to Ivy, there were several methods to setup Ivy and start contributing. Out of all those methods, ācodespacesā found out to be easy to setup. I followed the Official Setting Up docs of Ivy for codespaces, but after following each and every step, I was unable to setup the codespaces for Ivy. (The ivy docs for setting up are updated for codespace now and you can refer these docs here.)
I went on to Ivyās discord and shoot the problem to the Ivy community. The engineers and the whole community is very supportive and they gave me solutions to solve this issue. Also, I noticed a lot of other folks were facing the same issue which I was facing.
So whenever anyone faced this issue, people use to help that person by telling the same solution again and again, which I found to be repetitive and time consuming. So I decided to write this blog, whenever people will come with this setup issue, we can direct them to this blog. š
3. Step by Step explanation to setup codespaces for Ivy (with screenshots) š±
- Go to Ivyās github repo, fork the repository. Select code option. Youāll be able to see 2 options- Local and Codespaces. Select Codespaces option. After that select the kebab option (3 dots).
2. After clicking on kebab, click on āNew with optionsā¦ā button.
3. A new tab will pop up asking you to create codespace for your repo (in this case, Ivy repo). here, we need to make changes in āDev container configurationā. Click on āDefault project configurationā and select āIvy Development Environment (image)ā.
4. Click on āCreate codespaceā button.
5. It will start setting up your Codespace. This process of building the container (Ivy dev env image) takes a good amount of time. So take a break, have some water ! ā±ļø (Maybe go on a vacation, kidding. š)
6. After building the container, codespaces will get opened. This is what youāll see, a readme file, a terminal and the explorer on the left side.
7. (Optional) White themed code editors makes me sick š¤ So I just changed the theme of the codespaces to one of the dark themes. Now it looks good š
8. Now go to Settings (present in bottom left corner) and select Command Palette option (you can also open it using Ctrl+Shift+P) and search āpython interpreterā and click on āPython: Select Interpreterā.
9. Youāll be able to see different interpreters available for python. Select āPython 3.10.0 (multienv)ā option.
10. After selecting interpreter, go to file explorer and open _array_module.py file. To go to the file follow this path:
ivy_tests -> array_api_testing -> test_array_api -> array_api_tests -> _array_module.py
11. Make the following code changes on line number 8 and 9. We are setting backend as numpy.
import ivy as array_module
array_module.set_backend('numpy')
12. After making the changes, _array_module.py file will look like this.
13. These all are the changes to successfully setup codespaces for Ivy repository, to be able to contribute.
To check if youāve setup the codespaces correctly, try running some tests for functions in the terminal.
I tried out running test cases for paddle hardshrink activation function. To locate this function, here is the path to the file test_paddle_activation.py in which this function is present:
ivy_tests -> test_ivy -> test_frontends -> test_paddle -> test_nn -> test_functional -> test_paddle_activation.py
To run a test for any function in the terminal, this is the code:
python3 -m pytest <.py file relative_path>::<function_name>
You can see, the tests are running without any issue. Although one of the test case is failing š (jax newer version issue). In this way, you can confirm that youāve setup the codespace in correct way.
4. Important points to consider ā ļø
1. If you are using the free version of the GitHub, you will have limitations on the usage of Codespaces. Check this out- the quotas for codespaces.
2. Due to the limitations for free tier, after using codespaces, donāt forget to stop codespaces, as it continues to be in active state for some time, even after closing the codespaces tab. You can close the running codespaces by following these screenshots.
3. Building the codespaces for the first time takes a good amount of time. But this is one time process. The codespaces will open very fast after the initial container build.
4. The issues people facing before going through this blog (imports error, _array_module.py file cannot be seen in the file explorer, config related error, etc) will be resolved.
5. References
A huge shoutout to Ivy, the engineers working in Ivy, Ivy community. This problem would not have been able to solve without them. Thank you ! ā¤ļø
Ivyās links :- Official website, GitHub, Discord, Medium, Youtube, LinkedIn, Twitter !
6. Connect with me! ā¤ļø
š Thatās a wrap on my technical blog! If you have any questions or need further clarification on the topics covered, feel free to reach out to me. Iām here to help!
If youāre looking for a talented technical writer, Iām available for hire. Letās collaborate and bring your ideas to life! š