-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from fixie-ai/juberti/fetch
Simplify bench.yml
- Loading branch information
Showing
2 changed files
with
28 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,21 +3,21 @@ name: Update LLM Benchmark Data | |
on: | ||
schedule: | ||
# Runs at 08:00 UTC every day | ||
- cron: '0 8 * * *' | ||
- cron: "0 8 * * *" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
run-benchmarks: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Send Benchmark Requests | ||
run: | | ||
regions=("sea" "iad" "cdg") | ||
for region in "${regions[@]}" | ||
do | ||
curl -X POST 'https://ai-benchmarks.fly.dev/bench?mode=text&max_tokens=20&store=true' -H "fly-prefer-region: $region" | ||
done | ||
- name: Send Benchmark Requests | ||
run: | | ||
regions=("sea" "iad" "cdg") | ||
for region in "${regions[@]}" | ||
do | ||
curl -X POST 'https://ai-benchmarks.fly.dev/bench?mode=text&max_tokens=20&store=true' -H "fly-prefer-region: $region" | ||
done | ||
generate-latest-data: | ||
needs: run-benchmarks | ||
|
@@ -34,19 +34,8 @@ jobs: | |
|
||
- name: Get data and update file | ||
run: | | ||
TEMP_FILE="/tmp/$(date +%s).tmp" | ||
OUTPUT="$(node ./utils/GenerateLatestData.js 2>"$TEMP_FILE")" | ||
if [[ -s "$TEMP_FILE" ]]; then | ||
# Read the file contents and echo them so they are captured by the GitHub Actions runner | ||
while read -r line; do | ||
echo "$line" | ||
done < "$TEMP_FILE" | ||
# Delete the file | ||
rm "$TEMP_FILE" | ||
exit 1 | ||
elif [ -n "$OUTPUT" ]; then | ||
OUTPUT=$(node ./utils/GenerateLatestData.js) || { echo "Failed to generate latest data."; exit 1; } | ||
if [ -n "$OUTPUT" ]; then | ||
echo "$OUTPUT" > ./website/public/data/latest.json | ||
git config --local user.email "[email protected]" | ||
|
@@ -56,6 +45,7 @@ jobs: | |
git push | ||
else | ||
echo "No data generated, skipping Git operations." | ||
exit 1 | ||
fi | ||
build-and-deploy-site: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,27 @@ | ||
// Define the regions to search for files | ||
const regions = ['cdg', 'sea', 'iad']; | ||
const regions = ["cdg", "sea", "iad"]; | ||
|
||
// Function to fetch data from a given URL | ||
async function fetchData(url) { | ||
try { | ||
const response = await fetch(url); | ||
if (!response.ok) { | ||
throw new Error('File not found'); | ||
} | ||
return await response.json(); | ||
} catch (error) { | ||
console.error(`Error fetching data from ${url}: ${error}`); | ||
return null; | ||
} | ||
const response = await fetch(url); | ||
return await response.json(); | ||
} | ||
|
||
// Main function to fetch files from all regions and merge them | ||
async function fetchAndMergeFiles(date) { | ||
if (!date) { | ||
console.error('Invalid date provided.'); | ||
return; | ||
} | ||
|
||
const baseUrl = 'https://storage.googleapis.com/thefastest-data'; | ||
const promises = regions.map(region => fetchData(`${baseUrl}/${region}/text/${date}.json`)); | ||
const results = await Promise.all(promises); | ||
|
||
// Filter out any null results (files not found) | ||
const validResults = results.filter(result => result !== null); | ||
|
||
// If no files were found, do not update "latest.json" | ||
if (validResults.length === 0) { | ||
return; | ||
} | ||
|
||
// Output the merged data to the console | ||
process.stdout.write(JSON.stringify(validResults, null, 2)); | ||
const baseUrl = "https://storage.googleapis.com/thefastest-data"; | ||
const promises = regions.map((region) => | ||
fetchData(`${baseUrl}/${region}/text/${date}.json`) | ||
); | ||
const results = await Promise.all(promises); | ||
process.stdout.write(JSON.stringify(results, null, 2)); | ||
} | ||
|
||
// Example usage with the current date | ||
const currentDate = new Date().toISOString().split('T')[0]; // Format: YYYY-MM-DD | ||
fetchAndMergeFiles(currentDate); | ||
const currentDate = new Date().toISOString().split("T")[0]; // Format: YYYY-MM-DD | ||
try { | ||
fetchAndMergeFiles(currentDate); | ||
} catch (error) { | ||
console.error(error); | ||
process.exit(1); | ||
} |