Skip to content

Commit

Permalink
Merge ad7dcce into db13b40
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Sep 20, 2022
2 parents db13b40 + ad7dcce commit baa9bdf
Show file tree
Hide file tree
Showing 17 changed files with 545 additions and 322 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: [3.6, 3.7, 3.8, 3.9]
python-version: ['3.6', '3.7', '3.8', '3.9', '3.10']

steps:
- name: Checkout code
Expand All @@ -43,7 +43,7 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: ['3.9']

steps:
- name: Checkout code
Expand Down Expand Up @@ -74,7 +74,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: ['3.9']

steps:
- name: Checkout code
Expand All @@ -97,7 +97,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [3.8]
python-version: ['3.9']

steps:
- name: Checkout code
Expand Down
125 changes: 125 additions & 0 deletions bin/desi_spectro_data_unpack.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
#!/bin/bash
#
# Help!
#
function usage() {
local execName=$(basename $0)
(
echo "${execName} [-d DIR] [-h] [-I] [-t] [-v]"
echo ""
echo "Unpack DESI data tarballs."
echo ""
echo " -d DIR = Tarballs are on DIR, e.g. \${SCRATCH}"
echo " -h = Print this message and exit."
echo " -I = Ignore checksum errors on tarballs."
echo " -t = Test mode. Do not make any changes. Implies -v."
echo " -v = Verbose mode. Print extra information."
echo ""
) >&2
}
#
# Make sure we are running on datatran.
#
if [[ "${NERSC_HOST}" != "datatran" ]]; then
echo "ERROR: This script should be executed on a DTN node!" >&2
exit 1
fi
#
# Get options.
#
src_dir=${PWD}
dst_dir=/global/cfs/cdirs/desi/spectro/staging/raw
test=false
verbose=false
ignore_errors=false
while getopts d:hItv argname; do
case ${argname} in
d) src_dir=${OPTARG} ;;
h) usage; exit 0 ;;
I) ignore_errors=true ;;
t) test=true; verbose=true ;;
v) verbose=true ;;
*) usage; exit 1 ;;
esac
done
shift $((OPTIND - 1))
#
# Set up environment.
#
[[ -z "${DESIUTIL}" ]] && source /global/common/software/desi/desi_environment.sh datatran-test
[[ -z "${DESITRANSFER}" ]] && module load desitransfer/main
#
# Find tarballs.
#
declare -a nights
for kk in ${src_dir}/*.sha256sum; do
k=$(basename ${kk})
d=$(dirname ${kk})
if [[ "${k}" == "*.sha256sum" ]]; then
echo "ERROR: No tarballs found!" >&2
exit 1
fi
#
# Verify tarball.
#
night=$(cut -d. -f1 <<<${k})
${verbose} && echo "(cd ${d} && sha256sum --quiet --check ${k})"
${test} || (cd ${d} && sha256sum --quiet --check ${k})
if [[ $? != 0 ]]; then
if ${ignore_errors}; then
echo "WARNING: Checksum failure when verifying ${night}.tar, continuing anyway." >&2
else
echo "ERROR: Checksum failure when verifying ${night}.tar!" >&2
exit 1
fi
fi
#
# Unpack tarball.
#
${verbose} && echo tar -xf ${d}/${night}.tar -C ${dst_dir}
${test} || tar -xf ${d}/${night}.tar -C ${dst_dir}
#
# Set permissions.
#
${verbose} && echo "find ${night} -type f -exec chmod 0440 {} ;"
${test} || find ${night} -type f -exec chmod 0440 \{\} \;
${verbose} && echo "find ${night} -type d -exec chmod 2550 {} ;"
${test} || find ${night} -type d -exec chmod 2550 \{\} \;
${verbose} && echo chmod u+w ${night}
${test} || chmod u+w ${night}
#
# Move into place.
#
${verbose} && echo mv ${night} ../../data
${test} || mv ${night} ../../data
${verbose} && echo chmod u-w ../../data/${night}
${test} || chmod u-w ../../data/${night}
#
# Clean up.
#
${verbose} && echo rm ${d}/${night}.tar ${d}/${night}.sha256sum
${test} || rm ${d}/${night}.tar ${d}/${night}.sha256sum
${verbose} && echo "nights+=( ${night} )"
nights+=( ${night} )
done
#
# Update transfer status after all nights are in place.
#
for night in "${nights[@]}"; do
for e in ../../data/${night}/*; do
expid=$(basename ${e})
${verbose} && echo desi_transfer_status ${night} ${expid} rsync
${test} || desi_transfer_status ${night} ${expid} rsync
${verbose} && echo "(cd ${e} && sha256sum --quiet --check checksum-${expid}.sha256sum)"
${test} || (cd ${e} && sha256sum --quiet --check checksum-${expid}.sha256sum)
if [[ $? == 0 ]]; then
${verbose} && echo desi_transfer_status ${night} ${expid} checksum
${test} || desi_transfer_status ${night} ${expid} checksum
else
${verbose} && echo desi_transfer_status --failure ${night} ${expid} checksum
${test} || desi_transfer_status --failure ${night} ${expid} checksum
fi
done
${verbose} && echo desi_transfer_status ${night} all backup
${test} || desi_transfer_status ${night} all backup
done
9 changes: 4 additions & 5 deletions bin/desi_transfer_status_restore
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,18 @@ def main():
"""
bt = backup_times()
nights = os.listdir(os.environ['DESI_SPECTRO_DATA'])
status = list()
status = dict()
for night in nights:
status[night] = dict()
if night != 'README.html':
exposures = os.listdir(os.path.join(os.environ['DESI_SPECTRO_DATA'], night))
for exp in exposures:
rt = int(os.stat(os.path.join(os.environ['DESI_SPECTRO_DATA'], night, exp)).st_mtime * 1000)
status.append([int(night), int(exp), 'rsync', True, '', rt])
status.append([int(night), int(exp), 'checksum', True, '', rt])
status[night][exposure] = [[0, 1, rt], [1, 1, rt]]
try:
status.append([int(night), int(exp), 'backup', True, '', bt[night]])
status[night][exposure].append([2, 1, bt[night]])
except KeyError:
pass
status = sorted(status, key=lambda x: x[0]*10000000 + x[1], reverse=True)
with open('desi_transfer_status_restore.json', 'w') as j:
json.dump(status, j, indent=None, separators=(',', ':'))
return 0
Expand Down
11 changes: 9 additions & 2 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@
Change Log
==========

0.7.3 (unreleased)
1.0.0 (unreleased)
------------------

* No changes yet.
* *Planned*: refactor package to deprecate ``setup.py``.

0.8.0 (unreleased)
------------------

* Use a more compact format for raw data transfer status (PR `#49`_).

.. _`#49`: https://github.com/desihub/desitransfer/pull/49

0.7.2 (2022-08-11)
------------------
Expand Down
2 changes: 1 addition & 1 deletion py/desitransfer/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.7.3.dev404'
__version__ = '0.8.0.dev404'
46 changes: 36 additions & 10 deletions py/desitransfer/data/desi_transfer_status.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,47 @@
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<link rel="stylesheet" type="text/css"
href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO"
href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css"
integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N"
crossorigin="anonymous" />
<!-- <link rel="stylesheet" type="text/css" media="screen" href="dts_status.css" /> -->
<script type="text/javascript"
src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ="
crossorigin="anonymous"></script>
<script type="text/javascript"
src="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/js/bootstrap.bundle.min.js"
integrity="sha384-Fy6S3B9q64WdZWQUiU+q4/2Lc9npb8tCaSX9FK7E8HnRr0Jz8D6OP9dO5Vg3Q9ct"
crossorigin="anonymous"></script>
<script type="text/javascript" src="desi_transfer_status.js"></script>
<style type="text/css">
html { overflow-y: scroll; }
</style>
</head>
<body>
<div class="container">
<nav class="navbar navbar-light navbar-expand-lg bg-light">
<div class="container">
<a class="navbar-brand" href="https://www.desi.lbl.gov/">DESI</a>
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item active"><a class="nav-link" href="./index.html">&#127968; Home <span class="sr-only">(current)</span></a></li>
</ul>
</div><!-- end class="collapse navbar-collapse" -->
</div><!-- end class="container" -->
</nav><!-- end class="navbar" -->
<main role="main" class="container">
<div class="row">
<div class="col-12">
<div class="col">
<h1>DESI Transfer Status</h1>
</div><!-- end class="col" -->
</div><!-- end class="row" -->
<div class="row">
<div class="col">
<form>
<fieldset><legend>Display Mode</legend>
<fieldset id="years"></fieldset>
<fieldset id="display"><legend>Display Mode</legend>
<div class="form-check form-check-inline">
<input class="form-check-input displayMode" type="radio" name="displayMode" id="display10" value="display10" checked="checked" />
<label class="form-check-label displayMode" for="display10">Display Last 10 Nights</label>
Expand All @@ -35,9 +56,14 @@ <h1>DESI Transfer Status</h1>
</div>
</fieldset>
</form>
</div><!-- end class="col-12" -->
</div><!-- end class="col" -->
</div><!-- end class="row" -->
<div class="row">
<div class="col">
<h2 id="displayTitle"></h2>
</div><!-- end class="col" -->
</div><!-- end class="row" -->
<div id="content"></div>
</div><!-- end class="container" -->
</main>
</body>
</html>

0 comments on commit baa9bdf

Please sign in to comment.