Skip to content

Commit

Permalink
RAFT DevContainer for GitHub Codespaces (ShishirPatil#379)
Browse files Browse the repository at this point in the history
This PR adds support for a GitHub Codespaces Dev Container for the
`raft` sub-project:
    - Dev Container config `RAFT` with direnv with shell hooks
- Adds `Open in GitHub Codespaces` badge to README.md pre-configured
with `RAFT` config
- post-create script creates env using the python venv module and points
direnv at it
    - Upgrades pip and installs requirements

Note: The Dev Container configuration can also be used locally in VS
Code in addition to remotely in GitHub Codespaces.

This PR is similar to ShishirPatil#351 but targets the `raft` sub project.

Co-authored-by: Shishir Patil <[email protected]>
  • Loading branch information
cedricvidal and ShishirPatil authored May 8, 2024
1 parent 3f91544 commit 6dff506
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .devcontainer/raft/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mcr.microsoft.com/devcontainers/python:1-3.10

RUN curl -sfL https://direnv.net/install.sh | bash && \
echo 'eval "$(direnv hook bash)"' >> /etc/bash.bashrc
32 changes: 32 additions & 0 deletions .devcontainer/raft/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "RAFT",

// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"build": {
// Path is relative to the devcontainer.json file.
"dockerfile": "Dockerfile"
},

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "sh ${containerWorkspaceFolder}/.devcontainer/raft/post-create.sh",

// Configure tool-specific properties.
"customizations": {
"codespaces": {
"openFiles": [
"raft/README.md"
]
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
16 changes: 16 additions & 0 deletions .devcontainer/raft/post-create.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#!/bin/bash

cd raft

echo "Allowing raft direnv"
direnv allow

echo "Creating virtual environment"
python3 -m venv .venv
. ./.venv/bin/activate

echo "Upgrading pip"
pip install --upgrade pip

echo "Installing requirements"
pip install -r requirements.txt
3 changes: 3 additions & 0 deletions raft/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Tell direnv to use pre configured venv
export VIRTUAL_ENV=./.venv
layout python
1 change: 1 addition & 0 deletions raft/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.venv/
8 changes: 8 additions & 0 deletions raft/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ RAFT is a recipe to adapting LLMs to domain-specific RAG. You can learn more in

The input data from the user can be either a general text document (pdf, json, or txt) for general QA or an API documentation in the API Zoo JSONL format for API calling.

## Dev environment with Codespaces

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/ShishirPatil/gorilla/tree/codespaces?devcontainer_path=.devcontainer%2Fraft%2Fdevcontainer.json)

Everything is setup automatically in the dev container, open a terminal into the `raft` folder:

Note: The `raft` virtual env will be activated in your shell when entering into the `raft` folder.

## Install Dependencies

Dependencies can be installed using the following command:
Expand Down

0 comments on commit 6dff506

Please sign in to comment.