Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 7befb39
Author: Brad <bradford.bates@noaa.gov>
Date:   Thu Jul 1 10:16:49 2021 -0500

    Allowance of evaluation at IFC sites and updating of bad eval sites list

    Updates to evaluation scripts to allow for Alpha testing at Iowa Flood Center (IFC) sites. Also, BAD_SITES variable updates to omit sites not suitable for evaluation from metric calculations.

    - The BAD_SITES list in tools_shared_variables.py was updated and reasons for site omission are documented.
    - Refactored run_test_case.py, synthesize_test_cases.py, tools_shared_variables.py, and eval_plots.py to allow for IFC comparisons.

    This resolves #424, resolves #412, and resolves #428.

commit ac4ae06
Author: Brian Avant <brian.avant@noaa.gov>
Date:   Mon Jun 21 07:46:35 2021 -0500

    Thalweg Profile Tool and lateral Thalweg Adjustment Threshold

    Adding a thalweg profile tool to identify significant drops in thalweg elevation. Also setting lateral thalweg adjustment threshold in hydroconditioning.

    - thalweg_drop_check.py checks the elevation along the thalweg for each stream path downstream of MS headwaters within a HUC.
    - Removing dissolveLinks arg from clip_vectors_to_wbd.py.
    - Cleaned up code in split_flows.py to make it more readable.
    - Refactored reduce_nhd_stream_density.py and adjust_headwater_streams.py to limit MS headwater points in agg_nhd_headwaters_adj.gpkg.
    - Fixed a bug in adjust_thalweg_lateral.py lateral elevation replacement threshold; changed threshold to 3 meters.
    - Updated aggregate_vector_inputs.py to log intermediate processes.

    This resolves #408, resolves #18, and resolves #409.

commit ca8cb7e
Author: Brad <bradford.bates@noaa.gov>
Date:   Thu Jun 10 10:54:32 2021 -0500

    Feature to evaluate alternative CatFIM technique performance

    Added eval_catfim_alt.py to evaluate performance of alternative CatFIM techniques.

    This resolves #414.

commit 129f2d5
Author: NickChadwick-NOAA <nick.chadwick@noaa.gov>
Date:   Wed Jun 9 10:38:19 2021 -0500

    Fim Run Memory Profiling

    To help analyze the memory consumption of the Fim Run process, the python module memory-profiler has been added to give insights into where peak memory usage is with in the codebase.

    In addition, the Dockerfile was previously broken due to the Taudem dependency removing the version that was previously being used by FIM. To fix this, and allow new docker images to be built, the Taudem version has been updated to the newest version on the Github repo and thus needs to be thoroughly tested to determine if this new version has affected the overall FIM outputs.

    Resolves #392 and #403

    Additions
    - Added memory-profiler to Pipfile and Pipfile.lock.
    - Added mprof (memory-profiler cli utility) call to the time_and_tee_run_by_unitsh to create overall memory usage graph location in the /logs/{HUC}_memory.png of the outputs directory.
    - Added @Profile decorator to all functions within scripts used in the run_by_unit.sh script to allow for memory usage tracking, which is then recorded in the /logs/{HUC}.log file of the outputs directory.

    Changes
    - Changed the Taudem version in Dockerfile.dev to 98137bb6541a0d0077a9c95becfed4e56d0aa0ac.
    - Changed all calls of python scripts in run_by_unit.sh to be called with the -m memory-profiler argument to allow scripts to also track memory usage.

commit a001d75
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Fri Jun 4 15:25:56 2021 -0500

    Correct headwater assignment nws_lid layer

    Bug fix to the generate_nws_lid.py script

    - Fixes incorrectly assigned attribute field "is_headwater" for some sites in the nws_lid.gpkg layer.
    - Updated agg_nhd_headwaters_adj.gpkg, agg_nhd_streams_adj.gpkg, nwm_flows.gpkg, and nwm_catchments.gpkg input layers using latest NWS LIDs.

    This resolves #383 and resolves #397.

