Func Annotator is a simple Python tool that generates natural language annotations for Python functions using a plain-text prompt. The annotation describes the function's input, processing, and output in clear, concise English.
- Generates structured, plain-English documentation for Python functions.
- Outputs annotation in three parts: Input, Processing, Output.
- Simple to run locally or in Docker.
- Designed for clarity—no Markdown or extraneous formatting.
-
Clone the repository and install dependencies:
git clone <your-repo-url> cd <repo> pip install -r requirements.txt -
Run the annotator (interactive mode):
python app/func_annotator.pyPaste your function when prompted, end your input with 'end'(case ignored) in a new line to get result.
-
Batch annotation (process all function samples):
python app/batch_annotator.pyThis will process all functions in
feedings/and save annotated results tooutputs/. -
Run the test:
pytest tests/test.py
You can also use Docker for easy setup and execution:
# 构建 Docker 镜像
docker build -t func-annotator .
# 运行标注工具(需要挂载配置文件)
docker run --rm -v $(pwd)/docker.env:/app/config/docker.env func-annotator
# 运行测试
docker run --rm -v $(pwd)/docker.env:/app/config/docker.env func-annotator pytest tests/test.py -v
The tool uses .env to store model info and credentials:
API_KEY=YOUR_API_KEY
API_URL=YOUR_API_URL
MODEL_NAME=YOUR_MODEL_NAME
The tool uses prompt_template.txt to modify prompt sending to models.
This project uses DVC to version control function samples in the feedings/ directory. This allows you to track changes to your training data and collaborate with others.
-
Install DVC (already included in requirements.txt):
pip install -r requirements.txt
-
Initialize DVC manually:
# Initialize DVC repository dvc init # Add function sample files to version control dvc add feedings/function_sample1.py dvc add feedings/function_sample2.py
This will create
.dvcfiles that track your function samples and add them to DVC cache.
# View current status
dvc status
# Commit changes
dvc commit -m "Updated function samples"
# Push to remote storage
dvc push
# Pull latest version
dvc pull
# View history
dvc list .
# Show differences
dvc diff- function_sample1.py - Arithmetic and mathematical functions (20 functions)
- Arithmetic operations, geometry, statistics, linear algebra
- function_sample2.py - Text processing functions (20 functions)
- String operations, text analysis, data formatting, encryption
- debugged errors in Dockerfile.
- added error captures in func_annotator.py.
- attached readme.md.
- added cache files in .gitignore and .dockerignore.
- added model performance traced by integrating mlflow & dagshub.
- restructured project with app/ and tests/ directories.
- enhanced error handling and monitoring metrics.
- integrated DVC (Data Version Control) for managing function samples.
- added version control for feedings/ function sample files.
- reorganized project structure with docs/ directory.
- added batch annotation script (app/batch_annotator.py) for processing multiple functions at once.