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

Updates for daily loading, kibo, sqlalchemy 2. #14

Merged
merged 118 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
118 commits
Select commit Hold shift + click to select a range
d32039e
change hostname
weaverba137 May 10, 2024
0af5563
update Dockerfile
weaverba137 May 10, 2024
e76f766
fix bug in version load
weaverba137 May 10, 2024
3a83b26
change from engine to connection
weaverba137 May 11, 2024
06301c6
wrap sql in text
weaverba137 May 11, 2024
b2c5eaf
fix tests
weaverba137 May 11, 2024
178ddae
add config section for daily
weaverba137 May 13, 2024
27bf269
add placeholder for daily redshifts
weaverba137 May 13, 2024
540c07e
load from csv file
weaverba137 May 13, 2024
eae45e8
skip zpix corrections for daily reductions
weaverba137 May 13, 2024
002ac4d
add entry for jura
weaverba137 May 31, 2024
d20f13b
Add notes on daily loading
weaverba137 May 31, 2024
45a2e64
more info on daliy
weaverba137 May 31, 2024
3f37c58
add test notebook
weaverba137 Jun 5, 2024
15fc6a0
update notes
weaverba137 Jun 5, 2024
a4b68b1
Merge branch 'sqlalchemy-2' of github.com:desihub/specprod-db into sq…
weaverba137 Jun 5, 2024
e39d8c4
add notebook
weaverba137 Jun 7, 2024
ad40444
Merge branch 'sqlalchemy-2' of github.com:desihub/specprod-db into sq…
weaverba137 Jun 7, 2024
73789a1
working full load of one tile
weaverba137 Jul 23, 2024
4a32623
add some notes
weaverba137 Jul 23, 2024
b69cf1a
Add no_sky function
weaverba137 Jul 24, 2024
e3ab130
update tests
weaverba137 Jul 24, 2024
2986d0e
fix desitarget url
weaverba137 Jul 24, 2024
159b599
add a "self" loader
weaverba137 Jul 24, 2024
c3f7f7a
add more converters
weaverba137 Jul 24, 2024
4d2c407
more loaders
weaverba137 Jul 24, 2024
f0264ee
fix key error
weaverba137 Jul 24, 2024
767b0bc
update notebooks
weaverba137 Jul 26, 2024
18d5adb
latest notebook updates
weaverba137 Jul 30, 2024
44a2265
add convert method to Ztile
weaverba137 Jul 31, 2024
5d1ce11
update ztile conversion method
weaverba137 Aug 1, 2024
560ccb9
check in notebooks
weaverba137 Aug 1, 2024
af4712f
add tile.py
weaverba137 Aug 7, 2024
e3b4f16
move code into tile.py
weaverba137 Aug 7, 2024
3bc2c38
fix typo
weaverba137 Aug 7, 2024
9701284
add target loading functions
weaverba137 Aug 7, 2024
f722948
move more code over from the notebook
weaverba137 Aug 7, 2024
9baab7b
update notebook
weaverba137 Aug 7, 2024
25eea3b
Add tests for load.py
weaverba137 Aug 12, 2024
7941785
install scipy for tests
weaverba137 Aug 12, 2024
a7be554
install fitsio for tests
weaverba137 Aug 12, 2024
a441711
add numba for tests
weaverba137 Aug 12, 2024
6e83d5e
pin scipy version
weaverba137 Aug 12, 2024
9ae8b3c
install desimodel
weaverba137 Aug 12, 2024
eb8373a
reduce number of numpy versions
weaverba137 Aug 12, 2024
20bdf84
skip 3.11 tests
weaverba137 Aug 12, 2024
99362fd
add tests to notebook
weaverba137 Aug 12, 2024
2b1245a
notebook update
weaverba137 Aug 13, 2024
556e078
fix goaltype length
weaverba137 Aug 14, 2024
e6eef4d
update container startup script
weaverba137 Aug 14, 2024
0e5afdf
update notebooks
weaverba137 Aug 14, 2024
17381b3
add a template for tile-based batch scripts
weaverba137 Aug 20, 2024
f1999c2
add tiles to batch generation script
weaverba137 Aug 20, 2024
1868018
handle patched files differently
weaverba137 Aug 20, 2024
93179b2
move script when done
weaverba137 Aug 20, 2024
b1423eb
fix batch tests
weaverba137 Aug 20, 2024
063cfe3
rollback on bad tiles or exposures.
weaverba137 Aug 20, 2024
55be99a
notebook update
weaverba137 Aug 22, 2024
f60ff6f
cut tile list
weaverba137 Aug 22, 2024
0f0ce0e
fix index error
weaverba137 Aug 22, 2024
b68e539
add job submission script
weaverba137 Aug 23, 2024
f57937b
fix syntax
weaverba137 Aug 23, 2024
3d9eb3d
add additional submission script
weaverba137 Aug 23, 2024
089e176
improve submission scripts
weaverba137 Aug 23, 2024
aa0b4ac
always use module swap
weaverba137 Aug 23, 2024
d226b26
fix test
weaverba137 Aug 23, 2024
2c788bb
update patch notebook
weaverba137 Aug 23, 2024
222da36
don't mask function names with variable names
weaverba137 Aug 26, 2024
239400a
fix variable name
weaverba137 Aug 26, 2024
cd95467
move patch code into command-line script.
weaverba137 Aug 26, 2024
63818cb
fix typo
weaverba137 Aug 26, 2024
71b92f4
copy original files
weaverba137 Aug 26, 2024
d2b5312
patch code clean-up
weaverba137 Aug 27, 2024
1fe412d
remove program mask
weaverba137 Aug 27, 2024
3cb0e87
reduce tile time to 30 minutes
weaverba137 Aug 27, 2024
ba7cb5a
fix bug when converting ztile defaults
weaverba137 Aug 27, 2024
5cc344c
restore production hostname
weaverba137 Aug 27, 2024
a6355e9
read zbest if redrock not found
weaverba137 Sep 3, 2024
5ae53b3
patch only masked values
weaverba137 Sep 4, 2024
4f9d1d7
check for column presence in src
weaverba137 Sep 4, 2024
461fd23
check for extra copies
weaverba137 Sep 4, 2024
b149584
copy results back to patch
weaverba137 Sep 4, 2024
54c8f55
compare data attribute
weaverba137 Sep 4, 2024
c549db5
copy back values
weaverba137 Sep 4, 2024
14d9b4e
patch TILERA, TILEDEC for tiles
weaverba137 Sep 4, 2024
2ce7f95
debugging TILEDEC
weaverba137 Sep 4, 2024
91be4c8
find bad ra,dec before patching
weaverba137 Sep 4, 2024
29ad83c
more debugging
weaverba137 Sep 4, 2024
1389af3
fix join typo
weaverba137 Sep 4, 2024
8362ac3
number of rows
weaverba137 Sep 4, 2024
9f0ad04
fix style
weaverba137 Sep 4, 2024
18d07ad
handle missing mask
weaverba137 Sep 4, 2024
6cb211c
consolidate join code
weaverba137 Sep 4, 2024
2277688
restrict range when patching MJD
weaverba137 Sep 4, 2024
22a6745
minor formatting change
weaverba137 Sep 4, 2024
0b3168e
update notebooks
weaverba137 Sep 4, 2024
4d65d82
patch all columns in all frames
weaverba137 Sep 6, 2024
ce8d183
don't patch TSNR2_ALPHA
weaverba137 Sep 6, 2024
a43b354
copy mjd back into frames
weaverba137 Sep 6, 2024
6a5a622
debugging
weaverba137 Sep 6, 2024
654499b
check for exposures still zero
weaverba137 Sep 6, 2024
72bc7ea
update notebook
weaverba137 Sep 10, 2024
e938492
latest notebook tests
weaverba137 Sep 12, 2024
1a3c90a
add UPDATED column to tiles
weaverba137 Sep 12, 2024
a195c06
add notes on daily loading
weaverba137 Sep 17, 2024
49c9f50
fix style
weaverba137 Sep 17, 2024
669154e
fix tile patching
weaverba137 Sep 20, 2024
90d3a8f
also patch unknown
weaverba137 Sep 20, 2024
1ce434d
fix typo
weaverba137 Sep 20, 2024
1283a16
fix index error
weaverba137 Sep 20, 2024
a293c03
fix qa check
weaverba137 Sep 20, 2024
650659c
update change log
weaverba137 Sep 20, 2024
ba9146e
document changes to goaltype
weaverba137 Sep 20, 2024
f5de544
add support for desi_public
weaverba137 Sep 25, 2024
364bf34
update convert methods to support monolithic loading
weaverba137 Sep 25, 2024
62d8cf1
fix style
weaverba137 Sep 25, 2024
9d7691b
restore default configuration prior to tagging
weaverba137 Sep 26, 2024
485f90d
update change log
weaverba137 Sep 26, 2024
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
55 changes: 32 additions & 23 deletions .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,35 @@ jobs:
fail-fast: true
matrix:
os: [ubuntu-latest]
python-version: ['3.9', '3.10']
numpy-version: ['<1.23']
astropy-version: ['<5.1', '<6.0']
python-version: ['3.10'] # , '3.11'] The 3.11 tests take a long time, so skip for now.
numpy-version: ['<1.23'] # , '<2.0'] Need to find a scipy version that works for 3.11 and pre-2.0 numpy
astropy-version: ['<6.1', '<7.0']