commit cca68e1
Author: Brad <bradford.bates@noaa.gov>
Date:   Fri Jun 4 14:03:05 2021 -0500

    Update CHANGELOG.md

commit b9167d5
Author: RyanSpies-NOAA <ryan.spies@noaa.gov>
Date:   Fri Jun 4 14:00:06 2021 -0500

    BARC updates to cap xsec area and allow user to choose input bankfull geometry

    BARC updates to cap the bathy calculated xsec area in bathy_rc_adjust.py and allow user to choose input bankfull geometry.

    - Added new env variable to control which input file is used for the bankfull geometry input to bathy estimation workflow.
    - Modified the bathymetry cross section area calculation to cap the additional area value so that it cannot exceed the bankfull cross section area value for each stream segment (bankfull value obtained from regression equation dataset).
    - Modified the rating_curve_comparison.py plot output to always put the FIM rating curve on top of the USGS rating curve (avoids USGS points covering FIM).
    - Created a new aggregate csv file (aggregates for all hucs) for all of the usgs_elev_table.csv files (one per huc).
    - Evaluate the FIM Bathymetry Adjusted Rating Curve (BARC) tool performance using the estimated bankfull geometry dataset derived for the NWM route link dataset.

    This resolves #342, resolves #343, resolves #313, resolves #401, and resolves #402.

commit ac25186
Author: Brad <bradford.bates@noaa.gov>
Date:   Fri May 21 13:31:07 2021 -0500

    Alpha test bug fixes and improvements

    Enhancements and bug fixes to synthesize_test_cases.py.

    - Addresses a bug where AHPS sites without benchmark data were receiving a CSI of 0 in the master metrics CSV produced by synthesize_test_cases.py.
    - Includes a feature enhancement to synthesize_test_cases.py that allows for the inclusion of user-specified testing versions in the master metrics CSV.
    - Removes some of the print statements used by synthesize_test_cases.py.

    This resolves #354 and resolves #386.

commit f2d65ee
Author: Brad <bradford.bates@noaa.gov>
Date:   Tue May 18 13:34:26 2021 -0500

    Update CHANGELOG.md

commit 8fbf4b6
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Tue May 18 13:26:56 2021 -0500

    Bug fixes in preprocessing and run_test_case.py and update eval_plots

    Modifications and fixes to run_test_case.py, eval_plots.py, and AHPS preprocessing scripts.

    - Comment out return statement causing run_test_case.py to skip over sites/hucs when calculating contingency rasters.
    - Move bad sites list and query statement used to filter out bad sites to the tools_shared_variables.py.
    - Add print statements in eval_plots.py detailing the bad sites used and the query used to filter out bad sites.
    - Update AHPS preprocessing scripts to produce a domain shapefile.
    - Change output filenames produced in ahps preprocessing scripts.
    - Update workarounds for some sites in ahps preprocessing scripts.

    This resolves #381, resolves #369, resolves #326, resolves #385, resolves #377.

commit cbc360f
Author: NickChadwick-NOAA <nick.chadwick@noaa.gov>
Date:   Tue May 11 10:42:27 2021 -0500

    Updated Eventlet package to 0.31.0 to patch a vulnerability

    The current version of Eventlet used in the Connector module of the FIM API is outdated and vulnerable. This update bumps the version to the patched version.

    Using new nhd inputs.

commit b5da4b4
Author: NickChadwick-NOAA <nick.chadwick@noaa.gov>
Date:   Fri May 7 14:45:39 2021 -0500

    Added fuctionality for new "Release" feature in FIM API

    New "Release" feature added to the FIM API. This feature will allow for automated FIM, CatFIM, and relevant metrics to be generated when a new FIM Version is released. See #373 for more detailed steps that take place in this feature.

    Additions
    - Added new window to the UI in api/frontend/gui/templates/index.html.
    - Added new job type to api/node/connector/connector.py to allow these release jobs to run.
    - Added additional logic in api/node/updater/updater.py to run the new eval and CatFIM scripts used in the release feature.

    Changes
    - Updated api/frontend/output_handler/output_handler.py to allow for copying more broad ranges of file paths instead of only the /data/outputs directory.

    Resolves Issues #264 #278 #307 and #373

