feat: scaffold sparrow project
This commit is contained in:
commit
dd7f19ccec
14 changed files with 89 additions and 0 deletions
6
.env.example
Normal file
6
.env.example
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
CF_ORCH_URL=http://10.1.10.71:7700
|
||||||
|
SPARROW_DATA_DIR=data
|
||||||
|
SPARROW_DB_PATH=data/sparrow.db
|
||||||
|
SPARROW_HOST=0.0.0.0
|
||||||
|
SPARROW_PORT=8513
|
||||||
|
SPARROW_ENV=development
|
||||||
8
.gitignore
vendored
Normal file
8
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
.env
|
||||||
|
data/
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
.pytest_cache/
|
||||||
|
dist/
|
||||||
|
*.egg-info/
|
||||||
|
CLAUDE.md
|
||||||
0
app/__init__.py
Normal file
0
app/__init__.py
Normal file
0
app/api/__init__.py
Normal file
0
app/api/__init__.py
Normal file
0
app/api/endpoints/__init__.py
Normal file
0
app/api/endpoints/__init__.py
Normal file
0
app/db/__init__.py
Normal file
0
app/db/__init__.py
Normal file
0
app/db/migrations/__init__.py
Normal file
0
app/db/migrations/__init__.py
Normal file
0
app/models/__init__.py
Normal file
0
app/models/__init__.py
Normal file
0
app/models/schemas/__init__.py
Normal file
0
app/models/schemas/__init__.py
Normal file
0
app/services/__init__.py
Normal file
0
app/services/__init__.py
Normal file
47
manage.sh
Executable file
47
manage.sh
Executable file
|
|
@ -0,0 +1,47 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||||
|
ENV_FILE="$REPO_DIR/.env"
|
||||||
|
PID_FILE="$REPO_DIR/data/sparrow.pid"
|
||||||
|
LOG_FILE="$REPO_DIR/data/sparrow.log"
|
||||||
|
|
||||||
|
[[ -f "$ENV_FILE" ]] && source "$ENV_FILE"
|
||||||
|
SPARROW_PORT="${SPARROW_PORT:-8513}"
|
||||||
|
|
||||||
|
cmd="${1:-help}"
|
||||||
|
|
||||||
|
start() {
|
||||||
|
mkdir -p "$REPO_DIR/data"
|
||||||
|
if [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null; then
|
||||||
|
echo "sparrow already running (PID $(cat "$PID_FILE"))"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
echo "Starting sparrow on port $SPARROW_PORT..."
|
||||||
|
conda run -n cf \
|
||||||
|
uvicorn app.main:app --host "${SPARROW_HOST:-0.0.0.0}" --port "$SPARROW_PORT" \
|
||||||
|
>> "$LOG_FILE" 2>&1 &
|
||||||
|
echo $! > "$PID_FILE"
|
||||||
|
echo "Started (PID $!). Logs: $LOG_FILE"
|
||||||
|
}
|
||||||
|
|
||||||
|
stop() {
|
||||||
|
if [[ -f "$PID_FILE" ]]; then
|
||||||
|
kill "$(cat "$PID_FILE")" 2>/dev/null && echo "Stopped." || echo "Not running."
|
||||||
|
rm -f "$PID_FILE"
|
||||||
|
else
|
||||||
|
echo "Not running."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
case "$cmd" in
|
||||||
|
start) start ;;
|
||||||
|
stop) stop ;;
|
||||||
|
restart) stop; sleep 1; start ;;
|
||||||
|
status) [[ -f "$PID_FILE" ]] && kill -0 "$(cat "$PID_FILE")" 2>/dev/null \
|
||||||
|
&& echo "running (PID $(cat "$PID_FILE"))" || echo "stopped" ;;
|
||||||
|
logs) tail -f "$LOG_FILE" ;;
|
||||||
|
open) xdg-open "http://localhost:$SPARROW_PORT" 2>/dev/null || \
|
||||||
|
open "http://localhost:$SPARROW_PORT" 2>/dev/null || true ;;
|
||||||
|
*) echo "Usage: $0 {start|stop|restart|status|logs|open}" ;;
|
||||||
|
esac
|
||||||
23
pyproject.toml
Normal file
23
pyproject.toml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
[build-system]
|
||||||
|
requires = ["setuptools>=68"]
|
||||||
|
build-backend = "setuptools.build:build"
|
||||||
|
|
||||||
|
[project]
|
||||||
|
name = "sparrow"
|
||||||
|
version = "0.1.0"
|
||||||
|
requires-python = ">=3.12"
|
||||||
|
dependencies = [
|
||||||
|
"fastapi>=0.115",
|
||||||
|
"uvicorn[standard]>=0.32",
|
||||||
|
"sse-starlette>=2.1",
|
||||||
|
"pydantic>=2.0",
|
||||||
|
"python-multipart>=0.0.9",
|
||||||
|
"httpx>=0.27",
|
||||||
|
]
|
||||||
|
|
||||||
|
[project.optional-dependencies]
|
||||||
|
dev = ["pytest>=8", "pytest-asyncio>=0.24", "httpx>=0.27"]
|
||||||
|
|
||||||
|
[tool.pytest.ini_options]
|
||||||
|
asyncio_mode = "auto"
|
||||||
|
testpaths = ["tests"]
|
||||||
5
setup.py
Normal file
5
setup.py
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
from setuptools import setup, find_packages
|
||||||
|
|
||||||
|
setup(
|
||||||
|
packages=find_packages(),
|
||||||
|
)
|
||||||
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
Loading…
Reference in a new issue