env:
DESIUTIL_VERSION: '3.3.0'
DESISPEC_VERSION: '0.56.2'
# Versions correspond to desimodules/24.6
DESIUTIL_VERSION: '3.4.2'
DESISPEC_VERSION: '0.63.7'
DESITARGET_VERSION: '2.7.0'
DESIMODEL_VERSION: '0.19.1'

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install git+https://github.com/desihub/desiutil.git@${DESIUTIL_VERSION}#egg=desiutil
python -m pip install git+https://github.com/desihub/desispec.git@${DESISPEC_VERSION}#egg=desispec
python -m pip install git+https://github.com/desihub/desitarget.git@${DESITARGET_VERSION}#egg=desitarget
python -m pip install git+https://github.com/desihub/desimodel.git@${DESIMODEL_VERSION}#egg=desimodel
python -m pip install --upgrade "numpy${{ matrix.numpy-version }}"
python -m pip install --upgrade "astropy${{ matrix.astropy-version }}"
python -m pip install --upgrade "astropy${{ matrix.astropy-version }}" 'scipy<1.13' fitsio numba
python -m pip install --editable .[test]
- name: Run the test
run: pytest
Expand All @@ -54,28 +59,32 @@ jobs:
os: [ubuntu-latest]
python-version: ['3.10']
numpy-version: ['<1.23']
astropy-version: ['<5.1']
astropy-version: ['<6.1']