commit 22ba0df
Author: Brian Avant <brian.avant@noaa.gov>
Date:   Fri May 7 12:51:19 2021 -0500

    Remove Great Lakes from wbd buffer

    - The gl_water_polygons.gpkg layer is used to mask out Great Lakes boundaries and remove NHDPlus HR coastline segments. These segments are causing issues later in run_by_unit.sh and unnecessarily increasing total processing time.

    Resolves issue #374

commit 25c3ec1
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Mon May 3 10:07:19 2021 -0500

    Generate nws_lid.gpkg

    Generate nws_lid.gpkg.

    - Generate nws_lid.gpkg with attributes indicating if site is a headwater nws_lid as well as if it is co-located with another nws_lid which is referenced to the same nwm_feature_id segment.

    This resolves #368.

commit 9518cbe
Author: Brian Avant <brian.avant@noaa.gov>
Date:   Fri Apr 30 15:41:29 2021 -0500

    Refactor NHDPlus HR preprocessing workflow

    Refactor NHDPlus HR preprocessing workflow.

    - Consolidate NHD streams, NWM catchments, and headwaters MS and FR layers with mainstem column.
    - HUC8 intersections are included in the input headwaters layer.
    - clip_vectors_to_wbd.py removes incoming stream segment from the selected layers.

    This resolves #238.

commit 199ab6e
Author: Brian Avant <brian.avant@noaa.gov>
Date:   Wed Apr 28 11:32:11 2021 -0500

    Refactor synthesize_test_case.py to handle exceptions during multiprocessing

    Refactor synthesize_test_case.py to handle exceptions during multiprocessing. Resolves issue #351

    Changes
     - refactored inundation.py and run_test_case.py to handle exceptions without using sys.exit(). This isn't the ideal way to handle exceptions when using multiprocessing because the child process is expecting a return.

commit 99c197b
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Tue Apr 27 12:42:59 2021 -0500

    Implement CatFIM threshold flows to Sierra test and add AHPS benchmark preprocessing scripts.

    Implement CatFIM threshold flows to Sierra test and add AHPS benchmark preprocessing scripts.

    - Produce CatFIM flows file when running rating_curve_get_usgs_gages.py.
    - Several scripts to preprocess AHPS benchmark data. Requires numerous file dependencies not available through Cahaba.
    - Modify rating_curve_comparison.py to ingest CatFIM threshold flows in calculations.
    - Modify eval_plots.py to save all site specific bar plots in same parent directory instead of in subdirectories.
    - Add variables to env.template for AHPS benchmark preprocessing.

    This resolves #341, resolves #361, and resolves #357.

commit c311317
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Thu Apr 22 15:32:10 2021 -0500

    Update plotting script to not error out if FR or MS are not analyzed when using spatial argument

    update eval_plots.py to correctly produce spatial datasets if version is not analyzed. For example, if no FR versions are analyzed, instead of throwing an error, it will check to make sure there exists a FR analyzed datasets, if one exists then create spatial data for FR datasets (ble).

commit 6387384
Author: Brian Avant <brian.avant@noaa.gov>
Date:   Tue Apr 20 09:54:37 2021 -0500

    Closing multiprocessing pool objects

    Updating repo to close all multiprocessing Pool objects to fix memory issues

