Welcome to the INFO-5940 repository! This guide will help you set up the development environment using Docker in VS Code, configure the OpenAI API key, manage Git branches, and run Jupyter notebooks for assignments.
Before starting, ensure you have the following installed on your system:
- Docker (Ensure Docker Desktop is running)
- VS Code
- VS Code Remote - Containers Extension
- Git
- OpenAI API Key
Open a terminal and run:
git clone https://github.com/AyhamB/INFO-5940.git
cd INFO-5940- Open VS Code, navigate to the
INFO-5940folder. - Open the Command Palette (
Ctrl+Shift+PorCmd+Shift+Pon Mac) and search for:Remote-Containers: Reopen in Container - Select this option. VS Code will build and open the project inside the container.
📌 Note: If you don’t see this option, ensure that the Remote - Containers extension is installed.
Since docker-compose.yml expects environment variables, follow these steps:
-
Inside the project folder, create a
.envfile:touch .env
-
Add your API key and base URL:
OPENAI_API_KEY=your-api-key-here OPENAI_BASE_URL=https://api.ai.it.cornell.edu/ TZ=America/New_York -
Modify
docker-compose.ymlto include this.envfile:version: '3.8' services: devcontainer: container_name: info-5940-devcontainer build: dockerfile: Dockerfile target: devcontainer environment: - OPENAI_API_KEY=${OPENAI_API_KEY} - OPENAI_BASE_URL=${OPENAI_BASE_URL} - TZ=${TZ} volumes: - '$HOME/.aws:/root/.aws' - '.:/workspace' env_file: - .env
-
Restart the container:
docker-compose up --build
Now, your API key will be automatically loaded inside the container.
Since you may need to switch between different branches for assignments, here’s how to manage Git branches in VS Code efficiently.
- Open VS Code.
- Click on the Source Control panel on the left (
Ctrl+Shift+G/Cmd+Shift+Gon Mac). - Click on the branch name (bottom-left corner of VS Code).
- A dropdown will appear with all available branches.
- Select the branch you want to switch to.
- Open VS Code.
- Press
Ctrl+Shift+P(Cmd+Shift+Pon Mac) to open the Command Palette. - Type "Git: Checkout to..." and select it.
- Pick the branch you want to switch to.
If you prefer the command line inside the container, use:
git branch # View all branches
git checkout branch-name # Switch to a branch
git pull origin branch-name # Update the branch (recommended)📌 Tip: If you are working on a new feature, create a new branch before making changes:
git checkout -b new-feature-branchOnce inside the VS Code Dev Container, you should be able to run the notebooks from the IDE but you can also launch the Jupyter Notebook server:
jupyter notebook --ip 0.0.0.0 --port=8888 --no-browser --allow-rootWhen the notebook starts, it will output a URL like this:
http://127.0.0.1:8888/?token=your_token_here
Copy and paste this link into your browser to access the Jupyter Notebook interface.
-
Ensure Docker Desktop is running.
-
Run
docker-compose up --buildagain. -
If errors persist, delete existing containers with:
docker-compose down
Then restart:
docker-compose up --build
- Ensure you’re using the correct port (
8888). - Run
docker psto check if the container is running.
- Check if
.envis correctly created. - Ensure
docker-compose.ymlincludesenv_file: - .env. - Restart the container after making changes (
docker-compose up --build).
- Complete assignments using the Jupyter Notebook.
- Use the OpenAI API inside Python scripts within the container.
- Switch between Git branches as needed for different assignments.
Happy coding! 🚀