env:
DESIUTIL_VERSION: '3.3.0'
DESISPEC_VERSION: '0.56.2'
DESIUTIL_VERSION: '3.4.2'
DESISPEC_VERSION: '0.63.7'
DESITARGET_VERSION: '2.7.0'
DESIMODEL_VERSION: '0.19.1'

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install git+https://github.com/desihub/desiutil.git@${DESIUTIL_VERSION}#egg=desiutil
python -m pip install git+https://github.com/desihub/desispec.git@${DESISPEC_VERSION}#egg=desispec
python -m pip install git+https://github.com/desihub/desitarget.git@${DESITARGET_VERSION}#egg=desitarget
python -m pip install git+https://github.com/desihub/desimodel.git@${DESIMODEL_VERSION}#egg=desimodel
python -m pip install --upgrade "numpy${{ matrix.numpy-version }}"
python -m pip install --upgrade "astropy${{ matrix.astropy-version }}"
python -m pip install --upgrade "astropy${{ matrix.astropy-version }}" 'scipy<1.13' fitsio numba
python -m pip install --editable .[coverage]
- name: Run the test with coverage
run: pytest --cov
Expand All @@ -96,11 +105,11 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
Expand All @@ -117,15 +126,15 @@ jobs:
os: [ubuntu-latest]
python-version: ['3.10']
env:
DESIUTIL_VERSION: '3.3.0'
DESIUTIL_VERSION: '3.4.2'

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
Expand All @@ -148,16 +157,16 @@ jobs:

steps:
- name: Checkout code
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: python -m pip install --upgrade pip setuptools wheel pycodestyle
- name: Test the style; failures are allowed
# This is equivalent to an allowed falure.
- name: Test the style
# Uncomment continue-on-error to allow failures.
# continue-on-error: true
run: pycodestyle --count py/specprodDB
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ ENV/
env.bak/
venv.bak/
.vscode/
spin/db/docker-env.txt

# Spyder project settings
.spyderproject
Expand Down
5 changes: 5 additions & 0 deletions bin/load_specprod_tile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python
# See top-level LICENSE.rst file for Copyright information
from specprodDB.tile import main
from sys import exit
exit(main())
5 changes: 5 additions & 0 deletions bin/patch_specprod
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env python
# See top-level LICENSE.rst file for Copyright information
from specprodDB.patch import main
from sys import exit
exit(main())
60 changes: 60 additions & 0 deletions bin/submit_load_specprod_db.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash
#
# Submit load_specprod_db jobs in sequence.
#
function usage() {
local execName=$(basename $0)
(
echo "${execName} [-h] [-s SHELL] [-t] [-v] SPECPROD"
echo ""
echo "Submit load_specprod_db jobs in sequence."
echo ""
echo " -h = Print help message and exit."
echo " -s SHELL = Scripts have extension SHELL, default 'sh'."
echo " -t = Test mode. Do not make any changes. Implies -v."
echo " -v = Verbose mode. Print lots of extra information."
echo " SPECPROD = The specprod jobs to submit, e.g. 'iron'."
) >&2
}
#
# Command-line options.
#
shell=sh
test=/usr/bin/false
verbose=/usr/bin/false
while getopts hs:tv argname; do
case ${argname} in
h) usage; exit 0 ;;
s) shell=${OPTARG} ;;
t) test=/usr/bin/true; verbose=/usr/bin/true ;;
v) verbose=/usr/bin/true ;;
*) usage; exit 1 ;;
esac
done
shift $((OPTIND - 1))
#
# Get the specprod value.
#
if [[ $# > 0 ]]; then
specprod=$1
else
echo "ERROR: SPECPROD must be set!" >&2
exit 1
fi
#
# Loop over jobs.
#
job_id=0
for stage in exposures photometry targetphot target redshift fiberassign; do
if [[ "${stage}" == "exposures" ]]; then
dependency=''
else
dependency="--dependency=afterok:${job_id}"
fi
${verbose} && echo "DEBUG: sbatch --parsable ${dependency} load_specprod_db_${specprod}_${stage}.${shell}"
if ${test}; then
job_id=$(( job_id + 1 ))
else
job_id=$(sbatch --parsable ${dependency} load_specprod_db_${specprod}_${stage}.${shell})
fi
done
90 changes: 90 additions & 0 deletions bin/submit_load_specprod_tile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/bin/bash
#
# Submit load_specprod_tile jobs in a chained sequence.
#
function usage() {
local execName=$(basename $0)
(
echo "${execName} [-h] [-j N] [-s SHELL] [-t] [-v]"
echo ""
echo "Submit load_specprod_tile jobs in sequence."
echo ""
echo " -h = Print help message and exit."
echo " -j N = Only submit N jobs."
echo " -s SHELL = Scripts have extension SHELL, default 'sh'."
echo " -t = Test mode. Do not make any changes. Implies -v."
echo " -v = Verbose mode. Print lots of extra information."
) >&2
}
#
# Command-line options.
#
n_jobs=0
shell=sh
test=/usr/bin/false
verbose=/usr/bin/false
while getopts hj:s:tv argname; do
case ${argname} in
h) usage; exit 0 ;;
j) n_jobs=${OPTARG} ;;
s) shell=${OPTARG} ;;
t) test=/usr/bin/true; verbose=/usr/bin/true ;;
v) verbose=/usr/bin/true ;;
*) usage; exit 1 ;;
esac
done
shift $((OPTIND - 1))
#
# Find the first tile and submit it.
#
first_tile=$(grep -- --overwrite load_specprod_tile_*.${shell} | cut -d: -f1)
if [[ -n "${first_tile}" ]]; then
${verbose} && echo "DEBUG: sbatch --parsable ${first_tile}"
if ${test}; then
job_id=1
else
job_id=$(sbatch --parsable ${first_tile})
fi
n_submitted=1
else
echo "INFO: No first tile found, assuming it has already been loaded."
job_id=0
n_submitted=0
fi
#
# Find the last tile.
#
last_tile=$(grep -- --primary load_specprod_tile_*.${shell} | cut -d: -f1)
#
# Loop over tiles.
#
for tile in load_specprod_tile_*.${shell}; do
if [[ "${tile}" == "${first_tile}" ]]; then
${verbose} && echo "DEBUG: First tile, ${first_tile}, already submitted."
elif [[ "${tile}" == "${last_tile}" ]]; then
${verbose} && echo "DEBUG: Last tile, ${last_tile}, will be skipped."
else
if [[ ${job_id} == 0 ]]; then
dependency=''
else
dependency="--dependency=afterok:${job_id}"
fi
${verbose} && echo "DEBUG: sbatch --parsable ${dependency} ${tile}"
if ${test}; then
job_id=$(( job_id + 1 ))
else
job_id=$(sbatch --parsable ${dependency} ${tile})
fi
n_submitted=$(( n_submitted + 1 ))
if (( n_submitted == n_jobs )); then
echo "INFO: ${n_jobs} have been submitted, exiting."
exit 0
fi
fi
done
${verbose} && echo "DEBUG: sbatch --dependency=afterok:${job_id} ${last_tile}"
if ${test}; then
:
else
sbatch --dependency=afterok:${job_id} ${last_tile}
fi
6 changes: 6 additions & 0 deletions doc/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,11 @@ specprodDB API
.. automodule:: specprodDB.load
:members:

