Skip to content

Commit

Permalink
Merge pull request #75 from lsst/tickets/PREOPS-4948
Browse files Browse the repository at this point in the history
tickets/PREOPS-4948: functions to support imitating a DES nightsum report using a Times Square notebook
  • Loading branch information
ehneilsen authored Mar 6, 2024
2 parents 470e267 + 7749366 commit 7bff853
Show file tree
Hide file tree
Showing 34 changed files with 1,254 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build_container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: "3.11"
auto-update-conda: true
Expand All @@ -38,7 +38,7 @@ jobs:
- name: Access rubin-sched-data cache
id: cache-rs
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cached-rubin-sched-data
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build_docs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: "3.11"
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
shell: bash -l {0}
run: |
cd docs
package-docs build
make html
- name: Upload documentation
uses: lsst-sqre/ltd-upload@v1
Expand Down
15 changes: 7 additions & 8 deletions .github/workflows/cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- uses: actions/checkout@v4

- name: Install conda
uses: conda-incubator/setup-miniconda@v2
uses: conda-incubator/setup-miniconda@v3
with:
python-version: "3.11"
auto-update-conda: true
Expand All @@ -29,14 +29,14 @@ jobs:
id: rs-install
shell: bash -l {0}
run: |
mamba install --quiet rubin-scheduler
mamba install --quiet rubin-scheduler
mamba list rubin-scheduler | grep -v "#" | awk '{print $2}' > ${{ github.workspace }}/rs_version
echo "rs-version" `cat ${{ github.workspace }}/rs_version`
echo "rs-version=`cat ${{ github.workspace }}/rs_version`" >> $GITHUB_OUTPUT
echo "rs-version=`cat ${{ github.workspace }}/rs_version`" >> $GITHUB_OUTPUT
- name: Access rubin-sched-data cache
id: cache-rs
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cached-rubin-sched-data
with:
Expand All @@ -59,8 +59,9 @@ jobs:
name: Update/Download data.
shell: bash -l {0}
run: |
export RUBIN_SIM_DATA_DIR=~/rubin_sim_data
export RUBIN_SIM_DATA_DIR=~/rubin_sim_data
scheduler_download_data --update --tdqm_disable
rs_download_data --update --tdqm_disable --dirs sim-baseline
- name: Check data
shell: bash -l {0}
Expand All @@ -72,6 +73,4 @@ jobs:
cat $RUBIN_SIM_DATA_DIR/versions.txt
echo "is it in sync?"
scheduler_download_data --versions


rs_download_data --versions
5 changes: 1 addition & 4 deletions .github/workflows/cleanup_cache.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
echo "Fetching list of cache key"
cacheKeysForPR=$(gh actions-cache list -R $REPO -B $BRANCH | cut -f 1)
## Setting this to not fail the workflow while deleting cache keys.
## Setting this to not fail the workflow while deleting cache keys.
set +e
echo "Deleting caches..."
for cacheKey in $cacheKeysForPR
Expand All @@ -27,6 +27,3 @@ jobs:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
BRANCH: refs/pull/${{ github.event.pull_request.number }}/merge



6 changes: 3 additions & 3 deletions .github/workflows/ruff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ jobs:
isort:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: isort/isort-action@v1
with:
requirements-files: "requirements.txt test-requirements.txt"
ruff:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: chartboost/ruff-action@v1
- uses: actions/checkout@v4
- uses: chartboost/ruff-action@v1
9 changes: 5 additions & 4 deletions .github/workflows/test_and_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
python-version: ["3.11"]
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v2
- uses: conda-incubator/setup-miniconda@v3
with:
python-version: ${{ matrix.python-version }}
auto-update-conda: true
Expand All @@ -49,7 +49,7 @@ jobs:
- name: Access rubin-sched-data cache
id: cache-rs
uses: actions/cache@v3
uses: actions/cache@v4
env:
cache-name: cached-rubin-sched-data
with:
Expand All @@ -63,12 +63,13 @@ jobs:
run: |
export RUBIN_SIM_DATA_DIR=~/rubin_sim_data
scheduler_download_data --update --tdqm_disable
rs_download_data --update --tdqm_disable --dirs sim_baseline
- name: Install schedview
shell: bash -l {0}
run: |
echo `pwd`
python -m pip install . --no-deps
python -m pip install -e . --no-deps
- name: Conda list
shell: bash -l {0}
Expand All @@ -85,7 +86,7 @@ jobs:
pytest -r a -v --cov=schedview --cov=tests --cov-report=xml --cov-report=term --cov-branch
- name: Upload coverage to codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v4
with:
file: coverage.xml

Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -146,3 +146,7 @@ util/sample_data/sample_rewards.h5
util/sample_data/sample_scheduler.pickle.xz
notebooks/de421.bsp
notebooks/MPCORB.DAT.gz

# Other temporary files
tmp/*
util/tmp/*
1 change: 1 addition & 0 deletions container_environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- pandas
- astropy >= 5.3
- rubin-scheduler
- rubin-sim
- uranography >= 1.1.0
- bokeh >= 3.1.1
- panel >= 1.1.0
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ param
pytz
uranography
rubin-scheduler
rubin-sim
pip
20 changes: 14 additions & 6 deletions schedview/app/prenight/prenight.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,12 +287,20 @@ def _update_visits(self):
if not ResourcePath(self.opsim_output_fname).exists():
raise FileNotFoundError(f"Resource not found: {self.opsim_output_fname}")

visits = schedview.collect.opsim.read_opsim(
self.opsim_output_fname,
Time(self._almanac_events.loc["sunset", "UTC"]),
Time(self._almanac_events.loc["sunrise", "UTC"]),
)
if len(visits) == 0:
try:
visits = schedview.collect.opsim.read_opsim(
self.opsim_output_fname,
Time(self._almanac_events.loc["sunset", "UTC"]),
Time(self._almanac_events.loc["sunrise", "UTC"]),
)
no_data_found = len(visits) == 0
except UserWarning as user_warning:
if user_warning.args[0].startswith("No data found matching"):
no_data_found = True
else:
raise user_warning

if no_data_found:
self.logger.info("No visits on requested night, looking for a night with visits.")
# read all visits to so we can find a central one
visits = schedview.collect.opsim.read_opsim(self.opsim_output_fname)
Expand Down
1 change: 1 addition & 0 deletions schedview/collect/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"read_scheduler",
"sample_pickle",
"load_bright_stars",
"read_ddf_visits",
]

from .footprint import get_footprint
Expand Down
2 changes: 1 addition & 1 deletion schedview/collect/local.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .metrics import get_metric_path # noqa F401
from .opsim import read_opsim # noqa F401
from .opsim import read_ddf_visits, read_opsim # noqa F401
from .scheduler_pickle import read_scheduler # noqa F401
from .scheduler_pickle import sample_pickle # noqa F401
from .stars import load_bright_stars # noqa F401
Loading

0 comments on commit 7bff853

Please sign in to comment.