Call functions that don't exist. Let AI figure it out.
Project description
🌧️ Rainfall
Call functions that don't exist. AI writes and executes the code.
Rainfall is a Python CLI that runs your scripts with AI-powered stub functions. Write the function signature and docstring, leave the body as ..., and Rainfall generates real working code.
Installation
pip install rainfall-cli
Quick Start
1. Set your Gemini API key:
export GEMINI_API_KEY=your_api_key_here
Get a free key at Google AI Studio.
2. Write a script with stub functions:
# my_script.py
def calculate_tip(bill: float, quality: str) -> float:
"""
Calculate tip based on bill and service quality.
Quality: 'poor', 'okay', 'good', 'excellent'
"""
...
def fetch_page_title(url: str) -> str:
"""Fetch a webpage and extract its <title> tag."""
...
def count_image_pixels(path: str) -> int:
"""Count total pixels in an image file."""
...
# Use them like normal functions
print(f"Tip: ${calculate_tip(85.50, 'excellent')}")
print(f"Title: {fetch_page_title('https://python.org')}")
print(f"Pixels: {count_image_pixels('photo.jpg')}")
3. Run with Rainfall:
rainfall my_script.py
Rainfall generates real Python code for each stub and executes it.
How It Works
- Parse — Finds stub functions (body is
...,pass, orNotImplementedError) - Generate — Asks LLM to write the function implementation
- Cache — Stores generated code (same function = same code)
- Execute — Runs the generated code with your arguments
def fetch_page_title(url: str) -> str:
"""Fetch a webpage and extract its <title> tag."""
...
# Rainfall generates:
response = requests.get(url)
match = re.search(r'<title>(.*?)</title>', response.text)
return match.group(1) if match else ""
What It Can Do
Because Rainfall executes real code, it can:
- ✅ Make HTTP requests (
requestspre-imported) - ✅ Process images (
PIL.Imagepre-imported) - ✅ Read/write files (
pathlib,ospre-imported) - ✅ Parse JSON, regex, math operations
- ✅ Any pure Python computation
CLI Options
rainfall script.py # Run with defaults
rainfall script.py --verbose # Show generated code
rainfall script.py --dry-run # List stubs without running
rainfall script.py --model MODEL # Use different model
Best Practices
Write Clear Docstrings
The docstring is your prompt. Be specific:
# ✅ Good - AI knows exactly what to do
def extract_emails(text: str) -> list:
"""
Extract all email addresses from text.
Returns a list of email strings.
"""
...
# ❌ Vague - AI has to guess
def process(data):
"""Process the data."""
...
Use Type Hints
def get_count() -> int: ... # AI returns an integer
def get_names() -> list: ... # AI returns a list
def is_valid() -> bool: ... # AI returns True/False
Pre-imported Modules
Generated code has access to:
os,sys,json,re,math,datetime,htmlpathlib.Pathrequests(HTTP)PIL.Image(images)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rainfall_cli-0.2.0.tar.gz.
File metadata
- Download URL: rainfall_cli-0.2.0.tar.gz
- Upload date:
- Size: 10.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
523328a29af111b844b1196e3274168fda757297eabf13ddb2155b489acbe151
|
|
| MD5 |
567a47b717c4aab0d083d4960e6dabf0
|
|
| BLAKE2b-256 |
47bad02dcaab4d58cab42187af519ef5e2f585787941775679563f57890fba1b
|
Provenance
The following attestation bundles were made for rainfall_cli-0.2.0.tar.gz:
Publisher:
workflow.yml on system1970/rainfall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rainfall_cli-0.2.0.tar.gz -
Subject digest:
523328a29af111b844b1196e3274168fda757297eabf13ddb2155b489acbe151 - Sigstore transparency entry: 779052706
- Sigstore integration time:
-
Permalink:
system1970/rainfall@1168d6599d1a2a37ac73cc5b99c94f980cc2be6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/system1970
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@1168d6599d1a2a37ac73cc5b99c94f980cc2be6c -
Trigger Event:
release
-
Statement type:
File details
Details for the file rainfall_cli-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rainfall_cli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 11.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b7826778b1f5006cd77778b291c3e73ff799fbc064ce0614a458393e6b7887e
|
|
| MD5 |
0c4af64da4349511c977cb922379a621
|
|
| BLAKE2b-256 |
c7ca0b8ac2671d83e1c49aa3c6c884ae5e7782a7427279d4ed82f9c208be55eb
|
Provenance
The following attestation bundles were made for rainfall_cli-0.2.0-py3-none-any.whl:
Publisher:
workflow.yml on system1970/rainfall
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rainfall_cli-0.2.0-py3-none-any.whl -
Subject digest:
2b7826778b1f5006cd77778b291c3e73ff799fbc064ce0614a458393e6b7887e - Sigstore transparency entry: 779052707
- Sigstore integration time:
-
Permalink:
system1970/rainfall@1168d6599d1a2a37ac73cc5b99c94f980cc2be6c -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/system1970
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
workflow.yml@1168d6599d1a2a37ac73cc5b99c94f980cc2be6c -
Trigger Event:
release
-
Statement type: