-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTaskfile.yaml
More file actions
108 lines (97 loc) · 3.19 KB
/
Taskfile.yaml
File metadata and controls
108 lines (97 loc) · 3.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
version: 3
silent: true
# Task automation for MarkItDown REST API
# Using Task instead of Makefiles for:
# - Cross-platform compatibility
# - Better YAML syntax and readability
# - Built-in variable support
# - Improved error handling
# Load environment variables from .env file
dotenv: ['.env', '{{.HOME}}/.env']
vars:
VENV_DIR: .venv
VENV_BIN: '{{if eq .OS "windows"}}{{.VENV_DIR}}\\Scripts{{else}}{{.VENV_DIR}}/bin{{end}}'
VENV_PYTHON: '{{if eq .OS "windows"}}{{.VENV_BIN}}\\python.exe{{else}}{{.VENV_BIN}}/python{{end}}'
VENV_PIP: '{{if eq .OS "windows"}}{{.VENV_BIN}}\\pip.exe{{else}}{{.VENV_BIN}}/pip{{end}}'
includes:
test: Taskfile.tests.yaml
tasks:
venv:
desc: Ensure virtual environment exists
status:
- '{{if eq .OS "windows"}}if exist {{.VENV_BIN}}\\python.exe (exit 0) else (exit 1){{else}}[ -x {{.VENV_PYTHON}} ]{{end}}'
cmds:
- cmd: |
set -e
for candidate in python3.12 python3.11 python3.10 python3; do
if command -v "$candidate" >/dev/null 2>&1; then
if "$candidate" -c 'import sys; sys.exit(0 if sys.version_info >= (3, 10) else 1)' >/dev/null 2>&1; then
PY="$candidate"
break
fi
fi
done
if [ -z "${PY:-}" ]; then
echo "Python >= 3.10 is required" >&2
exit 1
fi
"$PY" -m venv {{.VENV_DIR}}
platforms: [darwin, linux]
silent: false
- cmd: |
if not "%PYTHON%"=="" (
%PYTHON% -m venv {{.VENV_DIR}}
) else (
py -3 -m venv {{.VENV_DIR}}
)
platforms: [windows]
silent: false
install:
desc: Install dependencies
deps: [venv]
cmds:
- cmd: |
. {{.VENV_BIN}}/activate
pip install --upgrade pip
pip install --upgrade -r requirements.txt
platforms: [darwin, linux]
- cmd: |
call {{.VENV_BIN}}\activate.bat
pip install --upgrade pip
pip install --upgrade -r requirements.txt
platforms: [windows]
clean:
desc: Remove virtual environment and Task cache
cmds:
- '{{if eq .OS "windows"}}if exist {{.VENV_DIR}} rmdir /s /q {{.VENV_DIR}}{{else}}rm -rf {{.VENV_DIR}}{{end}}'
- '{{if eq .OS "windows"}}if exist .task rmdir /s /q .task{{else}}rm -rf .task{{end}}'
start:
desc: Start the FastAPI application
deps: [install]
cmds:
- cmd: |
. {{.VENV_BIN}}/activate
python main.py
platforms: [darwin, linux]
- cmd: |
call {{.VENV_BIN}}\activate.bat
python main.py
platforms: [windows]
dev:
desc: Start the application in development mode with auto-reload
deps: [install]
cmds:
- cmd: |
. {{.VENV_BIN}}/activate
lsof -i :8000 -t | xargs kill -9 || echo 'no server to kill'
uvicorn main:app --reload --host 0.0.0.0 --port 8000
platforms: [darwin, linux]
- cmd: |
call {{.VENV_BIN}}\activate.bat
uvicorn main:app --reload --host 0.0.0.0 --port 8000
platforms: [windows]
test:
desc: Run API tests
cmds:
- task: test:check-server
- task: test:all