Skip to content

Commit

Permalink
Some indentation formatting with run-atlas_container.sh and run-atlas…
Browse files Browse the repository at this point in the history
…_container.sh-dockerhub
  • Loading branch information
Shuwei Ye authored and Shuwei Ye committed Apr 14, 2024
1 parent 6a6a0bf commit 0307951
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 78 deletions.
76 changes: 37 additions & 39 deletions run-atlas_container.sh
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
#!/bin/bash
# coding: utf-8
# version=2024-04-11-r01
# version=2024-04-12-r01
# author: Shuwei Ye <[email protected]>
"true" '''\'
myScript="${BASH_SOURCE:-$0}"
ret=0

sourced=0
if [ -n "$ZSH_VERSION" ]; then
case $ZSH_EVAL_CONTEXT in *:file) sourced=1; esac
case $ZSH_EVAL_CONTEXT in *:file) sourced=1; esac
else
case ${0##*/} in bash|-bash|zsh|-zsh) sourced=1; esac
case ${0##*/} in bash|-bash|zsh|-zsh) sourced=1; esac
fi

mySetup=runMe-here.sh

if [[ -e $mySetup && ( $# -eq 0 || "$*" =~ "--rerun" ) ]]; then
source $mySetup
ret=$?
source $mySetup
ret=$?
elif [[ $# -eq 1 && "$1" =~ ^[Jj]upyter$ ]]; then
# source $mySetup jupyter
echo "Jupyter is not ready yet"
ret=$?
# source $mySetup jupyter
echo "Jupyter is not ready yet"
ret=$?
else
if [ "X" != "X$BASH_SOURCE" ]; then
shopt -s expand_aliases
fi
# alias py_readlink="python3 -I -S -c 'import os,sys;print(os.path.realpath(sys.argv[1]))'"
# alias py_stat="python3 -I -S -c 'import os,sys; print(int(os.path.getmtime(sys.argv[1])))'"
myDir=$(dirname $myScript)
myDir=$(readlink -f $myDir)
# myDir=$(py_readlink $myDir)
if [[ $# -eq 0 ]]; then
python3 -B -I "$myScript" --help
ret=$?
else
now=$(date +"%s")
python3 -B -I -S "$myScript" --shellFilename $mySetup "$@"
ret=$?
if [ -e $mySetup ]; then
# check if the setup script is newly created
# mtime_setup=$(py_stat $mySetup)
mtime_setup=$(stat -c %Y $mySetup 2>/dev/null || stat -f %m $mySetup)
if [ "$(( $mtime_setup - $now ))" -ge 0 ]; then
echo -e "\nTo reuse the same container next time, just run"
echo -e "\n\t source $mySetup \n or \n\t source $myScript"
sleep 2
source $mySetup
fi
fi
fi
if [ "X" != "X$BASH_SOURCE" ]; then
shopt -s expand_aliases
fi
myDir=$(dirname $myScript)
myDir=$(readlink -f $myDir)
# myDir=$(py_readlink $myDir)
if [[ $# -eq 0 ]]; then
python3 -B -I "$myScript" --help
ret=$?
else
now=$(date +"%s")
python3 -B -I -S "$myScript" --shellFilename $mySetup "$@"
ret=$?
if [ -e $mySetup ]; then
# check if the setup script is newly created
# mtime_setup=$(py_stat $mySetup)
mtime_setup=$(stat -c %Y $mySetup 2>/dev/null || stat -f %m $mySetup)
if [ "$(( $mtime_setup - $now ))" -ge 0 ]; then
echo -e "\nTo reuse the same container next time, just run"
echo -e "\n\t source $mySetup \n or \n\t source $myScript"
sleep 2
source $mySetup
fi
fi
fi
fi
[[ $sourced == 1 ]] && return $ret || exit $ret
'''
Expand All @@ -62,7 +60,6 @@ from datetime import datetime, timezone
# from time import sleep
import argparse
# import ast
import json
import pprint
import re
Expand All @@ -76,12 +73,13 @@ from urllib.request import urlopen
from urllib.error import URLError, HTTPError
import ssl
GITHUB_REPO = "usatlas/ML-Containers"
GITHUB_PATH = "run-atlas_container.sh"
URL_SELF = "https://raw.githubusercontent.com/%s/main/%s" % (
GITHUB_REPO, GITHUB_PATH)
GITHUB_REPO, GITHUB_PATH)
URL_API_SELF = "https://api.github.com/repos/%s/commits?path=%s&per_page=100" % (
GITHUB_REPO, GITHUB_PATH)
GITHUB_REPO, GITHUB_PATH)
CONTAINER_CMDS = ["podman", "docker", "nerdctl", "apptainer", "singularity"]
ContCmds_available = []
Expand Down Expand Up @@ -357,7 +355,7 @@ def listReleases(args):
matchTag = False
break
else:
if (releaseNoWild != tagName and
if (releaseNoWild != tagName and
releaseNoWild not in re.split(r"[-.]", tagName)):
matchTag = False
break
Expand Down
75 changes: 36 additions & 39 deletions run-atlas_container.sh-dockerhub
Original file line number Diff line number Diff line change
@@ -1,55 +1,53 @@
#!/bin/bash
# coding: utf-8
# version=2024-04-11-r01
# version=2024-04-12-r01
# author: Shuwei Ye <[email protected]>
"true" '''\'
myScript="${BASH_SOURCE:-$0}"
ret=0

sourced=0
if [ -n "$ZSH_VERSION" ]; then
case $ZSH_EVAL_CONTEXT in *:file) sourced=1; esac
case $ZSH_EVAL_CONTEXT in *:file) sourced=1; esac
else
case ${0##*/} in bash|-bash|zsh|-zsh) sourced=1; esac
case ${0##*/} in bash|-bash|zsh|-zsh) sourced=1; esac
fi

mySetup=runMe-here.sh

if [[ -e $mySetup && ( $# -eq 0 || "$*" =~ "--rerun" ) ]]; then
source $mySetup
ret=$?
source $mySetup
ret=$?
elif [[ $# -eq 1 && "$1" =~ ^[Jj]upyter$ ]]; then
# source $mySetup jupyter
echo "Jupyter is not ready yet"
ret=$?
# source $mySetup jupyter
echo "Jupyter is not ready yet"
ret=$?
else
if [ "X" != "X$BASH_SOURCE" ]; then
shopt -s expand_aliases
fi
# alias py_readlink="python3 -I -S -c 'import os,sys;print(os.path.realpath(sys.argv[1]))'"
# alias py_stat="python3 -I -S -c 'import os,sys; print(int(os.path.getmtime(sys.argv[1])))'"
myDir=$(dirname $myScript)
myDir=$(readlink -f $myDir)
# myDir=$(py_readlink $myDir)
if [[ $# -eq 0 ]]; then
python3 -B -I "$myScript" --help
ret=$?
else
now=$(date +"%s")
python3 -B -I "$myScript" --shellFilename $mySetup "$@"
ret=$?
if [ -e $mySetup ]; then
# check if the setup script is newly created
# mtime_setup=$(py_stat $mySetup)
mtime_setup=$(stat -c %Y $mySetup 2>/dev/null || stat -f %m $mySetup)
if [ "$(( $mtime_setup - $now ))" -ge 0 ]; then
echo -e "\nTo reuse the same container next time, just run"
echo -e "\n\t source $mySetup \n or \n\t source $myScript"
sleep 2
source $mySetup
fi
fi
fi
if [ "X" != "X$BASH_SOURCE" ]; then
shopt -s expand_aliases
fi
myDir=$(dirname $myScript)
myDir=$(readlink -f $myDir)
# myDir=$(py_readlink $myDir)
if [[ $# -eq 0 ]]; then
python3 -B -I "$myScript" --help
ret=$?
else
now=$(date +"%s")
python3 -B -I -S "$myScript" --shellFilename $mySetup "$@"
ret=$?
if [ -e $mySetup ]; then
# check if the setup script is newly created
# mtime_setup=$(py_stat $mySetup)
mtime_setup=$(stat -c %Y $mySetup 2>/dev/null || stat -f %m $mySetup)
if [ "$(( $mtime_setup - $now ))" -ge 0 ]; then
echo -e "\nTo reuse the same container next time, just run"
echo -e "\n\t source $mySetup \n or \n\t source $myScript"
sleep 2
source $mySetup
fi
fi
fi
fi
[[ $sourced == 1 ]] && return $ret || exit $ret
'''
Expand All @@ -62,7 +60,6 @@ from datetime import datetime, timezone
# from time import sleep
import argparse
# import ast
import json
import pprint
import re
Expand All @@ -78,11 +75,11 @@ import ssl
GITHUB_REPO = "usatlas/ML-Containers"
GITHUB_PATH = "run-atlas_container.sh"
GITHUB_PATH = "run-atlas_container.sh-dockerhub"
URL_SELF = "https://raw.githubusercontent.com/%s/main/%s" % (
GITHUB_REPO, GITHUB_PATH)
GITHUB_REPO, GITHUB_PATH)
URL_API_SELF = "https://api.github.com/repos/%s/commits?path=%s&per_page=100" % (
GITHUB_REPO, GITHUB_PATH)
GITHUB_REPO, GITHUB_PATH)
CONTAINER_CMDS = ["podman", "docker", "nerdctl", "apptainer", "singularity"]
ContCmds_available = []
Expand Down

0 comments on commit 0307951

Please sign in to comment.