-
Notifications
You must be signed in to change notification settings - Fork 660
Fixes for bash scripts and cmake #1145
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
base: master
Are you sure you want to change the base?
Changes from all commits
76dad6c
34c9141
181ed33
5228f00
51775cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,12 @@ shift | |
|
|
||
| #------------------------------------------------------------------------------ | ||
|
|
||
| if command -v python3 >/dev/null 2>&1; then | ||
| PYTHON=python3 | ||
| else | ||
| PYTHON=python | ||
| fi | ||
|
|
||
| mkdir -p "$BASEDIR"/modelstobetested | ||
| mkdir -p "$BASEDIR"/modelsuploaded | ||
|
|
||
|
|
@@ -33,9 +39,15 @@ function uploadStuff() { | |
| TODIR="$2" | ||
|
|
||
| #Sort by timestamp so that we process in order of oldest to newest if there are multiple | ||
| for FILEPATH in $(find "$BASEDIR"/"$FROMDIR"/ -mindepth 1 -maxdepth 1 -printf "%T@ %p\n" | sort -n | cut -d ' ' -f 2) | ||
| # Use python here to avoid 'find -printf' which is not portable to macOS | ||
| # Use sys.argv to safely pass directory name with spaces/quotes | ||
| $PYTHON -c "import os, sys; d=sys.argv[1]; print('\n'.join(sorted([os.path.join(d, f) for f in os.listdir(d)], key=lambda x: os.path.getmtime(x))))" "$BASEDIR/$FROMDIR" 2>/dev/null | while read -r FILEPATH | ||
| do | ||
| if [ ${FILEPATH: -10} == ".uploading" ] | ||
| if [ -z "$FILEPATH" ] | ||
| then | ||
| continue | ||
| fi | ||
| if [ "${FILEPATH: -10}" == ".uploading" ] | ||
| then | ||
| echo "Skipping upload tmp file:" "$FILEPATH" | ||
| else | ||
|
|
@@ -49,23 +61,23 @@ function uploadStuff() { | |
|
|
||
| if [ -d "$BASEDIR"/modelsuploaded/"$NAME" ] | ||
| then | ||
| echo "Model with same name aleady exists, so skipping:" "$SRC" | ||
| echo "Model with same name already exists, so skipping:" "$SRC" | ||
| else | ||
| rm -rf "$TMPDST" | ||
| mkdir "$TMPDST" | ||
|
|
||
| TOBEZIPPED="$TMPDST"/"$RUNNAME"-"$NAME" | ||
| TOBEZIPPED="$TMPDST/$RUNNAME-$NAME" | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any particular reason for changing the quoting style on this and subsequent lines? Just a style thing or is there some other reason?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No particular reason, just a style thing (suggested by Junie AI assistance). I can rollback to make the changes minimal. |
||
| mkdir "$TOBEZIPPED" | ||
|
|
||
| # Build zip containing the ckpt | ||
| cp "$SRC"/model.ckpt "$TOBEZIPPED"/model.ckpt | ||
| (cd "$TMPDST"; zip -r "$RUNNAME"-"$NAME".zip "$RUNNAME"-"$NAME"/) | ||
| cp "$SRC/model.ckpt" "$TOBEZIPPED/model.ckpt" | ||
| (cd "$TMPDST"; zip -r "$RUNNAME-$NAME.zip" "$RUNNAME-$NAME/") | ||
| rm "$TOBEZIPPED"/* | ||
| rmdir "$TOBEZIPPED" | ||
|
|
||
| cp "$SRC"/model.bin.gz "$TMPDST"/"$RUNNAME"-"$NAME".bin.gz | ||
| cp "$SRC"/metadata.json "$TMPDST"/metadata.json | ||
| cp "$SRC"/log.txt "$TMPDST"/log.txt | ||
| cp "$SRC/model.bin.gz" "$TMPDST/$RUNNAME-$NAME.bin.gz" | ||
| cp "$SRC/metadata.json" "$TMPDST/metadata.json" | ||
| cp "$SRC/log.txt" "$TMPDST/log.txt" | ||
|
|
||
| #Sleep a little to allow some tolerance on the filesystem | ||
| sleep 3 | ||
|
|
@@ -76,13 +88,13 @@ function uploadStuff() { | |
| do | ||
| set +e | ||
| set -x | ||
| python3 ./upload_model.py \ | ||
| $PYTHON ./upload_model.py \ | ||
| -run-name "$RUNNAME" \ | ||
| -model-name "$RUNNAME"-"$NAME" \ | ||
| -model-file "$TMPDST"/"$RUNNAME"-"$NAME".bin.gz \ | ||
| -model-zip "$TMPDST"/"$RUNNAME"-"$NAME".zip \ | ||
| -upload-log-file "$TMPDST"/upload_log.txt \ | ||
| -metadata-file "$TMPDST"/metadata.json \ | ||
| -model-name "$RUNNAME-$NAME" \ | ||
| -model-file "$TMPDST/$RUNNAME-$NAME.bin.gz" \ | ||
| -model-zip "$TMPDST/$RUNNAME-$NAME.zip" \ | ||
| -upload-log-file "$TMPDST/upload_log.txt" \ | ||
| -metadata-file "$TMPDST/metadata.json" \ | ||
| -parents-dir "$TARGETDIR" \ | ||
| -connection-config "$CONNECTION_CONFIG" \ | ||
| -rating-only "$RATING_ONLY" | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,6 +25,12 @@ shift | |
|
|
||
| #------------------------------------------------------------------------------ | ||
|
|
||
| if command -v python3 >/dev/null 2>&1; then | ||
| PYTHON=python3 | ||
| else | ||
| PYTHON=python | ||
| fi | ||
|
|
||
| OUTDIR=$(date "+%Y%m%d-%H%M%S") | ||
|
|
||
| mkdir -p "$BASEDIR"/shuffleddata/"$OUTDIR".tmp | ||
|
|
@@ -36,7 +42,7 @@ echo "Beginning shuffle at" $(date "+%Y-%m-%d %H:%M:%S") | |
| if [[ -n "${SKIP_VALIDATE:-}" ]] | ||
| then | ||
| ( | ||
| time python3 ./shuffle.py \ | ||
| time $PYTHON ./shuffle.py \ | ||
| "$BASEDIR"/selfplay/ \ | ||
| -expand-window-per-row 0.4 \ | ||
| -taper-window-exponent 0.65 \ | ||
|
|
@@ -56,7 +62,7 @@ then | |
| else | ||
| # Randomly peels off 5% of files generated by selfplay as validation data | ||
| ( | ||
| time python3 ./shuffle.py \ | ||
| time $PYTHON ./shuffle.py \ | ||
| "$BASEDIR"/selfplay/ \ | ||
| -expand-window-per-row 0.4 \ | ||
| -taper-window-exponent 0.65 \ | ||
|
|
@@ -74,7 +80,7 @@ else | |
| wait | ||
| ) | ||
| ( | ||
| time python3 ./shuffle.py \ | ||
| time $PYTHON ./shuffle.py \ | ||
| "$BASEDIR"/selfplay/ \ | ||
| -expand-window-per-row 0.4 \ | ||
| -taper-window-exponent 0.65 \ | ||
|
|
@@ -110,7 +116,7 @@ mv "$BASEDIR"/shuffleddata/"$OUTDIR".tmp "$BASEDIR"/shuffleddata/"$OUTDIR" | |
| #This should be VERY conservative and allow plenty of time for the training to switch | ||
| #to newer ones as they get generated. | ||
| echo "Cleaning up any old dirs" | ||
| find "$BASEDIR"/shuffleddata/ -mindepth 1 -maxdepth 1 -type d -mmin +120 | sort | head -n -5 | xargs --no-run-if-empty rm -r | ||
| find "$BASEDIR"/shuffleddata/ -mindepth 1 -maxdepth 1 -type d -mmin +120 -print0 | sort -z | head -z -n -5 | xargs -0 --no-run-if-empty rm -r | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does "-z" exist in MacOS as a flag for these commands? https://ss64.com/mac/sort.html doesn't list it.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed it looks like macOS doesn't support the |
||
|
|
||
| echo "Finished shuffle at" $(date "+%Y-%m-%d %H:%M:%S") | ||
| #Make a little space between shuffles | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a good way to guard against the case where "python3" doesn't exist and "python" is "python2"? In that case it would probably be best to fail rather than attempt to run python-3 scripts.