commit a304cf3
Author: Brian Avant <brian.avant@noaa.gov>
Date:   Mon Apr 19 12:14:47 2021 -0500

    Preprocess NHDPlus HR rasters for consistent projections, nodata values, and convert from cm to meters.

    Preprocess NHDPlus HR rasters for consistent projections, nodata values, and convert from cm to meters.

    - preprocess_rasters.py reprojects raster, converts to meters, and updates nodata value to -9999.
    - Cleaned up log messages from bathy_rc_adjust.py and usgs_gage_crosswalk.py.
    - Outputs paths updated in generate_categorical_fim_mapping.py and generate_categorical_fim.py.
    - update_raster_profile cleans up raster crs, blocksize, nodata values, and converts elevation grids from cm to meters.
    - reproject_dem.py imports gdal to reproject elevation rasters because an error was occurring when using rasterio.
    - burn_in_levees.py replaces the gdal_calc.py command to resolve inconsistent outputs with burned in levee values.

    This resolves #300.

commit 1a15cd8
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Fri Apr 16 14:09:21 2021 -0500

    Fixes production list in output_cleanup.py.

    Fixes production list in output_cleanup.py.

commit 5a8ebcd
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Wed Apr 14 08:47:58 2021 -0500

    Add mainstems attribute for sierra test

    Sierra test considered all USGS gage locations to be mainstems even though many actually occurred with tributaries. This resulted in unrealistic comparisons as incorrect gages were assigned to mainstems segments. This feature branch identifies gages that are on mainstems via attribute field.

    - Modifies usgs_gage_crosswalk.py to filter out gages from the usgs_gages.gpkg layer such that for a "MS" run, only consider gages that contain rating curve information (via curve attribute) and are also mainstems gages (via mainstems attribute).
    - Modifies usgs_gage_crosswalk.py to filter out gages from the usgs_gages.gpkg layer such that for a "FR" run, only consider gages that contain rating curve information (via curve attribute) and are not mainstems gages (via mainstems attribute).
    - Modifies how mainstems segments are determined by using the nwm_flows_ms.gpkg as a lookup to determine if the NWM segment specified by WRDS for a gage site is a mainstems gage.
    - Adds a mainstem attribute field to usgs_gages.gpkg that indicates whether a gage is located on a mainstems river.
    - Adds NWM_FLOWS_MS variable to the .env and .env.template files.
    - Adds the extent argument specified by user when running fim_run.sh to usgs_gage_crosswalk.py.

commit c9161b8
Author: RyanSpies-NOAA <ryan.spies@noaa.gov>
Date:   Thu Apr 8 11:11:56 2021 -0500

    Implementing a prototype technique to estimate the missing bathymetric component in the HAND-derived synthetic rating curves.

    Implementing a prototype technique to estimate the missing bathymetric component in the HAND-derived synthetic rating curves. The new Bathymetric Adjusted Rating Curve (BARC) function is built within the fim_run.sh workflow and will ingest bankfull geometry estimates provided by the user to modify the cross section area used in the synthetic rating curve generation.

    - add_crosswalk.py outputs the stream order variables to src_full_crosswalked.csv and calls the new bathy_rc_adjust.py if bathy env variable set to True and extent=MS.
    - run_by_unit.sh includes a new csv outputs for reviewing BARC calculations.
    - params_template.env & params_calibrated.env contain new BARC function input variables and on/off toggle variable.
    eval_plots.py now includes additional AHPS eval sites in the list of "bad_sites" (flagged issues with MS flowlines).
    - Adds bathy_rc_adjust.py
        - Imports the existing synthetic rating curve table and the bankfull geometry input data (topwidth and cross section area per COMID).
        - Performs new synthetic rating curve calculations with bathymetry estimation modifications.
        - Flags issues with the thalweg-notch artifact.

    This resolves #306, resolves #328, resolves #309, resolves #311, and resolves #330.

