-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'spacetelescope:main' into fix-ifu
- Loading branch information
Showing
25 changed files
with
8,628 additions
and
141 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
name: Deprecate Notebook | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
notebook_name: | ||
description: 'The name of the notebook to deprecate (e.g., example.ipynb)' | ||
required: true | ||
default: 'example.ipynb' | ||
|
||
jobs: | ||
deprecate: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Find notebook path | ||
id: find_path | ||
run: | | ||
NOTEBOOK_NAME="${{ github.event.inputs.notebook_name }}" | ||
NOTEBOOK_PATH=$(find ./notebooks -name "$NOTEBOOK_NAME" -type f) | ||
if [ -z "$NOTEBOOK_PATH" ]; then | ||
echo "::error::Notebook '${NOTEBOOK_NAME}' not found in the notebooks directory." | ||
exit 1 | ||
fi | ||
echo "notebook_path=$NOTEBOOK_PATH" >> $GITHUB_ENV | ||
# - name: Check for deprecated tag | ||
# id: check_deprecated | ||
# run: | | ||
# notebook_path="${{ env.notebook_path }}" | ||
# if jq '.metadata.deprecated == true' "$notebook_path"; then | ||
# echo "::error::Notebook '${{ env.notebook_path }}' is already flagged as deprecated." | ||
# exit 0 | ||
# fi | ||
|
||
- name: Add deprecated tag with timestamp and removal date | ||
run: | | ||
notebook_path="${{ env.notebook_path }}" | ||
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
removal_date=$(date -u -d "$timestamp + 30 days" +"%Y-%m-%dT%H:%M:%SZ") | ||
jq --arg ts "$timestamp" --arg rd "$removal_date" \ | ||
'.metadata.deprecated = { "status": true, "timestamp": $ts, "removal_date": $rd }' \ | ||
"$notebook_path" > temp.ipynb && mv temp.ipynb "$notebook_path" | ||
- name: Add deprecation banner with timestamp and removal date | ||
run: | | ||
notebook_path="${{ env.notebook_path }}" | ||
timestamp=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
removal_date=$(date -u -d "$timestamp + 30 days" +"%Y-%m-%d") | ||
BANNER_CELL=$(jq -n \ | ||
--arg text "<div style='border: 3px solid red; padding: 10px; text-align: center; font-weight: bold; color: red;'>⚠️ This notebook is scheduled for deprecation as of $timestamp and is planned for removal by $removal_date. Future use is discouraged.</div>" \ | ||
'{"cell_type": "markdown", "metadata": {"deprecation": true}, "source": [$text]}') | ||
jq ".cells |= [$BANNER_CELL] + ." "$notebook_path" > temp.ipynb && mv temp.ipynb "$notebook_path" | ||
- name: Commit and push to gh-storage branch | ||
run: | | ||
git config --global user.name "github-actions" | ||
git config --global user.email "github-actions@github.com" | ||
git checkout -B gh-storage | ||
git add "${{ env.notebook_path }}" | ||
git commit -m "Deprecate notebook ${{ env.notebook_path }}" | ||
git push origin gh-storage --force |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
name: Move Deprecated Notebooks | ||
|
||
on: | ||
workflow_dispatch: | ||
schedule: | ||
- cron: '0 3 * * *' # Runs daily at 3 AM UTC | ||
|
||
jobs: | ||
check_and_move: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
ref: gh-storage # Start from the gh-storage branch | ||
|
||
- name: Set up date variables | ||
id: date_setup | ||
run: | | ||
CURRENT_DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ") | ||
echo "current_date=$CURRENT_DATE" >> $GITHUB_ENV | ||
- name: Find all deprecated notebooks | ||
id: find_deprecated | ||
run: | | ||
# Find all notebooks with the deprecation flag set | ||
DEPRECATED_NOTEBOOKS=$(find ./notebooks -name "*.ipynb" -exec jq -r 'select(.metadata.deprecated.status == true) | input_filename' {} \;) | ||
if [ -z "$DEPRECATED_NOTEBOOKS" ]; then | ||
echo "No deprecated notebooks found." | ||
exit 0 | ||
fi | ||
echo "deprecated_notebooks=$DEPRECATED_NOTEBOOKS" >> $GITHUB_ENV | ||
- name: Process deprecated notebooks | ||
run: | | ||
current_date="${{ env.current_date }}" | ||
deprecated_notebooks="${{ env.deprecated_notebooks }}" | ||
for notebook_path in $deprecated_notebooks; do | ||
# Extract the removal date from the notebook metadata | ||
removal_date=$(jq -r '.metadata.deprecated.removal_date' "$notebook_path") | ||
# Check if the current date is past the removal date | ||
if [[ "$current_date" > "$removal_date" ]]; then | ||
echo "Notebook $notebook_path is past the deprecation date ($removal_date). Moving to 'deprecated' branch." | ||
# Determine the notebook's directory | ||
notebook_dir=$(dirname "$notebook_path") | ||
else | ||
echo "Notebook $notebook_path is not past the deprecation date ($removal_date)." | ||
fi | ||
done | ||
# Checkout deprecated branch | ||
git fetch origin deprecated | ||
git checkout deprecated || git checkout -b deprecated | ||
# Move the entire folder to the deprecated branch | ||
git mv "$notebook_dir" . | ||
# Commit changes on deprecated branch | ||
git add . | ||
git commit -m "Moved deprecated notebook $notebook_path to deprecated branch" | ||
# Push changes to the deprecated branch | ||
git push origin deprecated | ||
# Checkout main branch | ||
git checkout main | ||
# Remove the folder from main | ||
git rm -r "$notebook_dir" | ||
# Commit changes on main branch | ||
git add . | ||
git commit -m "Removed deprecated notebook $notebook_path from main branch" | ||
# Push changes to the main branch | ||
git push origin main | ||
# Return to gh-storage branch | ||
git checkout gh-storage | ||
else | ||
echo "Notebook $notebook_path is not past the deprecation date ($removal_date)." | ||
fi | ||
done |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,15 @@ __pycache__/ | |
# C extensions | ||
*.so | ||
|
||
|
||
|
||
# FITS files | ||
*.fits | ||
|
||
|
||
|
||
|
||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
jdaviz >= 3.6.0 | ||
astropy >= 5.3.1 | ||
jwst >= 1.11.3 | ||
specreduce >= 1.3.0 | ||
|
||
specreduce >= 1.3.0 |
Oops, something went wrong.