ramp v1.0.0
DOCUMENTATION
ToC
VisualStudio Code is an amazing tool. It supports containerized development in so many different ways, and the documents can be confusing. These are instructions for setting up a working containerized dev environment, by attaching VSCode to a running container.
At a high level, here’s how it works.
docker build --tag rampdev -f Dockerfile.dev .
This will build the docker image with all its dependencies except the ramp modules. This allows you to pip install from source inside the running container, and then to do development.
docker run -it --rm --gpus=all -v /home/carolyn/ramp-code:/tf/ramp-code -v /home/carolyn/ramp-code:/tf/ramp-code -p 8888:8888 rampdev bash
You should replace /home/carolyn with your RAMP_HOME path on your own host machine. Note that /home/carolyn is the RAMP_HOME directory on my server, and /tf is RAMP_HOME in the container.
This will open a bash shell in the rampdev container, in the /tf directory.
IMPORTANT NOTE
Note that this container will run as root using the previous command; this is necessary in order for VSCode to install a server in it. This means that new source files that you create in VSCode, in your mounted volumes, will have root user permissions. This can be fixed with 'sudo chown <your_user> <filename> ' on the host system. There is not currently a better solution for this problem.
cd ramp-code
pip install -e .
This will give you a development-ready installation of the ramp modules in your container, from the code you’ve mounted into the container.
You’ll then attach to the same container with VisualStudio Code, using its Remote-Containers extension (you’ll need to be running the container as root in order for VSCode to install itself into the container). Any changes you make to the code base in the process of debugging will be picked up by the debugger.
Start Visual Studio code (assuming it is already installed on your machine: here is the link for installation on Ubuntu)
In VSCode, Open Settings > Extensions (‘Settings’ is the little gear icon on the extreme left panel, at the bottom); select, install, and enable the Remote – Containers extension. The little green icon will appear on the VS Code window at the lower left, as seen below.
Click on the little green icon, and a menu of Remote-Containers commands will come up. Select ‘Attach to Running Container’, and select the rampdev container you started (there is usually only one running at a time anyway).
The green icon at the lower left will now show that you’re attached to the container you selected. Go to the VSCode File Explorer at the top of the panel on the left, and open the ‘/ramp-code’ directory. You are ready to debug!
Select a script to debug from the /tf/ramp-code/scripts directory
Place a debug breakpoint next to any line in the script as you normally would in any debugger. The red dot should appear to the left, as shown below. If it doesn’t appear, you may need to install the ‘Python’ extension (or VSCode may prompt you to do so).
From the top menu, select Run > Start Debugging. The script will run, and should stop when it hits your breakpoint. All the imports should work without any exceptions being thrown.
Spanning Africa, India, and the United States, DevGlobal Partners supports the world’s leading non-profits, companies, philanthropies, multilateral agencies, and government agencies on their innovation and sustainability initiatives
As a constantly growing team, we are always looking for new and diverse talent to expand and strengthen our capabilities.
If you are interested in learning about more ways to contribute please visit our “Careers” page using the button below.
info@dev.global
(425) 448-2658
123 2nd Ave S suite 230 #18
Edmonds, WA 98020