BUILD_FORECAST_SCENARIO Hook Timing #1136
Replies: 5 comments 13 replies
-
What does this script look like and what environmental variables is it affecting? I suggest that hooks are not the place to override variables, especially ones that are not exported by the time Bash variables can't be updated by a child process in a way that persists them in the parent process. To persist environmental variables between child and parent, we either:
My suggestion is to use Thanks for asking, Josh! |
Beta Was this translation helpful? Give feedback.
-
This script doesn't change any existing environment variables, so we should be okay there! It just uses SCENARIODIR to determine where to put the tvw file it generates, which is why I'm so focused on that variable. The code does add a couple of lines to run.properties as well that are used in generate_tvwfile.sh, which I think Dave set up via a customization to asgs_main. I am totally on board the "let's not make customizations to core ASGS scripts unless absolutely necessary" train, so in the medium to long term it would probably be good to find a new solution for this. In the short term though I'm just trying to fix up what we have! I'm basically trying to figure out the best way of getting custom code to run after the forecast directory has been created (so the time_variable_weir.in file can be dropped there), but the forecast hasn't started yet (so the file is in place by the time it is needed). I was assuming the BUILD_FORECAST_SCENARIO hook would do that, especially because of lines 78 and 79 here: Line 78 in cd0b377 I would have assumed that mypath == $pwd == /work/.../forecast when the BUILD_FORECAST_SCENARIO code hooks in, but that doesn't seem to be how it works in practice. My forecast scenario is named "forecast" - I'm now realizing that it might have been confusing to just talk about the "forecast" directory! |
Beta Was this translation helpful? Give feedback.
-
I did a bit of testing with this and I found that the forecast job had already been submitted per the log file (and per my recollection while monitoring the test), but when you go to SCRATCHDIR/asgs######/status/hook.status.json it shows that ASGS is only on the NOWCAST_POLLING status:
|
Beta Was this translation helpful? Give feedback.
-
I am currently trying to resolve this by setting SCENARIODIR=$ADVISDIR/$ENSTORM when the BUILD_FORECAST_SCENARIO hook code is called instead of $PWD. It's possible pwd just isn't the SCENARIODIR when this hook activates, so provided the forecast folder exists at this time, this should solve the problem. If it turns out that the folder doesn't exist yet I'll have to figure out when it gets created and then somehow call the code after that. |
Beta Was this translation helpful? Give feedback.
-
My issue is resolved here, so I'm going to close. If you'd like to discuss more about the hooks and this would be a good place to do that, of course feel free to open it back up! |
Beta Was this translation helpful? Give feedback.
-
Hi All! Another question for you - Dave Ullman built a customization for ASGS that allows us to close the Providence Hurricane Barrier based on a date we add to the ASGS config file. It works using ASGS's hooks to call a script that generates a time_varying_weir.in file based on the configured barrier closure time. The config file looks like the following:
This seems to work as intended for the nowcast, but it definitely doesn't work for the forecast. generate_tvwfile.sh uses "$SCENARIODIR/time_varying_weir.in" as the name of the tvw file it generates. So, if SCENARIODIR is still the nowcast folder when the code runs via the hook, the time_varying_weir.in file will be created in the nowcast directory instead of the forecast directory. As a result the barrier does not close. The run still succeeds, but runs with the barrier open and closed also have identical output. I would have expected slight differences just due to the barrier having been closed during the nowcast piece, so it's possible that's broken too, but the results are identical.
Here's the relevant section from the log file (notice the BUILD_FORECAST_SCENARIO hook and the outfile in the nowcast directory):
My question is this: Is there another hook we should be using instead of BUILD_FORECAST_SCENARIO so that SCENARIODIR will be set as the forecast folder? Alternatively, is there another approach you would recommend (perhaps using the same hook, but changing "nowcast" to "forecast" in the SCENARIODIR whenever it runs via the BUILD_FORECAST_SCENARIO hook)? I'm pretty sure the code generates a valid tvw file based on the configuration (and if it doesn't I can sort that out). I'd just like advice on how to get the file to the right place at the right time.
I'm going to reach out to Dave in a moment to see if he ever found another solution for this, but I'd love to get your thoughts! Thanks.
Beta Was this translation helpful? Give feedback.
All reactions