Skip to content

Commit

Permalink
Merge branch 'main' into mgwalker/1145-precip-tables-across-days
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-gade authored Oct 2, 2024
2 parents d4f0374 + 6989ec4 commit 796aeeb
Show file tree
Hide file tree
Showing 13 changed files with 264 additions and 202 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/deploy-sandbox.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ on:
- design
- eric
- greg
- james

jobs:
deploy-sandbox:
Expand All @@ -32,7 +33,7 @@ jobs:
cf_password: ${{ secrets[env.CF_PASSWORD] }}
cf_org: nws-weathergov
cf_space: ${{ github.event.inputs.environment }}
cf_command: "push -f manifests/manifest-${{ github.event.inputs.environment }}.yaml --var newrelic-license=${{ secrets.NEWRELIC_LICENSE }} --strategy rolling"
cf_command: "push -f manifests/manifest-${{ github.event.inputs.environment }}.yaml --var newrelic-license='${{ secrets.NEWRELIC_LICENSE }}' --var allowed-ips='${{secrets.ALLOWED_IP_ADDRESSES}}' --strategy rolling"

- name: Run post-deploy steps in ${{ github.event.inputs.environment }} space
uses: cloud-gov/cg-cli-tools@main
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# We will use an interoperability layer between the NWS public API and the website

Date: 2024-10-01

### Status

Accepted

### Context

The public NWS API is primary data source for all observation and forecast data. The way it is architected, it requires multiple roundtrip REST requests to obtain all of the information needed to display our website. The data that comes back from the API is not precisely the structure that works best for our website, so we do some amount of processing on it before using it to render the site. We currently cache API responses with Drupal caching mechanisms, but we do not cache the processed results.

### Decision

We will introduce a new API interop layer that sits between Drupal and the public NWS API. This layer will be built in Node.js to take advantage of its multithreading support and low memory footprint.

The interop layer will present a single endpoint that returns all of the data relevant to rendering the website. Behind the scenes, the interop layer will make the necessary calls to the public API and the local geospatial database tables. The interop layer will also handle most of the processing of the raw data into structures that directly serve the website.

### Consequences