.. automodule:: specprodDB.patch
:members:

.. automodule:: specprodDB.tile
:members:

.. automodule:: specprodDB.util
:members:
11 changes: 8 additions & 3 deletions doc/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,25 @@ Change Log
1.3.0 (unreleaded)
------------------

*Planned*: Support loading ongoing daily reductions.
*Planned*: Support loading ongoing daily reductions, in particular, updates
to tiles already in the database.

1.2.0 (unreleased)
------------------

This release corresponds to loading the ``guadalupe`` and ``iron`` spectroscopic
productions in preparation for DR1. See also PR `#12`_. Some specific changes:
productions in preparation for DR1. See also PR `#12`_ and `#14`_. Some specific changes:

* Photometry and target data are split among several files instead of a monolithic file.
* Add ``DESINAME`` column to redshift tabled.
* Add ``DESINAME`` column to redshift tables.
* Move version configuration to a configuration file.
* Default values for targeting bits when they are absent from target files.
* Support SQLAlchemy 2.
* ORM objects know how to "load themselves".
* Support for tile-based loading, needed to load ``daily`` reductions.

.. _`#12`: https://github.com/desihub/specprod-db/pull/12
.. _`#14`: https://github.com/desihub/specprod-db/pull/14

1.1.0 (2023-06-09)
------------------
Expand Down
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
# some external dependencies are not met at build time and break the
# building process.
autodoc_mock_imports = []
for missing in ('desiutil', 'desispec', 'numpy', 'astropy', 'pytz', 'sqlalchemy'):
for missing in ('desiutil', 'desispec', 'desitarget', 'numpy', 'astropy', 'pytz', 'sqlalchemy'):
try:
foo = import_module(missing)
except ImportError:
Expand Down
Loading