download and cache data #127
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: download and cache data | |
| on: | |
| schedule: | |
| - cron: "42 4 * * 3" | |
| workflow_call: | |
| inputs: | |
| stpsf_dataset_type: | |
| type: string | |
| required: false | |
| default: "latest_release" | |
| cache_path: | |
| type: string | |
| required: false | |
| default: "" | |
| outputs: | |
| cache_key: | |
| value: ${{ jobs.combine_data_cache.outputs.cache_key }} | |
| cache_path: | |
| value: ${{ jobs.combine_data_cache.outputs.cache_path }} | |
| workflow_dispatch: | |
| inputs: | |
| stpsf_dataset_type: | |
| description: Which STPSF dataset to download, either "latest_release" or "development" | |
| type: string | |
| required: false | |
| default: "latest_release" | |
| cache_path: | |
| description: path to which to download the data | |
| type: string | |
| required: false | |
| default: "/tmp/data" | |
| jobs: | |
| download_stpsf_data: | |
| uses: spacetelescope/stpsf/.github/workflows/download_data.yml@c7453e95d48474f94e753860b40e9ea7bf5bfa11 # 2.2.0 | |
| with: | |
| dataset_type: ${{ inputs.stpsf_dataset_type }} | |
| combine_data_cache: | |
| name: combine GalSim and STPSF data into single cache | |
| needs: [download_stpsf_data] | |
| runs-on: ubuntu-latest | |
| env: | |
| GALSIM_DATA_URL: https://github.com/GalSim-developers/GalSim/raw/releases/2.4/examples/data/ | |
| steps: | |
| - id: cache_path | |
| run: echo cache_path=${{ inputs.cache_path != '' && inputs.cache_path || github.event_name == 'schedule' && '/tmp/data' || format('{0}/data', runner.temp) }} >> $GITHUB_OUTPUT | |
| - name: download GalSim data | |
| run: | | |
| mkdir galsim_data | |
| wget ${{ env.GALSIM_DATA_URL }}/real_galaxy_catalog_23.5_example.fits -O galsim_data/real_galaxy_catalog_23.5_example.fits | |
| wget ${{ env.GALSIM_DATA_URL }}/real_galaxy_catalog_23.5_example_selection.fits -O galsim_data/real_galaxy_catalog_23.5_example_selection.fits | |
| wget ${{ env.GALSIM_DATA_URL }}/real_galaxy_catalog_23.5_example_fits.fits -O galsim_data/real_galaxy_catalog_23.5_example_fits.fits | |
| - id: galsim_data | |
| run: echo "hash=${{ hashFiles( 'galsim_data/' ) }}" >> $GITHUB_OUTPUT | |
| - run: echo GALSIM_PATH=${{ steps.cache_path.outputs.cache_path }}/galsim_data/ >> $GITHUB_ENV | |
| - run: | | |
| mkdir -p ${{ env.GALSIM_PATH }} | |
| mv ./galsim_data/* ${{ env.GALSIM_PATH }} | |
| - run: echo GALSIM_CAT_PATH=${{ env.GALSIM_PATH }}real_galaxy_catalog_23.5_example.fits >> $GITHUB_ENV | |
| - name: retrieve STPSF data cache | |
| uses: actions/cache/restore@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: ${{ needs.download_stpsf_data.outputs.cache_path }} | |
| key: ${{ needs.download_stpsf_data.outputs.cache_key }} | |
| - run: mv ${{ needs.download_stpsf_data.outputs.cache_path }}/stpsf-data/ ${{ steps.cache_path.outputs.cache_path }} | |
| continue-on-error: true | |
| - run: ls ${{ steps.cache_path.outputs.cache_path }}/* | |
| - run: echo STPSF_PATH=${{ steps.cache_path.outputs.cache_path }}/stpsf-data/ >> $GITHUB_ENV | |
| - id: cache_key | |
| run: echo cache_key=${{ needs.download_stpsf_data.outputs.cache_key }}-galsim-${{ steps.galsim_data.outputs.hash }} >> $GITHUB_OUTPUT | |
| # save a new cache to the same generalized data directory, combined with extra data | |
| - name: cache combined data | |
| uses: actions/cache/save@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 | |
| with: | |
| path: ${{ steps.cache_path.outputs.cache_path }} | |
| key: ${{ steps.cache_key.outputs.cache_key }} | |
| outputs: | |
| cache_key: ${{ steps.cache_key.outputs.cache_key }} | |
| cache_path: ${{ steps.cache_path.outputs.cache_path }} |