Skip to content

Commit

Permalink
Add CI/CD pipeline configuration, requirements, and test files
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Aug 19, 2024
1 parent 5067f0a commit 3e2d819
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 0 deletions.
44 changes: 44 additions & 0 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: NeuroCoder CI/CD Pipeline

on:
push:
branches:
- neurocoder-development
pull_request:
branches:
- neurocoder-development

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.9'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Run tests
run: |
pytest
deploy:
runs-on: ubuntu-latest
needs: build

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Deploy to Docker
run: |
docker build -t neurocoder .
docker run -d -p 80:80 neurocoder
20 changes: 20 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# NeuroCoder Project Dependencies

# FastAPI for creating APIs
fastapi==0.78.0

# PyTorch for model development
torch==1.12.1

# Transformers for advanced architecture
transformers==4.21.1

# pytest for testing
pytest==7.1.2

# Docker for containerization
docker==5.0.3

# Additional dependencies
requests==2.28.1
pydantic==1.9.1
39 changes: 39 additions & 0 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import pytest
import torch
from src.models.model_training import AdvancedNeuroCoder
from src.api import app
from fastapi.testclient import TestClient

@pytest.fixture
def client():
return TestClient(app)

@pytest.fixture
def model():
return AdvancedNeuroCoder(vocab_size=10000)

def test_api_generate_code(client, model):
input_data = {
"input_ids": [1, 2, 3, 4],
"attention_mask": [1, 1, 1, 1],
"task": "generate"
}
response = client.post("/generate-code", json=input_data)
assert response.status_code == 200
assert "output" in response.json()

def test_api_feedback(client):
feedback_data = {
"code_id": "1234",
"rating": 5,
"comments": "Great code generation!"
}
response = client.post("/feedback", json=feedback_data)
assert response.status_code == 200
assert response.json()["status"] == "success"

def test_api_benchmarks(client):
response = client.get("/benchmarks")
assert response.status_code == 200
assert "benchmarks" in response.json()
assert "comparisons" in response.json()
34 changes: 34 additions & 0 deletions tests/test_model_training.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pytest
import torch
from src.models.advanced_architecture import AdvancedNeuroCoder

@pytest.fixture
def model():
return AdvancedNeuroCoder(vocab_size=10000)

def test_model_initialization(model):
assert model is not None
assert model.embedding.num_embeddings == 10000

def test_forward_pass(model):
input_ids = torch.tensor([[1, 2, 3, 4]])
attention_mask = torch.tensor([[1, 1, 1, 1]])
output = model(input_ids, attention_mask)
assert output is not None
assert output.shape == (1, 4, 10000) # (batch_size, sequence_length, vocab_size)

def test_model_output_range(model):
input_ids = torch.tensor([[1, 2, 3, 4]])
attention_mask = torch.tensor([[1, 1, 1, 1]])
output = model(input_ids, attention_mask)
assert torch.all(output >= 0) and torch.all(output <= 1) # Assuming output is probabilities

def test_model_parameters(model):
total_params = sum(p.numel() for p in model.parameters())
assert total_params > 0, "Model should have parameters"

def test_model_training_mode(model):
model.train()
assert model.training == True
model.eval()
assert model.training == False

0 comments on commit 3e2d819

Please sign in to comment.