Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: optimize script fetching data #222

Merged
merged 25 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,7 @@ Cargo.lock
.python-version
__pycache__

.client_cache/
.client_cache/
.utxo_data/
.timestamps_data/

23 changes: 13 additions & 10 deletions scripts/data/client.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,37 @@
base_dir=".client_cache"

start=${1:-0}
end=${2:-100}
no_of_blocks=${2:-100}
end=$(($start+$no_of_blocks))
step=${3:-1}
mode=${4:-"light"}
strategy=${5:-"sequential"}

mkdir $base_dir || true
mkdir -p $base_dir

run_client() {
local initial_height=$1
local num_blocks=$2

first=$((initial_height+1))
second=$((initial_height+num_blocks))
echo -n "Running $mode client on blocks $first — $second ..."

batch_file=${base_dir}/${mode}_${initial_height}_${num_blocks}.json
arguments_file=${base_dir}/arguments-${mode}_${initial_height}_${num_blocks}.json
if [ ! -f "$batch_file" ]; then
python ../../scripts/data/generate_data.py $mode $initial_height $num_blocks true $batch_file
python ../../scripts/data/generate_data.py --fast --mode $mode --height $initial_height --num_blocks $num_blocks --include_expected --output_file $batch_file
fi

arguments=$(python ../../scripts/data/format_args.py $batch_file)
output=$(scarb cairo-run --no-build --package client --function test "$arguments")
if [[ "$output" == *"FAIL"* ]]; then
echo " fail"

echo -n "Running $mode client on blocks $first - $second "
python ../../scripts/data/format_args.py $batch_file > $arguments_file
output=$(scarb cairo-run --no-build --package client --function test --arguments-file $arguments_file)
if [[ $? -ne 0 || "$output" == *"FAIL"* || "$output" == *error* || "$output" == *panicked* ]]; then
echo "fail"
echo $output
exit 1
else
echo " ok"
echo "ok"
echo $output
fi
}

Expand Down
Loading
Loading