Skip to content

Commit

Permalink
Don't checkout the CLI repo
Browse files Browse the repository at this point in the history
Signed-off-by: Dave Tucker <[email protected]>
  • Loading branch information
dave-tucker committed Mar 14, 2024
1 parent 47fba53 commit 7a23ba7
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 63 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
build-args: |
GITHUB_USER=instruct-lab-bot
GITHUB_TOKEN=${{ secrets.BOT_GITHUB_TOKEN }}
file: Dockerfile
push: true
tags: ${{ steps.bot_meta.outputs.tags }}
Expand All @@ -50,6 +53,9 @@ jobs:
uses: docker/build-push-action@v4
with:
context: .
build-args: |
GITHUB_USER=instruct-lab-bot
GITHUB_TOKEN=${{ secrets.BOT_GITHUB_TOKEN }}
file: Dockerfile.serve
push: true
tags: ${{ steps.labserve_meta.outputs.tags }}
Expand Down
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
FROM docker.io/library/node:20-slim
FROM docker.io/library/fedora:39

ARG GITHUB_USER
ARG GITHUB_TOKEN


RUN dnf install -y nodejs npm python3 python3-pip python3-devel git gcc gcc-c++ && dnf clean all

# Install lab CLI
RUN pip install -e git+https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/redhat-et/instruct-lab-cli#egg=cli

# Install the app
WORKDIR /usr/src/app
COPY package.json package-lock.json ./
RUN npm install
ENV NODE_ENV="production"
COPY . .
RUN npm run build
VOLUME /data
CMD [ "node", "./lib/main.js" ]
10 changes: 6 additions & 4 deletions Dockerfile.serve
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
FROM docker.io/library/python:3.10
VOLUME /src
ENV VENV_DIR=venv
ARG GITHUB_USER
ARG GITHUB_TOKEN
RUN pip install -e git+https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/redhat-et/instruct-lab-cli#egg=cli
COPY ./scripts/entrypoint.sh /usr/local/bin/entrypoint.sh
WORKDIR /src
ENTRYPOINT [ "/usr/local/bin/entrypoint.sh"]
VOLUME [ "/data" ]
WORKDIR /data
ENTRYPOINT [ "lab", "serve"]
6 changes: 3 additions & 3 deletions deploy/ansible/bot/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
name: instruct-lab-bot
image: ghcr.io/redhat-et/instruct-lab-bot/instruct-lab-bot:main
state: started
pull: always
links:
- "instructlab:instructlab"
ports:
Expand All @@ -20,7 +21,6 @@
- APP_ID: "{{ app_id }}"
- PRIVATE_KEY: "{{ private_key }}"
- WEBHOOK_SECRET: "{{ webhook_secret }}"
- WORK_DIR: "/src/instructlab"
- VENV_DIR: "venv"
- WORK_DIR: "/data"
volumes:
- "/home/{{ ansible_user }}/instructlab:/src/instructlab"
- "/home/{{ ansible_user }}/instructlab:/data"
1 change: 0 additions & 1 deletion deploy/ansible/instructlab/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ python_venv_path: "{{ app_directory }}/venv"
cli_directory: "{{ app_directory }}/cli"
taxonomy_directory: "{{ app_directory }}/taxonomy"
models_directory: "{{ app_directory }}/models"
new_model_path: "models/mistral-7b-instruct-v0.1.Q4_K_M.gguf"
51 changes: 9 additions & 42 deletions deploy/ansible/instructlab/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,60 +19,21 @@
https://instruct-lab-bot:{{ github_token }}@github.com
mode: "0600"

- name: Check if the cli directory exists
ansible.builtin.stat:
path: "{{ cli_directory }}"
register: cli_dir

- name: Delete the cli directory if it exists
ansible.builtin.file:
path: "{{ cli_directory }}"
state: absent
when: cli_dir.stat.exists

- name: Clone the cli repository
ansible.builtin.git: # noqa latest[git]
repo: https://github.com/redhat-et/instruct-lab-cli
dest: "{{ cli_directory }}"
clone: true
update: true

- name: Check if the taxonomy directory exists
ansible.builtin.stat:
path: "{{ taxonomy_directory }}"
register: taxonomy_dir

- name: Delete the taxonomy directory if it exists
ansible.builtin.file:
path: "{{ taxonomy_directory }}"
state: absent
when: taxonomy_dir.stat.exists

- name: Clone the taxonomy repository
ansible.builtin.git: # noqa latest[git]
repo: https://github.com/redhat-et/taxonomy
dest: "{{ taxonomy_directory }}"
clone: true
update: true

- name: Create Python virtual environment if it does not exist
ansible.builtin.shell: |
python3 -m venv {{ python_venv_path }}
args:
executable: /bin/bash
creates: "{{ python_venv_path }}/bin/activate"

- name: Install Labrador CLI
ansible.builtin.pip:
name: .
virtualenv: "{{ python_venv_path }}"
state: present
chdir: "{{ cli_directory }}"

- name: Install additional packages
ansible.builtin.pip:
name: huggingface-hub
virtualenv: "{{ python_venv_path }}"
state: present

- name: Create the models directory
Expand All @@ -81,9 +42,14 @@
state: directory
mode: "0755"

- name: Check if model exists
ansible.builtin.stat:
path: "{{ models_directory }}/{{ new_model_path }}"
register: model

- name: Download model from Hugging Face # noqa no-changed-when
when: model.stat.exists == false
ansible.builtin.shell: |
source {{ python_venv_path }}/bin/activate
huggingface-cli download \
TheBloke/Mistral-7B-Instruct-v0.1-GGUF \
mistral-7b-instruct-v0.1.Q4_K_M.gguf \
Expand Down Expand Up @@ -120,14 +86,15 @@
gpu_layers: -1
host_port: localhost:8000
max_ctx_size: 4096
model_path: models/{{ new_model_path }}
model_path: models/mistral-7b-instruct-v0.1.Q4_K_M.gguf
- name: Serve the model
community.docker.docker_container:
name: instruct-lab-serve
image: ghcr.io/redhat-et/instruct-lab-bot/instruct-lab-serve:main
pull: always
state: started
ports:
- "8000:8000"
volumes:
- "/home/{{ ansible_user }}/instructlab:/src"
- "/home/{{ ansible_user }}/instructlab:/data"
5 changes: 0 additions & 5 deletions scripts/entrypoint.sh

This file was deleted.

7 changes: 1 addition & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ import { Probot } from "probot";

dotenv.config();

const WORK_DIR = process.env.WORK_DIR;
const VENV_DIR = process.env.VENV_DIR;

function run(cmd: string) {
return new Promise((resolve, reject) => {
exec(cmd, (error, stdout, stderr) => {
Expand Down Expand Up @@ -51,9 +48,7 @@ export default (app: Probot) => {

try {
const prNumber = context.payload.issue.number;
await run(
`./scripts/generate.sh --work-dir ${WORK_DIR} --venv-dir ${VENV_DIR} ${prNumber}`,
);
await run(`./scripts/generate.sh ${prNumber}`);
const issueComment = context.issue({
body:
`Beep, boop 🤖 The test data has been generated!\n` +
Expand Down

0 comments on commit 7a23ba7

Please sign in to comment.