Skip to content

Commit

Permalink
feat: adding namespaces (#226)
Browse files Browse the repository at this point in the history
  • Loading branch information
shreyashankar authored Dec 4, 2024
1 parent bd40799 commit 82a2102
Show file tree
Hide file tree
Showing 20 changed files with 346 additions and 235 deletions.
12 changes: 11 additions & 1 deletion .github/workflows/docker-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ jobs:
echo "Waiting for container to start..."
sleep 30
frontend_healthy=false
# Check container health for up to 3 minutes
for i in {1..6}; do
if ! docker ps -q -f name=docetl-test > /dev/null 2>&1; then
Expand All @@ -56,8 +58,9 @@ jobs:
fi
# Try to curl the frontend
if curl -s -f http://localhost:3000 > /dev/null; then
if curl -s -f http://localhost:3000/playground > /dev/null; then
echo "Frontend is responding"
frontend_healthy=true
break
fi
Expand All @@ -71,6 +74,13 @@ jobs:
sleep 30
done
# Explicitly fail if frontend check never succeeded
if [ "$frontend_healthy" = false ]; then
echo "Frontend health check failed"
docker logs docetl-test
exit 1
fi
# If we get here, container is running and healthy
echo "Container is running successfully"
Expand Down
2 changes: 1 addition & 1 deletion docetl/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "0.1.7"
__version__ = "0.2"

from docetl.runner import DSLRunner
from docetl.builder import Optimizer
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "docetl"
version = "0.1.7"
version = "0.2"
description = "ETL with LLM operations."
authors = ["Shreya Shankar <[email protected]>"]
license = "MIT"
Expand Down
16 changes: 16 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
theme: {
extend: {
keyframes: {
shake: {
'0%, 100%': { transform: 'translateX(0)' },
'25%': { transform: 'translateX(-4px)' },
'75%': { transform: 'translateX(4px)' },
},
},
animation: {
shake: 'shake 0.2s ease-in-out 0s 2',
},
},
},
}
33 changes: 33 additions & 0 deletions website/src/app/api/checkNamespace/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { NextResponse } from "next/server";
import fs from "fs";
import { getNamespaceDir } from "@/app/api/utils";
import os from "os";

export async function POST(request: Request) {
try {
const { namespace } = await request.json();
const homeDir = process.env.DOCETL_HOME_DIR || os.homedir();

if (!namespace) {
return NextResponse.json(
{ error: "Namespace parameter is required" },
{ status: 400 }
);
}

const namespaceDir = getNamespaceDir(homeDir, namespace);
const exists = fs.existsSync(namespaceDir);

if (!exists) {
fs.mkdirSync(namespaceDir, { recursive: true });
}

return NextResponse.json({ exists });
} catch (error) {
console.error("Error checking/creating namespace:", error);
return NextResponse.json(
{ error: "Failed to check/create namespace" },
{ status: 500 }
);
}
}
14 changes: 11 additions & 3 deletions website/src/app/api/getInputOutput/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,15 @@ import fs from "fs/promises";
import os from "os";
export async function POST(request: Request) {
try {
const { default_model, data, operations, operation_id, name, sample_size } =
await request.json();
const {
default_model,
data,
operations,
operation_id,
name,
sample_size,
namespace,
} = await request.json();

if (!name) {
return NextResponse.json(
Expand All @@ -29,7 +36,8 @@ export async function POST(request: Request) {
operation_id,
name,
homeDir,
sample_size
sample_size,
namespace
);

// Check if inputPath exists
Expand Down
2 changes: 2 additions & 0 deletions website/src/app/api/getPipelineConfig/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export async function POST(request: Request) {
operation_id,
name,
sample_size,
namespace,
system_prompt,
} = await request.json();

Expand Down Expand Up @@ -37,6 +38,7 @@ export async function POST(request: Request) {
name,
homeDir,
sample_size,
namespace,
system_prompt
);

Expand Down
198 changes: 0 additions & 198 deletions website/src/app/api/runPipeline/route.ts

This file was deleted.

3 changes: 2 additions & 1 deletion website/src/app/api/saveDocuments/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export async function POST(request: NextRequest) {
try {
const formData = await request.formData();
const files = formData.getAll("files") as File[];
const namespace = formData.get("namespace") as string;

if (!files || files.length === 0) {
return NextResponse.json({ error: "No files provided" }, { status: 400 });
Expand All @@ -21,7 +22,7 @@ export async function POST(request: NextRequest) {
const homeDir = process.env.DOCETL_HOME_DIR || os.homedir();

// Create uploads directory in user's home directory if it doesn't exist
const uploadsDir = path.join(homeDir, ".docetl", "documents");
const uploadsDir = path.join(homeDir, ".docetl", namespace, "documents");
await mkdir(uploadsDir, { recursive: true });

const savedFiles = await Promise.all(
Expand Down
4 changes: 2 additions & 2 deletions website/src/app/api/uploadFile/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export async function POST(request: NextRequest) {
try {
const formData = await request.formData();
const file = formData.get("file") as File;

const namespace = formData.get("namespace") as string;
if (!file) {
return NextResponse.json({ error: "No file uploaded" }, { status: 400 });
}
Expand All @@ -19,7 +19,7 @@ export async function POST(request: NextRequest) {

// Create uploads directory in user's home directory if it doesn't exist
const homeDir = process.env.DOCETL_HOME_DIR || os.homedir();
const uploadDir = path.join(homeDir, ".docetl", "files");
const uploadDir = path.join(homeDir, ".docetl", namespace, "files");
await mkdir(uploadDir, { recursive: true });

// Create full file path
Expand Down
Loading

0 comments on commit 82a2102

Please sign in to comment.