#### Positive
- In the immediate term, our Drupal modules for fetching data will be dramatically simplified if not entirely replaced. Because Drupal is single-threaded, offloading this functionality should have a positive impact on page load times.
- In the longer term, the interop layer can add caching for processed data, allowing much faster responses to page requests.
- The most significant portion of backend code is moved out of PHP and into Javascript, a language that is easier to support by 18F staff. Javascript also has very broad industry support (as does PHP), so this should not have any downstream negative consequences.
- We should have more flexibility over how we handle error cases. Currently our response to errors from the API is to simply show a red banner for whichever data component failed. Because of how the site was built with intertangled blocks, an error in one data component could cascade into errors for other components (e.g., if the forecast causes an error, we also don't show alerts). With the interop layer, we have an opportunity to separate the data components more cleanly and have more fine-grained error handling.

#### Neutral
- Additional cloud resources will be required. It seems likely to be a relatively small impact since the total amount of computation work will remain roughly the same.

#### Negative
- The interop layer introduces an additional programming language and runtime environment, increasing complexity.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"devDependencies": {
"@axe-core/playwright": "^4.10.0",
"@playwright/test": "^1.47.2",
"@types/node": "^22.7.1",
"@types/node": "^22.7.4",
"axe-core": "^4.10.0",
"chai": "^5.1.1",
"cypress": "^13.14.2",
Expand Down
90 changes: 90 additions & 0 deletions tests/api/data/e2e/alerts/active__status=actual&area=CA.json
Original file line number Diff line number Diff line change
Expand Up @@ -5588,6 +5588,96 @@
"eventEndingTime": ["2024-01-05T02:00:00+00:00"]
}
}
},
{
"id": "https://alert/tropical_cyclone_local_statement}",
"type": "Feature",
"geometry": null,
"properties": {
"@id": "https://alert/tropical_cyclone_local_statement}",
"@type": "wx:Alert",
"id": "tropical_cyclone_local_statement",
"areaDesc": "Over there. Over there. Send the word, to be heard, over there",
"geocode": {
"SAME": [],
"UGC": []
},
"affectedZones": ["https://every-alert/zone"],
"references": [],
"sent": "date:now -1 hour",
"effective": "date:now -1 hour",
"onset": "date:now -1 hour",
"expires": "date:now +1 hour",
"ends": "date:now +1 hour",
"status": "Actual",
"messageType": "Alert",
"category": "Met",
"severity": "Severe",
"certainty": "Likely",
"urgency": "Expected",
"event": "tropical cyclone local statement",
"sender": "w-nws.webmaster@noaa.gov",
"senderName": "NWS Anchorage AK",
"headline": "Tropical Cyclone Local Statement",
"description": "Not real",
"instruction": null,
"response": "Avoid",
"parameters": {
"AWIPSidentifier": ["CWFALU"],
"WMOidentifier": ["FZAK52 PAFC 031605 AAA"],
"NWSheadline": [
"GALE WARNING THROUGH THURSDAY... ...HEAVY FREEZING SPRAY WARNING TONIGHT AND THURSDAY"
],
"BLOCKCHANNEL": ["EAS", "NWEM", "CMAS"],
"VTEC": ["/O.NEW.PAFC.UP.W.3097.240104T0200Z-240105T0200Z/"],
"eventEndingTime": ["2024-01-05T02:00:00+00:00"]
}
}
},
{
"id": "https://alert/cold_weather_advisory}",
"type": "Feature",
"geometry": null,
"properties": {
"@id": "https://alert/cold_weather_advisory}",
"@type": "wx:Alert",
"id": "cold_weather_advisory",
"areaDesc": "Over there. Over there. Send the word, to be heard, over there",
"geocode": {
"SAME": [],
"UGC": []
},
"affectedZones": ["https://every-alert/zone"],
"references": [],
"sent": "date:now -1 hour",
"effective": "date:now -1 hour",
"onset": "date:now -1 hour",
"expires": "date:now +1 hour",
"ends": "date:now +1 hour",
"status": "Actual",
"messageType": "Alert",
"category": "Met",
"severity": "Severe",
"certainty": "Likely",
"urgency": "Expected",
"event": "cold weather advisory",
"sender": "w-nws.webmaster@noaa.gov",
"senderName": "NWS Anchorage AK",
"headline": "Dummy alert",
"description": "Not real",
"instruction": null,
"response": "Avoid",
"parameters": {
"AWIPSidentifier": ["CWFALU"],
"WMOidentifier": ["FZAK52 PAFC 031605 AAA"],
"NWSheadline": [
"GALE WARNING THROUGH THURSDAY... ...HEAVY FREEZING SPRAY WARNING TONIGHT AND THURSDAY"
],
"BLOCKCHANNEL": ["EAS", "NWEM", "CMAS"],
"VTEC": ["/O.NEW.PAFC.UP.W.3097.240104T0200Z-240105T0200Z/"],
"eventEndingTime": ["2024-01-05T02:00:00+00:00"]
}
}
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ final class AlertFilterTest extends EndToEndBase
/**
* Test that alerts are sorted correctly.
* @group e2e
* @group eric
*/
public function testAlertSorting(): void
{
Expand Down Expand Up @@ -143,6 +144,8 @@ final class AlertFilterTest extends EndToEndBase
"snow squall warning",
"ice storm warning",
"winter storm warning",
"lake effect snow warning",
"dust storm warning",
"high wind warning",
"tropical storm warning",
"tsunami advisory",
Expand All @@ -151,63 +154,49 @@ final class AlertFilterTest extends EndToEndBase
"earthquake warning",
"volcano warning",
"ashfall warning",
"flood warning",
"coastal flood warning",
"lakeshore flood warning",
"flood warning",
"ashfall advisory",
"high surf warning",
"dust storm warning",
"lake effect snow warning",
"excessive heat warning",
"tornado watch",
"severe thunderstorm watch",
"flash flood watch",
"flood statement",
"wind chill warning",
"extreme cold warning",
"hard freeze warning",
"freeze warning",
"red flag warning",
"hurricane watch",
"typhoon watch",
"tropical storm watch",
"hurricane local statement",
"typhoon local statement",
"tropical storm local statement",
"tropical depression local statement",
"avalanche advisory",
"tropical cyclone local statement",
"winter weather advisory",
"wind chill advisory",
"avalanche advisory",
"cold weather advisory",
"heat advisory",
"urban and small stream flood advisory",
"small stream flood advisory",
"arroyo and small stream flood advisory",
"flood advisory",
"hydrologic advisory",
"lakeshore flood advisory",
"coastal flood advisory",
"lakeshore flood advisory",
"high surf advisory",
"dense fog advisory",
"dense smoke advisory",
"blowing dust advisory",
"lake wind advisory",
"wind advisory",
"frost advisory",
"ashfall advisory",
"freezing fog advisory",
"local area emergency",
"avalanche watch",
"blizzard watch",
"winter storm watch",
"rip current statement",
"beach hazards statement",
"winter storm watch",
"avalanche watch",
"flood watch",
"coastal flood watch",
"lakeshore flood watch",
"flood watch",
"high wind watch",
"excessive heat watch",
"extreme cold watch",
"wind chill watch",
"lake effect snow watch",
"freeze watch",
"fire weather watch",
"extreme fire danger",
Expand All @@ -222,7 +211,7 @@ final class AlertFilterTest extends EndToEndBase
"short term forecast",
"administrative message",
"test",
"child abduction emergency",
"child abduction emergency"
];

$this->onLocationRoute(37.805, -122.273);
Expand Down
4 changes: 4 additions & 0 deletions web/modules/weather_blocks/weather_blocks.module
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ function weather_blocks_template_preprocess_default_variables_alter(
"https://cdn.star.nesdis.noaa.gov/WFO/$wfo/GEOCOLOR/$goes-" .
strtoupper($wfo) .
"-GEOCOLOR-600x600.gif",
"mp4" =>
"https://cdn.star.nesdis.noaa.gov/WFO/$wfo/GEOCOLOR/$goes-" .
strtoupper($wfo) .
"-GEOCOLOR-600x600.mp4",
];
}
} catch (Throwable $e) {
Expand Down
Loading

0 comments on commit 796aeeb

Please sign in to comment.