commit 40631f4
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Mon Apr 5 13:45:09 2021 -0500

    Create tool to retrieve rating curves from USGS sites and convert to elevation (NAVD88). Intended to be used as part of the Sierra Test.

    - Modify usgs_gage_crosswalk.py to:
        - Look for location_id instead of site_no attribute field in usgs_gages.gpkg file.
        - Filter out gages that do not have rating curves included in the usgs_rating_curves.csv
    - Modify rating_curve_comparison.py to perform a check on the age of the user specified usgs_rating_curves.csv and alert user to the age of the file and recommend updating if file is older the 30 days.
    - Add rating_curve_get_usgs_curves.py. This script will generate the following files:
        - usgs_rating_curves.csv: A csv file that contains rating curves (including converted to NAVD88 elevation) for USGS gages in a format that is compatible with rating_curve_comparisons.py. As it is is currently configured, only gages within CONUS will have rating curve data.
        - log.csv: A log file that records status for each gage and includes error messages.
        - usgs_gages.gpkg: A geospatial layer (in FIM projection) of all active USGS gages that meet a predefined criteria. Additionally, the curve attribute indicates whether a rating curve is found in the usgs_rating_curves.csv. This spatial file is only generated if the all option is passed with the -l argument.

    This resolves #289.

commit 44b6333
Author: brian.avant <brian.avant@noaa.gov>
Date:   Thu Apr 1 13:40:49 2021 -0500

    [1pt] Tool to compare synthetic rating curve with benchmark rating curve (sierra test) (#332)

    * `usgs_gage_crosswalk.py`: generates `usgs_elev_table.csv` in run_by_unit.py with elevation at USGS gages
    * `rating_curve_comparison.py`: post-processing script to plot and calculate metrics between FIM and USGS rating curve data
    * updates `aggregate_fim_outputs.py` call argument in `fim_run.sh` from 4 jobs to 6 jobs (optimizing API performance)
    * reroutes median elevation data from `add_crosswalk.py` and `rem.py` to new file (depreciating `hand_ref_elev_table.csv`)
    *- adds new files to `viz_whitelist` in `output_cleanup.py`

commit 4df6d1d
Author: Brad <bradford.bates@noaa.gov>
Date:   Thu Apr 1 12:27:10 2021 -0500

    Update CHANGELOG.md

commit 385ae0f
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Thu Apr 1 12:24:05 2021 -0500

    Update spatial option when performing eval plots

    Removes file dependencies from spatial option. Does require the WBD layer which should be specified in .env file.

    - Produces outputs in a format consistent with requirements needed for publishing.
    - Preserves leading zeros in huc information for all outputs from eval_plots.py.
    - Creates fim_performance_points.shp: this layer consists of all evaluated ahps points (with metrics). Spatial data retrieved from WRDS on the fly.
    - Creates fim_performance_polys.shp: this layer consists of all evaluated huc8s (with metrics). Spatial data retrieved from WBD layer.

    This resolves #325.

commit 391b547
Author: Brad <bradford.bates@noaa.gov>
Date:   Wed Mar 31 10:00:34 2021 -0500

    Update README.md

commit a60e6ee
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Tue Mar 30 16:17:02 2021 -0500

    Adds detail and more information to plotting capabilities

    Add detail/information to plotting capabilities.

    - Merge plot_functions.py into eval_plots.py and move eval_plots.py into the tools directory.
    - Remove plots subdirectory.
    - Optional argument to create barplots of CSI for each individual site.
    - Create a csv containing the data used to create the scatterplots.

    This resolves #325.

commit 2b26065
Author: Brad <bradford.bates@noaa.gov>
Date:   Thu Mar 25 09:08:06 2021 -0500

    Update CHANGELOG.md

commit 34123dd
Author: TrevorGrout-NOAA <69653333+TrevorGrout-NOAA@users.noreply.github.com>
Date:   Thu Mar 25 08:51:04 2021 -0500

    Improvements to CatFIM service source data generation

    Improvements to CatFIM service source data generation.

    - Renamed generate_categorical_fim.py to generate_categorical_fim_mapping.py.
    - Updated the status outputs of the nws_lid_sites layer and saved it in the same directory as the merged catfim_library layer.
    - Additional stability fixes (such as improved compatability with WRDS updates).
    - Added generate_categorical_fim.py to wrap generate_categorical_fim_flows.py and generate_categorical_fim_mapping.py.
    - Create new nws_lid_sites shapefile located in same directory as the catfim_library shapefile.

    This resolves #305, resolves #321, and resolves #322.

commit d43bd8b
Author: Brad <bradford.bates@noaa.gov>
Date:   Wed Mar 24 10:21:04 2021 -0500

    Patch to synthesize_test_cases.py

    Bug fix to synthesize_test_cases.py to allow comparison between testing version and official versions.
  • Loading branch information
fernando-aristizabal committed Jul 7, 2021
1 parent 13e32cb commit 2e13a30
Show file tree
Hide file tree
Showing 55 changed files with 4,522 additions and 2,213 deletions.
230 changes: 218 additions & 12 deletions CHANGELOG.md

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ grass-session = "==0.5"
seaborn = "==0.11.0"
python-dotenv = "*"
natsort = "*"
memory-profiler = "*"

[requires]
python_version = "3.8"
373 changes: 206 additions & 167 deletions Pipfile.lock

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ The following input data sources should be downloaded and preprocessed prior to

### NHDPlus HR datasets
- `acquire_and_preprocess_inputs.py`
- `preprocess_rasters.py`
- `aggregate_nhd_hr_streams.py`

**Please note:** For the following two datasets, please contact Mark Glaudemans (mark.glaudemans@noaa.gov). We are currently working on a long-term data sharing solution for the in-house NOAA data.
Expand Down Expand Up @@ -68,11 +69,11 @@ docker run --rm -it -v <path/to/data>:/data -v <path/to/repository>:/foss_fim <i
- Please run `/foss_fim/src/acquire_and_preprocess_inputs.py --help` for more information.
- See United States Geological Survey (USGS) National Hydrography Dataset Plus High Resolution (NHDPlusHR) [site](https://www.usgs.gov/core-science-systems/ngp/national-hydrography/nhdplus-high-resolution) for more information

### Aggregate NHDHR Streams and Create NWM Headwater Points
### Aggregate NHDHR Streams and Create NWM Headwater Points
```
/foss_fim/src/aggregate_vector_inputs.py
```
### Produce Hydrofabric
### Produce Hydrofabric
```
fim_run.sh -u <huc4,6,or8s> -c /foss_fim/config/<your_params_file.env> -n <name_your_run>
```
Expand Down
158 changes: 124 additions & 34 deletions api/frontend/gui/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@

color: black;
background-color: white;
font-size: 0.9rem;

transition: all 0.1s linear;

Expand Down Expand Up @@ -137,6 +138,27 @@
background-color: #093568;
}

#release-button {
display: flex;
width: 100%;
height: 100%;

align-items: center;
justify-content: center;

font-size: 1.2rem;
color: white;
background-color: #28be99;
cursor: pointer;

transition: all 0.5s linear;
pointer-events: inherit;
}

