| 
1 |  | -# /bin/bash -x  | 
 | 1 | +#!/bin/bash -x  | 
2 | 2 | 
 
  | 
3 |  | -if [ "X$1" == "X" ]; then  | 
 | 3 | +# Check if an argument was provided  | 
 | 4 | +if [ -z "$1" ]; then  | 
4 | 5 |   echo "Must specify document to run"  | 
5 | 6 |   exit 1  | 
6 | 7 | fi  | 
7 | 8 | 
 
  | 
8 |  | -if [ "$1" == "readme" ]; then  | 
9 |  | -        echo "::group::Create script to run README"  | 
10 |  | -        python3 torchchat/utils/scripts/updown.py --create-sections --file README.md --replace 'llama3.1:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-readme.sh  | 
11 |  | -        # for good measure, if something happened to updown processor,  | 
12 |  | -        # and it did not error out, fail with an exit 1  | 
13 |  | -        echo "exit 1" >> ./run-readme.sh  | 
14 |  | -        echo "::endgroup::"  | 
15 |  | - | 
16 |  | -        echo "::group::Run README"  | 
17 |  | -        echo "*******************************************"  | 
18 |  | -        cat ./run-readme.sh  | 
19 |  | -        echo "*******************************************"  | 
20 |  | -        bash -x ./run-readme.sh  | 
21 |  | -        echo "::endgroup::"  | 
22 |  | - | 
23 |  | -        exit 0  | 
24 |  | -fi  | 
25 |  | - | 
26 |  | -if [ "$1" == "quantization" ]; then  | 
27 |  | -        echo "::group::Create script to run quantization"  | 
28 |  | -        python3 torchchat/utils/scripts/updown.py --create-sections --file docs/quantization.md --replace llama3:stories15M --suppress huggingface-cli,HF_TOKEN > ./run-quantization.sh  | 
29 |  | -        # for good measure, if something happened to updown processor,  | 
30 |  | -        # and it did not error out, fail with an exit 1  | 
31 |  | -        echo "exit 1" >> ./run-quantization.sh  | 
32 |  | -        echo "::endgroup::"  | 
33 |  | - | 
34 |  | -        echo "::group::Run quantization"  | 
35 |  | -        echo "*******************************************"  | 
36 |  | -        cat ./run-quantization.sh  | 
37 |  | -        echo "*******************************************"  | 
38 |  | -        bash -x ./run-quantization.sh  | 
39 |  | -        echo "::endgroup::"  | 
40 |  | - | 
41 |  | -        exit 0  | 
42 |  | -fi  | 
43 |  | - | 
44 |  | -if [ "$1" == "gguf" ]; then  | 
45 |  | -        echo "::group::Create script to run gguf"  | 
46 |  | -        python3 torchchat/utils/scripts/updown.py --file docs/GGUF.md --replace 'llama3:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-gguf.sh  | 
47 |  | -        # for good measure, if something happened to updown processor,  | 
48 |  | -        # and it did not error out, fail with an exit 1  | 
49 |  | -        echo "exit 1" >> ./run-gguf.sh  | 
50 |  | -        echo "::endgroup::"  | 
51 |  | - | 
52 |  | -        echo "::group::Run gguf"  | 
53 |  | -        echo "*******************************************"  | 
54 |  | -        cat ./run-gguf.sh  | 
55 |  | -        echo "*******************************************"  | 
56 |  | -        bash -x ./run-gguf.sh  | 
57 |  | -        echo "::endgroup::"  | 
58 |  | -fi  | 
59 |  | - | 
60 |  | - | 
61 |  | -if [ "$1" == "advanced" ]; then  | 
62 |  | -        echo "::group::Create script to run advanced"  | 
63 |  | -        python3 torchchat/utils/scripts/updown.py --file docs/ADVANCED-USERS.md --replace 'llama3:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-advanced.sh  | 
64 |  | -        # for good measure, if something happened to updown processor,  | 
65 |  | -        # and it did not error out, fail with an exit 1  | 
66 |  | -        echo "exit 1" >> ./run-advanced.sh  | 
67 |  | -        echo "::endgroup::"  | 
68 |  | - | 
69 |  | -        echo "::group::Run advanced"  | 
70 |  | -        echo "*******************************************"  | 
71 |  | -        cat ./run-advanced.sh  | 
72 |  | -        echo "*******************************************"  | 
73 |  | -        bash -x ./run-advanced.sh  | 
74 |  | -        echo "::endgroup::"  | 
75 |  | -fi  | 
76 |  | - | 
77 |  | -if [ "$1" == "evaluation" ]; then  | 
78 |  | -        echo "::group::Create script to run evaluation"  | 
79 |  | -        python3 torchchat/utils/scripts/updown.py --file torchchat/utils/docs/evaluation.md --replace 'llama3:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN > ./run-evaluation.sh  | 
80 |  | -        # for good measure, if something happened to updown processor,  | 
81 |  | -        # and it did not error out, fail with an exit 1  | 
82 |  | -        echo "exit 1" >> ./run-evaluation.sh  | 
83 |  | -        echo "::endgroup::"  | 
84 |  | - | 
85 |  | -        echo "::group::Run evaluation"  | 
86 |  | -        echo "*******************************************"  | 
87 |  | -        cat ./run-evaluation.sh  | 
88 |  | -        echo "*******************************************"  | 
89 |  | -        bash -x ./run-evaluation.sh  | 
90 |  | -fi  | 
91 |  | - | 
92 |  | -if [ "$1" == "multimodal" ]; then  | 
93 |  | - | 
94 |  | -   # Expecting that this might fail this test as-is, because   | 
95 |  | -   # it's the first on-pr test depending on github secrets for access with HF token access  | 
96 |  | - | 
97 |  | -        echo "::group::Create script to run multimodal"  | 
98 |  | -        python3 torchchat/utils/scripts/updown.py --file docs/multimodal.md > ./run-multimodal.sh  | 
99 |  | -        # for good measure, if something happened to updown processor,  | 
100 |  | -        # and it did not error out, fail with an exit 1  | 
101 |  | -        echo "exit 1" >> ./run-multimodal.sh  | 
102 |  | -        echo "::endgroup::"  | 
103 |  | - | 
104 |  | -        echo "::group::Run multimodal"  | 
105 |  | -        echo "*******************************************"  | 
106 |  | -        cat ./run-multimodal.sh  | 
107 |  | -        echo "*******************************************"  | 
108 |  | -        bash -x ./run-multimodal.sh  | 
109 |  | -        echo "::endgroup::"  | 
110 |  | -fi  | 
111 |  | - | 
112 |  | -if [ "$1" == "native" ]; then  | 
113 |  | - | 
114 |  | -        echo "::group::Create script to run native-execution"  | 
115 |  | -        python3 torchchat/utils/scripts/updown.py --file docs/native-execution.md > ./run-native.sh  | 
116 |  | -        # for good measure, if something happened to updown processor,  | 
117 |  | -        # and it did not error out, fail with an exit 1  | 
118 |  | -        echo "exit 1" >> ./run-native.sh  | 
119 |  | -        echo "::endgroup::"  | 
120 |  | - | 
121 |  | -        echo "::group::Run native-execution"  | 
122 |  | -        echo "*******************************************"  | 
123 |  | -        cat ./run-native.sh  | 
124 |  | -        echo "*******************************************"  | 
125 |  | -        bash -x ./run-native.sh  | 
126 |  | -        echo "::endgroup::"  | 
127 |  | -fi  | 
 | 9 | +# Pre-initialize variables  | 
 | 10 | +filepath=""  | 
 | 11 | +parameters="--replace 'llama3:stories15M,-l 3:-l 2' --suppress huggingface-cli,HF_TOKEN"  | 
 | 12 | +script_name="./run-${1}.sh"  # Dynamically initialize script name  | 
 | 13 | + | 
 | 14 | +# Use a case statement to handle the $1 argument  | 
 | 15 | +case "$1" in  | 
 | 16 | +  "readme")  | 
 | 17 | +    filepath="README.md"  | 
 | 18 | +    ;;  | 
 | 19 | +  "quantization")  | 
 | 20 | +    filepath="docs/quantization.md"  | 
 | 21 | +    ;;  | 
 | 22 | +  "gguf")  | 
 | 23 | +    filepath="docs/GGUF.md"  | 
 | 24 | +    ;;  | 
 | 25 | +  "advanced")  | 
 | 26 | +    filepath="docs/ADVANCED-USERS.md"  | 
 | 27 | +    ;;  | 
 | 28 | +  "evaluation")  | 
 | 29 | +    filepath="torchchat/utils/docs/evaluation.md"  | 
 | 30 | +    ;;  | 
 | 31 | +  "multimodal")  | 
 | 32 | +    filepath="docs/multimodal.md"  | 
 | 33 | +    parameters=""  # Clear parameters  | 
 | 34 | +    ;;  | 
 | 35 | +  "native")  | 
 | 36 | +    filepath="docs/native-execution.md"  | 
 | 37 | +    parameters=""  # Clear parameters  | 
 | 38 | +    ;;  | 
 | 39 | +  "distributed")  | 
 | 40 | +    filepath="docs/distributed.md"  | 
 | 41 | +    parameters=""  # Clear parameters  | 
 | 42 | +    ;;  | 
 | 43 | +  *)  | 
 | 44 | +    echo "Unknown option: $1"  | 
 | 45 | +    exit 1  | 
 | 46 | +    ;;  | 
 | 47 | +esac  | 
 | 48 | + | 
 | 49 | +# Generate the script  | 
 | 50 | +echo "::group::Create script to run $1"  | 
 | 51 | +python3 torchchat/utils/scripts/updown.py --file "$filepath" $parameters > "$script_name"  | 
 | 52 | +echo "exit 1" >> "$script_name"  | 
 | 53 | +echo "::endgroup::"  | 
 | 54 | + | 
 | 55 | +# Run the script  | 
 | 56 | +echo "::group::Run $1"  | 
 | 57 | +echo "*******************************************"  | 
 | 58 | +cat "$script_name"  | 
 | 59 | +echo "*******************************************"  | 
 | 60 | +bash -x "$script_name"  | 
 | 61 | +echo "::endgroup::"  | 
0 commit comments