Skip to content

Commit e136bef

Browse files
committed
update dashboard keys
2 parents c235320 + a341392 commit e136bef

28 files changed

+2016
-69
lines changed

.github/workflows/pr.yml

Lines changed: 59 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ jobs:
2929
runs-on: ubuntu-latest
3030
environment: staging
3131
outputs:
32-
publishedCollections: ${{ steps.publish-collections.outputs.success_collections }}
33-
commentId: ${{ steps.init-comment.outputs.COMMENT_ID }}
32+
published_collections: ${{ steps.publish-collections.outputs.success_collections }}
33+
comment_id: ${{ steps.init-comment.outputs.COMMENT_ID }}
34+
has_new_files_to_promote: ${{ steps.changed-files.outputs.added_files_count != 0 }}
3435
steps:
3536
- uses: actions/checkout@v4
3637

@@ -72,8 +73,7 @@ jobs:
7273
id: changed-files
7374
uses: tj-actions/changed-files@v45
7475
with:
75-
files: |
76-
**.json
76+
files: ingestion-data/staging/dataset-config/**.json
7777

7878
- name: List all newly added files
7979
env:
@@ -85,55 +85,35 @@ jobs:
8585
done
8686
echo "added_files_count: ${ADDED_FILES_COUNT}"
8787
88-
# Uses service client creds to get token
89-
# No username/password needed
90-
- name: Get auth token
91-
id: get-token
88+
- name: Exit early if no new files
89+
if: ${{ steps.changed-files.outputs.added_files_count == 0 }}
9290
run: |
93-
echo "Vars: $vars"
94-
response=$(curl -X POST \
95-
${{ vars.STAGING_COGNITO_DOMAIN }}/oauth2/token \
96-
-H "Content-Type: application/x-www-form-urlencoded" \
97-
-d "grant_type=client_credentials" \
98-
-d "client_id=${{ vars.STAGING_CLIENT_ID }}" \
99-
-d "client_secret=${{ secrets.STAGING_CLIENT_SECRET }}"
100-
)
101-
102-
access_token=$(echo "$response" | jq -r '.access_token')
103-
echo "ACCESS_TOKEN=$access_token" >> $GITHUB_OUTPUT
91+
echo "🕵️ No new files found. Exiting workflow early."
92+
exit 0
10493
10594
# Makes request to /dataset/publish endpoint
10695
# Outputs only files that were successfully published
10796
# Used by other steps
10897
# If none of the requests are successful, workflow fails
10998
# Updates the PR comment with status of collection publication
11099
- name: Publish all newly added collections to staging
100+
if: ${{ steps.changed-files.outputs.added_files_count != 0 }}
111101
id: publish-collections
112102
env:
113103
ADDED_FILES: ${{ steps.changed-files.outputs.added_files }}
114-
WORKFLOWS_URL: ${{ vars.STAGING_WORKFLOWS_URL }}
115104
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
116-
AUTH_TOKEN: ${{ steps.get-token.outputs.ACCESS_TOKEN }}
117105
COMMENT_ID: ${{ steps.init-comment.outputs.COMMENT_ID }}
106+
STAGING_SM2A_ADMIN_USERNAME: ${{ secrets.STAGING_SM2A_ADMIN_USERNAME }}
107+
STAGING_SM2A_ADMIN_PASSWORD: ${{ secrets.STAGING_SM2A_ADMIN_PASSWORD }}
108+
STAGING_SM2A_API_URL: ${{ vars.STAGING_SM2A_API_URL }}
109+
DATASET_DAG_NAME: ${{ vars.DATASET_DAG_NAME }}
118110
run: |
119-
if [ -z "$WORKFLOWS_URL" ]; then
120-
echo "WORKFLOWS_URL is not set"
121-
exit 1
122-
fi
123-
124-
if [ -z "$AUTH_TOKEN" ]; then
125-
echo "AUTH_TOKEN is not set"
126-
exit 1
127-
fi
128-
129-
publish_url="${WORKFLOWS_URL%/}/dataset/publish"
130-
bearer_token=$AUTH_TOKEN
111+
pip install -r ./scripts/requirements.txt
131112
132113
# Track successful publications
133114
all_failed=true
134115
declare -a success_collections=()
135-
status_message='### Collection Publication Status
136-
'
116+
status_message="### Collection Publication Status"
137117
138118
for file in ${ADDED_FILES}; do
139119
echo $file
@@ -142,25 +122,21 @@ jobs:
142122
collection_id=$(jq -r '.collection' "$file")
143123
144124
echo "Publishing $collection_id"
145-
response=$(curl -s -w "%{http_code}" -o response.txt -X POST "$publish_url" \
146-
-H "Content-Type: application/json" \
147-
-H "Authorization: Bearer $AUTH_TOKEN" \
148-
-d "$dataset_config"
149-
)
150125
151-
status_code=$(tail -n1 <<< "$response")
126+
response=$(python3 ./scripts/promote_collection.py "$file" "staging")
127+
echo "Processed file: $file"
128+
status_code=$(echo "$response" | jq -r '.statusCode' | head -n1)
129+
echo "Status Code: $status_code"
152130
153131
# Update status message based on response code
154-
if [ "$status_code" -eq 200 ] || [ "$status_code" -eq 201 ]; then
132+
if [[ $status_code -eq 200 ]] || [[ $status_code -eq 201 ]]; then
155133
echo "$collection_id successfully published ✅"
156-
status_message+="- **$collection_id**: Successfully published ✅
157-
"
134+
status_message+="- **$collection_id**: Successfully published ✅"
158135
success_collections+=("$file")
159136
all_failed=false
160137
else
161138
echo "$collection_id failed to publish ❌"
162-
status_message+="- **$collection_id**: Failed to publish. Error code $status_code. ❌
163-
"
139+
status_message+="- **$collection_id**: Failed to publish. Error code $status_code. ❌"
164140
fi
165141
else
166142
echo "File $file does not exist"
@@ -207,7 +183,23 @@ jobs:
207183
** ❌ The workflow run failed. [See logs here]($WORKFLOW_URL)**"
208184
gh api -X PATCH -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/issues/comments/$COMMENT_ID -f body="$UPDATED_BODY"
209185
186+
# If the workflow fails at any point, the PR comment will be updated
187+
188+
- name: Update PR comment if no new files
189+
if: ${{ steps.changed-files.outputs.added_files_count == 0 }}
190+
env:
191+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
192+
COMMENT_ID: ${{ steps.init-comment.outputs.COMMENT_ID }}
193+
run: |
194+
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
195+
CURRENT_BODY=$(gh api -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/issues/comments/$COMMENT_ID --jq '.body')
196+
UPDATED_BODY="$CURRENT_BODY
197+
198+
🕵️ No new files found. No files will be published to staging or promoted to production."
199+
gh api -X PATCH -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/issues/comments/$COMMENT_ID -f body="$UPDATED_BODY"
200+
210201
create-mdx-files-and-open-pr:
202+
if: ${{ needs.publish-new-datasets.outputs.has_new_files_to_promote == 'true' }}
211203
runs-on: ubuntu-latest
212204
environment: staging
213205
needs: publish-new-datasets
@@ -217,12 +209,12 @@ jobs:
217209

218210
- name: Use output from publish-new-datasets
219211
run: |
220-
echo "The output from the previous step is: ${{ needs.publish-new-datasets.outputs.publishedCollections }}"
212+
echo "The output from the previous step is: ${{ needs.publish-new-datasets.outputs.published_collections }}"
221213
222214
# Creates a slim dataset mdx file for each collection based on the dataset config json
223215
- name: Create dataset mdx for given collections
224216
env:
225-
PUBLISHED_COLLECTION_FILES: ${{ needs.publish-new-datasets.outputs.publishedCollections }}
217+
PUBLISHED_COLLECTION_FILES: ${{ needs.publish-new-datasets.outputs.published_collections }}
226218
run: |
227219
echo $PUBLISHED_COLLECTION_FILES
228220
collection_ids=""
@@ -238,14 +230,27 @@ jobs:
238230
echo "Final collection_ids: $collection_ids"
239231
echo "collection_ids=${collection_ids}" >> $GITHUB_ENV
240232
233+
- name: Prepare temp directory for artifacts
234+
run: |
235+
mkdir -p /tmp/upload-artifacts
236+
for file in $(echo "${{ needs.publish-new-datasets.outputs.published_collections }}" | tr ',' ' '); do
237+
if [ -f "$file" ]; then
238+
cp "$file" /tmp/upload-artifacts/
239+
else
240+
echo "Warning: File not found - $file"
241+
fi
242+
done
243+
244+
- name: List files in temp directory
245+
run: ls -lah /tmp/upload-artifacts
246+
241247
- name: Upload published collections files as directory artifact
242248
uses: actions/upload-artifact@v4
243249
env:
244-
PUBLISHED_COLLECTION_FILES: ${{ needs.publish-new-datasets.outputs.publishedCollections }}
245250
ARTIFACT_RETENTION_DAYS: ${{ vars.ARTIFACT_RETENTION_DAYS }}
246251
with:
247252
name: collections-to-promote-from-${{ github.event.pull_request.number }}
248-
path: ${{ env.PUBLISHED_COLLECTION_FILES }}
253+
path: /tmp/upload-artifacts/*
249254
retention-days: ${{ env.ARTIFACT_RETENTION_DAYS }}
250255

251256
- name: Save Workflow Run ID
@@ -357,7 +362,7 @@ jobs:
357362
- name: Create veda-config PR with changes
358363
id: create-pr
359364
env:
360-
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.commentId }}
365+
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.comment_id }}
361366
PUBLISHED_COLLECTION_FILES: ${{ steps.publish-collections.outputs.success_collections }}
362367
run: |
363368
cd veda-config
@@ -401,7 +406,7 @@ jobs:
401406
if: success()
402407
env:
403408
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
404-
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.commentId }}
409+
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.comment_id }}
405410
run: |
406411
PR_URL=${{ steps.create-pr.outputs.PR_URL }}
407412
CURRENT_BODY=$(gh api -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/issues/comments/$COMMENT_ID --jq '.body')
@@ -414,7 +419,7 @@ jobs:
414419
if: failure() && steps.create-pr.outcome == 'failure'
415420
env:
416421
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
417-
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.commentId }}
422+
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.comment_id }}
418423
run: |
419424
CURRENT_BODY=$(gh api -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/issues/comments/$COMMENT_ID --jq '.body')
420425
UPDATED_BODY="$CURRENT_BODY
@@ -427,7 +432,7 @@ jobs:
427432
if: failure() && steps.create-pr.outcome != 'failure'
428433
env:
429434
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
430-
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.commentId }}
435+
COMMENT_ID: ${{ needs.publish-new-datasets.outputs.comment_id }}
431436
run: |
432437
WORKFLOW_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
433438
CURRENT_BODY=$(gh api -H "Authorization: token $GITHUB_TOKEN" /repos/${{ github.repository }}/issues/comments/$COMMENT_ID --jq '.body')

.github/workflows/promote.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,14 @@ jobs:
6969
run: |
7070
pip install -r ./scripts/requirements.txt
7171
for file in downloaded-files/*.json; do
72-
python3 ./scripts/promote_to_production.py "$file"
72+
collection_id=$(jq -r '.collection' "$file")
73+
response=$(python3 ./scripts/promote_collection.py "$file" "production")
7374
echo "Processed file: $file"
75+
status_code=$(echo "$response" | jq -r '.statusCode')
76+
echo "Status Code: $status_code"
77+
if [ $status_code -eq 200 ] || [ $status_code -eq 201 ]; then
78+
echo "$collection_id successfully promoted to Production ✅"
79+
else
80+
echo "$collection_id failed to promote to Production ❌"
81+
fi
7482
done
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
{
2+
"license": "CC0-1.0",
3+
"stac_version": "1.0.0",
4+
"links": [],
5+
"spatial_extent": {
6+
"xmin": -90.85,
7+
"ymin": 29.03,
8+
"xmax": -90.06,
9+
"ymax": 29.65
10+
},
11+
"temporal_extent": {
12+
"startdate": "2021-08-23T00:00:00.000Z",
13+
"enddate": "2021-09-09T23:59:59.000Z"
14+
},
15+
"discovery_items": [
16+
{
17+
"upload": false,
18+
"cogify": false,
19+
"dry_run": false,
20+
"filename_regex": "(.*)NDWI_Difference_(.*).tif$",
21+
"use_multithreading": false,
22+
"discovery": "s3",
23+
"prefix": "planet-indices-v2/",
24+
"bucket": "veda-data-store-staging"
25+
}
26+
],
27+
"sample_files": [
28+
"s3://veda-data-store-staging/planet-indices-v2/NDWI_Difference_2021-08-23_2021-09-09.tif"
29+
],
30+
"data_type": "cog",
31+
"stac_extensions": [
32+
"https://stac-extensions.github.io/render/v1.0.0/schema.json",
33+
"https://stac-extensions.github.io/item-assets/v1.0.0/schema.json"
34+
],
35+
"item_assets": {
36+
"cog_default": {
37+
"type": "image/tiff; application=geotiff; profile=cloud-optimized",
38+
"roles": [
39+
"data",
40+
"layer"
41+
],
42+
"title": "Default COG Layer",
43+
"description": "Cloud optimized default layer to display on map"
44+
}
45+
},
46+
"providers": [
47+
{
48+
"name": "NASA VEDA",
49+
"roles": [
50+
"host"
51+
],
52+
"url": "https://www.earthdata.nasa.gov/dashboard/"
53+
}
54+
],
55+
"assets": {
56+
"thumbnail": {
57+
"title": "Thumbnail",
58+
"type": "image/jpeg",
59+
"roles": [
60+
"thumbnail"
61+
],
62+
"href": "https://thumbnails.openveda.cloud/louisiana-marsh.jpg",
63+
"description": "Photo by [Bridget Besaw](https://www.nature.org/en-us/get-involved/how-to-help/places-we-protect/the-nature-conservancy-in-louisiana-gulf-coast-prairies-and-marshes/) (Wetland landscape across southern Louisiana.)"
64+
}
65+
},
66+
"collection": "ida-ndwi-difference-TEST-SHOULDNT-RUN",
67+
"title": "NDWI Difference for Pre and Post-Hurricane Ida from PlanetScope TEST-SHOULDNT-RUN",
68+
"dashboard:time_density": "day",
69+
"description": "Normalized Difference Water Index Difference of before and after Hurricane Ida in Southern Louisiana.",
70+
"renders": {
71+
"dashboard": {
72+
"resampling": "nearest",
73+
"bidx": [
74+
1
75+
],
76+
"colormap_name": "rdbu",
77+
"assets": [
78+
"cog_default"
79+
],
80+
"rescale": [
81+
[
82+
-1,
83+
1
84+
]
85+
],
86+
"title": "VEDA Dashboard Render Parameters"
87+
}
88+
},
89+
"dashboard:is_periodic": true
90+
}

0 commit comments

Comments
 (0)