#release-button:hover, #release-button.active {
background-color: #09685b;
}

.form-field {
display: flex;
width: 0;
Expand Down Expand Up @@ -224,15 +246,40 @@
<!-- <h1>FIM Run API</h1> -->
<div id="request-container">
<div id="request-tabs-container">
<div class="request-tab" onclick="selectForm(event, 'release')">Release</div>
<div class="request-tab active" onclick="selectForm(event, 'fim-run')">FIM Run</div>
<div class="request-tab" onclick="selectForm(event, 'calibration')">Calibration</div>
<div class="request-tab" onclick="selectForm(event, 'preprocessing')">Pre-processing</div>
</div>
<div id="release" class="request-form" style="display: None;">
<div class="form-content">
<h3 style="margin: 0;">FIM Version</h3>
<div class="container-horizontal" style="width: 10rem;">
<span>FIM_3_</span>
<input type="text" id="release-job-version-major" class="form-field" placeholder="0"></input>
<span>_</span>
<input type="text" id="release-job-version-minor" class="form-field" placeholder="0"></input>
<span>_</span>
<input type="text" id="release-job-version-patch" class="form-field" placeholder="0"></input>
</div>
<h3 style="margin: 0;">Previous Major FIM Version</h3>
<div class="container-horizontal" style="width: 10rem;">
<span>FIM_3_</span>
<input type="text" id="prev-release-job-version-major" class="form-field" placeholder="0"></input>
<span>_</span>
<input type="text" id="prev-release-job-version-minor" class="form-field" placeholder="0"></input>
<span>_</span>
<input type="text" id="prev-release-job-version-patch" class="form-field" placeholder="0"></input>
</div>
<div class="error-list" id="release-errors"></div>
</div>
<div class="start-button not-connected" onclick="submitRequest('release')">Not Connected</div>
</div>
<div id="fim-run" class="request-form">
<div class="form-content">
<h3 style="margin: 0;">Basic</h3>
<div class="container-horizontal">
<input type="text" id="job-name" class="form-field" placeholder="Job Name"></input>
<input type="text" id="fim-run-job-name" class="form-field" placeholder="Job Name"></input>
<select id="presets-list" class="form-field" onchange="presetListSelected(event)"></select>
<input type="text" id="hucs" class="form-field" placeholder="HUC(s)" style="display: none;"></input>
<input type="text" id="git-branch" class="form-field" placeholder="Git Branch"></input>
Expand Down Expand Up @@ -271,7 +318,7 @@ <h3 style="margin: 0;">Extent</h3>

</div>
</div>
<div class="start-button not-connected" onclick="submitRequest('fim-run')">Not Connected</div>
<div class="start-button not-connected" onclick="submitRequest('fim_run')">Not Connected</div>
</div>
<div id="calibration" class="request-form" style="display: None;">
Calibration stuff goes here
Expand Down Expand Up @@ -370,7 +417,7 @@ <h3 style="margin: 0;">Extent</h3>
socket.on('job_added', job_type => {
document.querySelector('#request-container').classList.remove('loading')
if (job_type === 'fim_run') {
document.querySelector('#job-name').value = ''
document.querySelector('#fim-run-job-name').value = ''
document.querySelector('#hucs').value = ''
document.querySelector('#git-branch').value = ''
document.querySelector("input[name='dev-run']").checked = false
Expand All @@ -380,46 +427,89 @@ <h3 style="margin: 0;">Extent</h3>
document.querySelector("input[name='extent'][value='FR']").checked = true
document.querySelector("input[name='extent'][value='MS']").checked = false
document.querySelector('#fim-run-errors').innerHTML = ''
} else if (job_type === 'release') {
console.log('release job has been added')
document.querySelector('#release-job-version-major').value = ''
document.querySelector('#release-job-version-minor').value = ''
document.querySelector('#release-job-version-patch').value = ''
document.querySelector('#prev-release-job-version-major').value = ''
document.querySelector('#prev-release-job-version-minor').value = ''
document.querySelector('#prev-release-job-version-patch').value = ''
document.querySelector('#release-errors').innerHTML = ''
}
})
socket.on('job_canceled', () => {
console.log("Job has been cancelled")
})
})

// Fim_run related code
const submitRequest = requestName => {
let validation_errors = []
const job_name = document.querySelector('#job-name').value
const preset = document.querySelector('#presets-list').value
const hucs = document.querySelector('#hucs').value
const git_branch = document.querySelector('#git-branch').value
const dev_run = document.querySelector("input[name='dev-run']").checked
const viz_run = document.querySelector("input[name='viz-run']").checked
const configuration = Array.from(document.querySelectorAll("input[name='configuration']")).filter(c => c.checked)[0].value
const extents = Array.from(document.querySelectorAll("input[name='extent']")).filter(c => c.checked).map(c => c.value)

if (job_name === '') validation_errors.push('Job Name Cannot Be Empty')
if (preset === 'custom' && hucs === '') validation_errors.push('Huc(s) Cannot Be Empty')
if (git_branch === '') validation_errors.push('Git Branch Cannot Be Empty')

if (validation_errors.length > 0){
document.querySelector('#fim-run-errors').innerHTML = validation_errors.map(e => `<span>${e}</span>`).join('')
return
}
if (requestName === 'fim_run'){
// Fim_run related code
let validation_errors = []
const job_name = document.querySelector('#fim-run-job-name').value
const preset = document.querySelector('#presets-list').value
const hucs = document.querySelector('#hucs').value
const git_branch = document.querySelector('#git-branch').value
const dev_run = document.querySelector("input[name='dev-run']").checked
const viz_run = document.querySelector("input[name='viz-run']").checked
const configuration = Array.from(document.querySelectorAll("input[name='configuration']")).filter(c => c.checked)[0].value
const extents = Array.from(document.querySelectorAll("input[name='extent']")).filter(c => c.checked).map(c => c.value)

if (job_name === '') validation_errors.push('Job Name Cannot Be Empty')
if (preset === 'custom' && hucs === '') validation_errors.push('Huc(s) Cannot Be Empty')
if (git_branch === '') validation_errors.push('Git Branch Cannot Be Empty')

if (validation_errors.length > 0){
document.querySelector('#fim-run-errors').innerHTML = validation_errors.map(e => `<span>${e}</span>`).join('')
return
}

document.querySelector('#request-container').classList.add('loading')

socket.emit('new_job', {
job_name,
preset,
hucs,
git_branch,
dev_run,
viz_run,
configuration,
extents
})
document.querySelector('#request-container').classList.add('loading')

socket.emit('new_job', {
job_type: 'fim_run',
job_name,
preset,
hucs,
git_branch,
dev_run,
viz_run,
configuration,
extents
})
} else if (requestName === 'release'){
// Release related code
let validation_errors = []
const job_version_major = document.querySelector('#release-job-version-major').value
const job_version_minor = document.querySelector('#release-job-version-minor').value
const job_version_patch = document.querySelector('#release-job-version-patch').value
const prev_job_version_major = document.querySelector('#prev-release-job-version-major').value
const prev_job_version_minor = document.querySelector('#prev-release-job-version-minor').value
const prev_job_version_patch = document.querySelector('#prev-release-job-version-patch').value

if (job_version_major === '' || job_version_minor === '' || job_version_patch === '')
validation_errors.push('Fim Version must be completely filled out')
if (prev_job_version_major === '' || prev_job_version_minor === '' || prev_job_version_patch === '')
validation_errors.push('Previous Major Fim Version must be completely filled out')

if (validation_errors.length > 0){
document.querySelector('#release-errors').innerHTML = validation_errors.map(e => `<span>${e}</span>`).join('')
return
}

document.querySelector('#request-container').classList.add('loading')

socket.emit('new_job', {
job_type: 'release',
job_version_major,
job_version_minor,
job_version_patch,
prev_job_version_major,
prev_job_version_minor,
prev_job_version_patch
})
}
}

const disableDevRun = e => {
Expand Down
6 changes: 2 additions & 4 deletions api/frontend/output_handler/output_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
SOCKET_URL = os.environ.get('SOCKET_URL')

def handle_outputs(data):
nice_name = data['nice_name']
job_name = data['job_name']
directory_path = data['directory_path']
file_name = data['file_name']
Expand All @@ -18,16 +17,15 @@ def handle_outputs(data):
if chunk_index == 0:
mode = 'wb'
try:
os.makedirs(f"/data/outputs/{nice_name}/{directory_path}")
os.makedirs(directory_path)
except:
pass

# Write binary data to file
with open(f"/data/outputs/{nice_name}/{directory_path}/{file_name}", mode) as binary_file:
with open(f"{directory_path}/{file_name}", mode) as binary_file:
print(f"Writing chunk {chunk_index} for file {directory_path}/{file_name}")
binary_file.write(file_chunk)

# TODO: Write an emit that will trigger the next chunk to be sent.
sio.emit('output_handler_finished_file_chunk', {'job_name': job_name, 'file_path': f"{directory_path}/{file_name}"})

sio = socketio.Client()
Expand Down
Loading

0 comments on commit 2e13a30

Please sign in to comment.