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-5940
folder. - Open the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
on 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
.env
file: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.yml
to include this.env
file: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+G
on 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+P
on 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-branch
Once 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-root
When 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 --build
again. -
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 ps
to check if the container is running.
- Check if
.env
is correctly created. - Ensure
docker-compose.yml
includesenv_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! 🚀