Created
September 18, 2024 19:59
-
-
Save zkamvar/4ebfd30e8a758b4df6a1a9100853f1d2 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
# | |
# This will search GitHub for hubs that use quantiles, CDF, or PMF output | |
# types and check if they use "optional" in their hub-config/tasks.json | |
# files. | |
echo "======== SEARCHING GITHUB ============" | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $(gh auth token)" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/search/code?q=path:hub-config+quantile+language:json" \ | |
| jq ".items[] | select(.name == \"tasks.json\") | {path: .url, repo: .repository.full_name}" \ | |
| jq -s > quantile.json | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $(gh auth token)" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/search/code?q=path:hub-config/+pmf+language:json" \ | |
| jq ".items[] | select(.name == \"tasks.json\") | {path: .url, repo: .repository.full_name}" \ | |
| jq -s > pmf.json | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $(gh auth token)" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"https://api.github.com/search/code?q=path:hub-config/+cdf+language:json" \ | |
| jq ".items[] | select(.name == \"tasks.json\") | {path: .url, repo: .repository.full_name}" \ | |
| jq -s> cdf.json | |
echo "======== DOWNLOADING FILES ============" | |
echo ">>> QUANTILES" | |
thing=quantile | |
echo "| fields with optional ${thing} | repository |" | |
echo "| ----------------------------- | ---------- |" | |
for i in $(seq 0 $(( $(jq length quantile.json) - 1))); | |
do | |
repo=$(jq -r ".["$i"].repo" quantile.json) | |
path=$(jq -r ".["$i"].path" quantile.json) | |
if [[ -e "$repo" ]]; then | |
# echo "--- already downloaded: $repo" | |
: | |
else | |
echo "Downloading $repo ===================" | |
mkdir -p "$repo" | |
( | |
cd "$repo" | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $(gh auth token)" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"$path" | jq -r .content | base64 --decode > tasks.json || echo "oops: $repo" | |
) | |
fi | |
n=$(jq "[.rounds[].model_tasks[].output_type.${thing}.output_type_id.optional | if . == null then 0 else 1 end] | add" "$repo/tasks.json") | |
if [[ $n == 0 ]]; then | |
: | |
else | |
echo "| $n | https://github.com/$repo |" | |
fi | |
done | |
echo ">>> CDF" | |
thing=cdf | |
echo "| fields with optional ${thing} | repository |" | |
echo "| ----------------------------- | ---------- |" | |
for i in $(seq 0 $(( $(jq length cdf.json) - 1))); | |
do | |
repo=$(jq -r ".["$i"].repo" cdf.json) | |
path=$(jq -r ".["$i"].path" cdf.json) | |
if [[ -e "$repo" ]]; then | |
# echo "--- already downloaded: $repo" | |
: | |
else | |
echo "Downloading $repo ===================" | |
mkdir -p "$repo" | |
( | |
cd "$repo" | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $(gh auth token)" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"$path" | jq -r .content | base64 --decode > tasks.json || echo "oops: $repo" | |
) | |
fi | |
n=$(jq "[.rounds[].model_tasks[].output_type.${thing}.output_type_id.optional | if . == null then 0 else 1 end] | add" "$repo/tasks.json") | |
if [[ $n == 0 ]]; then | |
: | |
else | |
echo "| $n | https://github.com/$repo |" | |
fi | |
done | |
echo ">>> PMF" | |
thing=pmf | |
echo "| fields with optional ${thing} | repository |" | |
echo "| ----------------------------- | ---------- |" | |
for i in $(seq 0 $(( $(jq length pmf.json) - 1))); | |
do | |
repo=$(jq -r ".["$i"].repo" pmf.json) | |
path=$(jq -r ".["$i"].path" pmf.json) | |
if [[ -e "$repo" ]]; then | |
# echo "--- already downloaded: $repo" | |
: | |
else | |
echo "Downloading $repo ===================" | |
mkdir -p "$repo" | |
( | |
cd "$repo" | |
curl -L \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: Bearer $(gh auth token)" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
"$path" | jq -r .content | base64 --decode > tasks.json || echo "oops: $repo" | |
) | |
fi | |
n=$(jq "[.rounds[].model_tasks[].output_type.${thing}.output_type_id.optional | if . == null then 0 else 1 end] | add" "$repo/tasks.json") | |
if [[ $n == 0 ]]; then | |
: | |
else | |
echo "| $n | https://github.com/$repo |" | |
fi | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
as of 2024-09-18: