Skip to content

Commit 724d957

Browse files
Fix formatting issues to pass pre-commit checks
1 parent 445667a commit 724d957

11 files changed

Lines changed: 74 additions & 191 deletions

File tree

codegen-examples/examples/Deployer.sh

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,24 @@ deploy_examples() {
3838
local examples=("$@")
3939
local pids=()
4040
local results=()
41-
41+
4242
echo -e "${BLUE}Starting deployment of ${#examples[@]} examples...${NC}"
43-
43+
4444
# Start all deployments in the background
4545
for example in "${examples[@]}"; do
4646
local example_dir=$(dirname "$example")
4747
local example_name=$(basename "$example_dir")
48-
48+
4949
echo -e "${YELLOW}Deploying ${example_name}...${NC}"
50-
50+
5151
# Change to the example directory and run deploy.sh
5252
(cd "$example_dir" && ./deploy.sh > /tmp/deploy_${example_name}.log 2>&1)&
53-
53+
5454
# Store the PID and example name
5555
pids+=($!)
5656
results+=("$example_name")
5757
done
58-
58+
5959
# Wait for all deployments to finish
6060
for i in "${!pids[@]}"; do
6161
if wait "${pids[$i]}"; then
@@ -65,7 +65,7 @@ deploy_examples() {
6565
echo -e "${YELLOW}See log at /tmp/deploy_${results[$i]}.log${NC}"
6666
fi
6767
done
68-
68+
6969
echo -e "${BLUE}All deployments completed.${NC}"
7070
}
7171

@@ -74,29 +74,29 @@ main() {
7474
# Check if Modal CLI is installed and authenticated
7575
check_modal_cli
7676
check_modal_auth
77-
77+
7878
# Find all examples with deploy.sh scripts
7979
examples=($(find_examples))
80-
80+
8181
if [ ${#examples[@]} -eq 0 ]; then
8282
echo -e "${RED}No examples with deploy.sh scripts found.${NC}"
8383
exit 1
8484
fi
85-
85+
8686
# Display the list of available examples
8787
echo -e "${BLUE}Available examples:${NC}"
8888
for i in "${!examples[@]}"; do
8989
local example_dir=$(dirname "${examples[$i]}")
9090
local example_name=$(basename "$example_dir")
9191
echo -e "${YELLOW}$((i+1)).${NC} $example_name"
9292
done
93-
93+
9494
# Prompt for selection
9595
echo -e "${BLUE}Enter the numbers of the examples you want to deploy (space-separated), or 'all' for all examples:${NC}"
9696
read -r selection
97-
97+
9898
selected_examples=()
99-
99+
100100
if [ "$selection" == "all" ]; then
101101
selected_examples=("${examples[@]}")
102102
else
@@ -109,28 +109,28 @@ main() {
109109
fi
110110
done
111111
fi
112-
112+
113113
if [ ${#selected_examples[@]} -eq 0 ]; then
114114
echo -e "${RED}No valid examples selected.${NC}"
115115
exit 1
116116
fi
117-
117+
118118
# Confirm the selection
119119
echo -e "${BLUE}You selected the following examples:${NC}"
120120
for example in "${selected_examples[@]}"; do
121121
local example_dir=$(dirname "$example")
122122
local example_name=$(basename "$example_dir")
123123
echo -e "${YELLOW}${NC} $example_name"
124124
done
125-
125+
126126
echo -e "${BLUE}Do you want to deploy these examples? (y/n)${NC}"
127127
read -r confirm
128-
128+
129129
if [ "$confirm" != "y" ] && [ "$confirm" != "Y" ]; then
130130
echo -e "${RED}Deployment cancelled.${NC}"
131131
exit 0
132132
fi
133-
133+
134134
# Deploy the selected examples
135135
deploy_examples "${selected_examples[@]}"
136136
}

codegen-examples/examples/README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,8 @@ These examples demonstrate how to integrate Codegen with other tools:
6565
Before running these examples, ensure you have:
6666

6767
1. Python 3.10+ installed
68-
2. Codegen SDK installed: `pip install codegen==0.52.19`
69-
3. For Modal examples, Modal CLI installed: `pip install modal`
68+
1. Codegen SDK installed: `pip install codegen==0.52.19`
69+
1. For Modal examples, Modal CLI installed: `pip install modal`
7070

7171
## Using the Deployer Script
7272

@@ -75,20 +75,23 @@ The `Deployer.sh` script allows you to interactively select and deploy multiple
7575
To use it:
7676

7777
1. Make sure the script is executable:
78+
7879
```bash
7980
chmod +x Deployer.sh
8081
```
8182

82-
2. Run the script:
83+
1. Run the script:
84+
8385
```bash
8486
./Deployer.sh
8587
```
8688

87-
3. Select the examples you want to deploy when prompted:
89+
1. Select the examples you want to deploy when prompted:
90+
8891
- Enter the numbers of the examples (space-separated)
8992
- Or enter 'all' to deploy all examples
9093

91-
4. Confirm your selection
94+
1. Confirm your selection
9295

9396
The script will deploy the selected examples concurrently and show the deployment status.
9497

@@ -97,4 +100,3 @@ The script will deploy the selected examples concurrently and show the deploymen
97100
- [Codegen Documentation](https://docs.codegen.com)
98101
- [Modal Documentation](https://modal.com/docs/guide)
99102
- [Codegen GitHub Repository](https://github.com/Zeeeepa/codegen)
100-

codegen-examples/examples/hello_world/README.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This is a simple example that demonstrates how to deploy a basic Modal applicati
1212
## Prerequisites
1313

1414
Before you begin, ensure you have the following installed:
15+
1516
- Python 3.10+
1617
- [Modal CLI](https://modal.com/docs/guide/cli-reference)
1718
- [Codegen SDK](https://docs.codegen.com)
@@ -65,8 +66,8 @@ The web endpoint returns a JSON response with the following structure:
6566
This example includes three main components:
6667

6768
1. **Regular Function**: `hello()` - A simple function that returns a greeting
68-
2. **Web Endpoint**: `web_hello()` - A web endpoint that returns a JSON greeting
69-
3. **Scheduled Function**: `scheduled_hello()` - A function that runs every hour
69+
1. **Web Endpoint**: `web_hello()` - A web endpoint that returns a JSON greeting
70+
1. **Scheduled Function**: `scheduled_hello()` - A function that runs every hour
7071

7172
## Local Testing
7273

@@ -83,16 +84,15 @@ This will run the application locally and call the `hello()` function with the a
8384
You can customize this example by:
8485

8586
1. Adding more functions to the Modal app
86-
2. Changing the schedule for the scheduled function
87-
3. Adding more complex logic to the functions
88-
4. Integrating with other Codegen features
87+
1. Changing the schedule for the scheduled function
88+
1. Adding more complex logic to the functions
89+
1. Integrating with other Codegen features
8990

9091
## Troubleshooting
9192

9293
If you encounter issues:
9394

9495
1. Ensure you have the correct version of Modal and Codegen installed
95-
2. Check that you're authenticated with Modal
96-
3. Verify that the Modal CLI is installed correctly
97-
4. Check the Modal logs for detailed error information
98-
96+
1. Check that you're authenticated with Modal
97+
1. Verify that the Modal CLI is installed correctly
98+
1. Check the Modal logs for detailed error information

codegen-examples/examples/hello_world/app.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,23 @@
1010
# Create an image with Python dependencies
1111
image = modal.Image.debian_slim().pip_install(["codegen==0.52.19"])
1212

13+
1314
# Define a function that will run on Modal
1415
@app.function(image=image)
1516
def hello(name: str = "world"):
1617
"""Say hello to someone."""
1718
print(f"Hello, {name}!")
1819
return f"Hello, {name}!"
1920

21+
2022
# Define a web endpoint
2123
@app.function(image=image, keep_warm=1)
2224
@modal.web_endpoint(method="GET")
2325
def web_hello(name: str = "world"):
2426
"""Web endpoint that says hello to someone."""
2527
return {"message": f"Hello, {name}!"}
2628

29+
2730
# Define a scheduled function that runs every hour
2831
@app.function(image=image)
2932
@modal.schedule(rate="1 hour")
@@ -32,10 +35,10 @@ def scheduled_hello():
3235
print("Hello, it's time for a scheduled greeting!")
3336
return "Hello, it's time for a scheduled greeting!"
3437

38+
3539
if __name__ == "__main__":
3640
# This block is executed when running the script directly
3741
with app.run():
3842
# Call the function locally
3943
result = hello.remote("Modal")
4044
print(f"Result from remote function: {result}")
41-

codegen-examples/examples/linear_webhooks/README.md

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This example demonstrates how to deploy a Modal application that handles Linear
1212
## Prerequisites
1313

1414
Before you begin, ensure you have the following installed:
15+
1516
- Python 3.10+
1617
- [Modal CLI](https://modal.com/docs/guide/cli-reference)
1718
- [Codegen SDK](https://docs.codegen.com)
@@ -57,12 +58,12 @@ This will deploy the application to Modal and provide you with a URL to configur
5758
## Linear Webhook Configuration
5859

5960
1. Go to your Linear workspace settings
60-
2. Navigate to "API" > "Webhooks"
61-
3. Click "New Webhook"
62-
4. Enter the URL provided by the deployment script
63-
5. Select the events you want to receive (e.g., "Issues")
64-
6. Copy the webhook secret and add it to your `.env` file
65-
7. Click "Create webhook"
61+
1. Navigate to "API" > "Webhooks"
62+
1. Click "New Webhook"
63+
1. Enter the URL provided by the deployment script
64+
1. Select the events you want to receive (e.g., "Issues")
65+
1. Copy the webhook secret and add it to your `.env` file
66+
1. Click "Create webhook"
6667

6768
## Customizing Event Handlers
6869

@@ -78,6 +79,7 @@ def handle_comment(self, data: dict):
7879
## Available Event Types
7980

8081
Linear supports the following event types:
82+
8183
- Issue
8284
- Comment
8385
- Project
@@ -94,15 +96,14 @@ Linear supports the following event types:
9496
If you encounter issues:
9597

9698
1. Ensure you have the correct version of Modal and Codegen installed
97-
2. Check that you're authenticated with Modal
98-
3. Verify that your Linear API key and webhook secret are correct
99-
4. Check the Modal logs for detailed error information
100-
5. Verify that the webhook URL is correctly configured in Linear
99+
1. Check that you're authenticated with Modal
100+
1. Verify that your Linear API key and webhook secret are correct
101+
1. Check the Modal logs for detailed error information
102+
1. Verify that the webhook URL is correctly configured in Linear
101103

102104
## Security Considerations
103105

104106
- Keep your Linear API key and webhook secret secure
105107
- Use environment variables for sensitive information
106108
- Consider adding authentication to your webhook endpoint
107109
- Validate webhook signatures to ensure requests are coming from Linear
108-

codegen-examples/examples/linear_webhooks/deploy.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@ fi
2525
if [ ! -f .env ]; then
2626
echo -e "${YELLOW}Warning: .env file not found.${NC}"
2727
echo -e "Creating .env file from template..."
28-
28+
2929
if [ -f .env.template ]; then
3030
cp .env.template .env
3131
echo -e "${YELLOW}Please edit the .env file with your Linear API key and webhook secret.${NC}"
3232
echo -e "Do you want to continue with deployment? (y/n)"
3333
read -r continue
34-
34+
3535
if [ "$continue" != "y" ] && [ "$continue" != "Y" ]; then
3636
echo -e "${RED}Deployment cancelled.${NC}"
3737
exit 0

codegen-examples/examples/modal_repo_analytics/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ This example demonstrates how to deploy a Modal application that uses Codegen to
1212
## Prerequisites
1313

1414
Before you begin, ensure you have the following installed:
15+
1516
- Python 3.10+
1617
- [Modal CLI](https://modal.com/docs/guide/cli-reference)
1718
- [Codegen SDK](https://docs.codegen.com)
@@ -71,15 +72,14 @@ If there's an error, the `status` field will be set to `"error"` and the `error`
7172
You can customize this example by:
7273

7374
1. Adding more metrics to the `RepoMetrics` model
74-
2. Extending the `analyze_repo` function to extract additional information
75-
3. Adding authentication to the API endpoint
75+
1. Extending the `analyze_repo` function to extract additional information
76+
1. Adding authentication to the API endpoint
7677

7778
## Troubleshooting
7879

7980
If you encounter issues:
8081

8182
1. Ensure you have the correct version of Modal and Codegen installed
82-
2. Check that you're authenticated with Modal
83-
3. Verify that the repository name is in the correct format (`owner/repo`)
84-
4. Check the Modal logs for detailed error information
85-
83+
1. Check that you're authenticated with Modal
84+
1. Verify that the repository name is in the correct format (`owner/repo`)
85+
1. Check the Modal logs for detailed error information

codegen-examples/examples/modal_repo_rag/README.md

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ This example demonstrates how to deploy a Modal application that uses Codegen's
1313
## Prerequisites
1414

1515
Before you begin, ensure you have the following installed:
16+
1617
- Python 3.10+
1718
- [Modal CLI](https://modal.com/docs/guide/cli-reference)
1819
- [Codegen SDK](https://docs.codegen.com)
@@ -47,9 +48,10 @@ You can deploy this example to Modal using the provided deploy script:
4748
```
4849

4950
This will:
51+
5052
1. Create a Modal volume for storing vector indices (if it doesn't exist)
51-
2. Deploy the application to Modal
52-
3. Provide you with a URL to access the API
53+
1. Deploy the application to Modal
54+
1. Provide you with a URL to access the API
5355

5456
## Usage
5557

@@ -93,25 +95,24 @@ If there's an error, the `status` field will be set to `"error"` and the `error`
9395
## How It Works
9496

9597
1. The application creates or loads a vector index for the specified repository
96-
2. When a question is asked, it finds the most relevant code snippets using semantic search
97-
3. It then uses OpenAI's API to generate an answer based on the retrieved code context
98-
4. The vector indices are stored in a Modal volume for persistence between runs
98+
1. When a question is asked, it finds the most relevant code snippets using semantic search
99+
1. It then uses OpenAI's API to generate an answer based on the retrieved code context
100+
1. The vector indices are stored in a Modal volume for persistence between runs
99101

100102
## Customization
101103

102104
You can customize this example by:
103105

104106
1. Changing the LLM model (currently uses GPT-4 Turbo)
105-
2. Adjusting the number of context snippets retrieved
106-
3. Modifying the prompt template for better answers
107-
4. Adding authentication to the API endpoint
107+
1. Adjusting the number of context snippets retrieved
108+
1. Modifying the prompt template for better answers
109+
1. Adding authentication to the API endpoint
108110

109111
## Troubleshooting
110112

111113
If you encounter issues:
112114

113115
1. Ensure you have the correct version of Modal and Codegen installed
114-
2. Check that you're authenticated with Modal
115-
3. Verify that your OpenAI API key is set correctly
116-
4. Check the Modal logs for detailed error information
117-
116+
1. Check that you're authenticated with Modal
117+
1. Verify that your OpenAI API key is set correctly
118+
1. Check the Modal logs for detailed error information

0 commit comments

Comments
 (0)