Skip to content

Commit

Permalink
V0.5.0 (#539)
Browse files Browse the repository at this point in the history
* enable dropping of bcfishpass schema for upgrades

* add renamed job and upgrade job

* move csv load to /jobs

* load data files in first workflow job so all subsequet jobs have latest

* fix job name

* load param and data csvs in same job

* fix #302

* remove unneeded observations table, use observations mvw, presume observations are refreshed by jobs, add upstr salmon/steelhead observation counts to dams view

* fix #487

* add missing file

* simplify modelled crossing data flow/scripts

* load modelled crossings from temp table on completion

* note when to load existing modelled crossings

* call pscis from prep job, remove pscis and gradient barriers from access makefile

* update job names

* add missing job

* remove observation refresh from weekly load job so things function on initial setup

* add wcrp table

* use wcrp table for wcrp views, add test db build script, fix view creation order, further slim access model makefile

* fix #493, fix #492

* add moved file

* note how to upgrade

* update missed file with wcrp table

* another missed wcrp query

* fix #479

* add optional cross-db model output comparison view

* separate join from where

* prelim fix #480

* use target spp in wcrp crossings summary, more fix #480

* shuffle/add job files to accomodate test script/db

* remove old file, ignore dump files

* fix #495

* add mechanism to force matching of cabd waterfalls to correct blkey

* allow for force matching dams to blkey as well

* add cabd-blkey xref file

* update version

* note updated waterfall source, tidy source list

* remove changes file, see gh issues and milestones

* rename wcrp table to wcrp_watersheds, add draft tracking tables

* fix types, column names

* remove temp desc

* add draft barrier auto rank query/report

* Auto rank integration

- Created output table in db\bcfishpass\tables\wcrp.sql
- Created 1 script per watershed to populate the output table

* hold only rank info in rank table, add rank info to wcrp crossings view

* Created auto_rank.py

- Removed all individual watershed sql files
- Replaced with 1 python script which runs the ranking and populates the output table with the ranked barriers for the specified wcrp

* Update auto_rank.py

Species variable for _wct columns in ELKR wcrp and _ch_cm_co_pk_sk columns in other wcrps

* use database_url for connection

* auto format with black

* Auto rank integration (#517)

* Auto rank integration

- Created output table in db\bcfishpass\tables\wcrp.sql
- Created 1 script per watershed to populate the output table

* hold only rank info in rank table, add rank info to wcrp crossings view

* Created auto_rank.py

- Removed all individual watershed sql files
- Replaced with 1 python script which runs the ranking and populates the output table with the ranked barriers for the specified wcrp

* Update auto_rank.py

Species variable for _wct columns in ELKR wcrp and _ch_cm_co_pk_sk columns in other wcrps

* use database_url for connection

* auto format with black

---------

Co-authored-by: Simon Norris <[email protected]>

* Update connection in auto_rank.py

Modified to parse the DATABASE_URL environment variable to get connection info for psycopg2 connection formatting.

* structure files to enable migrations going forward, use cached DRA

* note how to dump a db with date/version tags

* adjust db folder name as v0.5.0 has not yet been tagged

* fix missed merge conflict

* prevent collisions by removing redundant inserts

* Update api functions (#523)

* Update to wcrp_habitat_connectivity_status_vw

View now includes unique case for upstream and downstream of Elko Dam

* Update barrier severity calculation

- [# of assessed structures where barrier_status IN (BARRIER, POTENTIAL) + ((failure rate)*(# of unassessed structures))/(total # of structures)]

- Failure rate = # of assessed structures that are barrier or potential/ total # of assessed structures

E.g.,:
44 assessed crossings (23 are potential or barriers) = failure rate of 52%
193 unassessed crossings
237 total crossings
Severity = (23 + 0.52(193))/237 = 123.36/237 -> (round to nearest “barrier”) ->123/237 = 51.9%

* Changes to wcrp_barrier_count

Update so that only barriers on accessible streams and habitat for target species are included for each watershed.

Fourth entry option 'OVERVIEW' for the model_status parameter, which would call and return results for all three of the other options combined (i.e., would return counts of barriers for ALL, ACCESSIBLE, and HABITAT in the same return)

* fix #518 (#524)

* Issue527 (#528)

* move wcrp crossings view def to separate file, prune fields that are included in the view, add fptwg prefix to their view

* further consolidate wcrp relations, calculate wcrp upstream habitat for all crossings (not just barriers)

* update wcrp crossings view to report on upstream barriers having spawn/rear habitat for wcrp target spp upstream, fixes #527

* add basic qa views of barriers with observations upstr, plus prelim draft detailed report of observations with barriers downstream

* note concern in crossings load

* remove all user falls other than Bonnington (historic), falls are covered by CABD

* restore header

* remove data from cabd dam exclusions file

* restore empty file for now

* move wcrp auto rank report to /jobs and clean git conflict

* bump db folder tag

* move barrier/observation qa report to reports

* replace postgisftw functions for easier upgrade

* remove upgrade script

---------

Co-authored-by: andrewp-CWF <[email protected]>
Co-authored-by: andrewp-CWF <[email protected]>
  • Loading branch information
3 people authored Jul 9, 2024
1 parent eaa2b7e commit f6c26ec
Show file tree
Hide file tree
Showing 135 changed files with 2,927 additions and 3,187 deletions.
16 changes: 7 additions & 9 deletions .github/workflows/production-bcfishpass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,27 @@ env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
jobs:
load-parameters:
load-csv:
runs-on: ubuntu-latest
environment: production
container: ghcr.io/smnorris/bcfishpass:main
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Run the jobs
- name: Load csv data, parameters
run: |
cp parameters/example_newgraph/*csv parameters/
make --debug=basic .make/parameters
jobs/load_csv
build-xings:
runs-on: ubuntu-latest
environment: production
container: ghcr.io/smnorris/bcfishpass:main
needs: load-parameters
needs: load-csv
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Build modelled crossings
run: jobs/bcfishpass01_modelled_stream_crossings
- name: Release modelled crossings
run: jobs/release_modelled_stream_crossings
run: jobs/model_stream_crossings
prep:
runs-on: ubuntu-latest
environment: production
Expand All @@ -42,7 +40,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v4
- name: Run the jobs
run: jobs/bcfishpass02_prep
run: jobs/model_prep
model:
runs-on: ubuntu-latest
environment: production
Expand All @@ -57,7 +55,7 @@ jobs:
- name: Run the jobs
run: |
git config --global --add safe.directory /__w/bcfishpass/bcfishpass
jobs/bcfishpass03_model
jobs/model_run
release:
runs-on: ubuntu-latest
environment: production
Expand Down
12 changes: 5 additions & 7 deletions .github/workflows/testing-bcfishpass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ on:
env:
DATABASE_URL: ${{ secrets.DATABASE_URL }}
jobs:
load-parameters:
load-csv:
runs-on: ubuntu-latest
environment: testing
container: ghcr.io/smnorris/bcfishpass:main
Expand All @@ -18,7 +18,7 @@ jobs:
- name: Run the jobs
run: |
cp parameters/example_newgraph/*csv parameters/
make --debug=basic .make/parameters
jobs/load_csv
load-xings:
runs-on: ubuntu-latest
environment: testing
Expand All @@ -28,9 +28,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v4
- name: Run the jobs
run: |
cd model/01_access/modelled_stream_crossings
make .make/download_archive
run: jobs/load_modelled_stream_crossings
prep:
runs-on: ubuntu-latest
environment: testing
Expand All @@ -40,7 +38,7 @@ jobs:
- name: Check out repository code
uses: actions/checkout@v4
- name: Run the jobs
run: jobs/bcfishpass02_prep
run: jobs/model_prep
model:
runs-on: ubuntu-latest
environment: testing
Expand All @@ -55,4 +53,4 @@ jobs:
- name: Run the jobs
run: |
git config --global --add safe.directory /__w/bcfishpass/bcfishpass
jobs/bcfishpass03_model
jobs/model_run
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ model/01_access/qa/*csv

# only include example parameters,
# not whatever is being used for a given project/test
parameters/parameters_habitat*.csv
parameters/parameters_habitat*.csv

# postgres dump files
*.dump
23 changes: 0 additions & 23 deletions CHANGES.txt

This file was deleted.

88 changes: 0 additions & 88 deletions Makefile

This file was deleted.

50 changes: 27 additions & 23 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ See the [Documentation](https://smnorris.github.io/bcfishpass/) for details.
- [fwapg](https://github.com/smnorris/fwapg)
- [bcfishobs](https://github.com/smnorris/bcfishobs)

## Setup
## Setup / Usage

`bcfishpass` is a collection of shell/sql/Python scripts. To download and use the latest:

Expand All @@ -47,37 +47,41 @@ All scripts presume that the `DATABASE_URL` environment variable points to your

export DATABASE_URL=postgresql://postgres@localhost:5432/bcfishpass

Set up the database schema:

jobs/setup

Load FWA data:
Load FWA:

git clone https://github.com/smnorris/fwapg
cd fwapg
mkdir -p .make; touch .make/db # just reload data
mkdir -p data
make --debug=basicjobs/load_fwa
make --debug=basic

Load/run `bcfishobs`:

git clone [email protected]:smnorris/bcfishobs.git
cd bcfishobs
make --debug=basic

Load all additional data:
Create db schema:

jobs/load_static
jobs/db_setup

Load source data:

jobs/load_static
jobs/load_monthly
jobs/load_weekly

Run `bcfishobs`:
Load cached bcfishpass data:

git clone [email protected]:smnorris/bcfishobs.git
cd bcfishobs
mkdir -p .make
make -t .make/setup
make -t .make/load_static
make -t .make/fiss_fish_obsrvtn_pnt_sp
make --debug=basic
jobs/load_gradient_barriers
jobs/load_modelled_stream_crossings

Run the model:

jobs/model_prep
jobs/model_run

Finally, navigate back to the root bcfishpass folder and build `bcfishpass`:
# Backups

make
Backup strategies will vary but it can be useful to dump the entire database to file.
This appends the date and commit tag date to the file name:

Note that it is possible (and often preferred) to build components of the modelling separately.
Refer to the various README files in the subfolders within the `model` folder for more info.
pg_dump -Fc $DATABASE_URL > bcfishpass.$(git describe --tags --abbrev=0).$(date +%F).dump
7 changes: 7 additions & 0 deletions data/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ Currently, controls the barrier status of natural barriers (gradient, falls, sub
NOTE - this table will only be used to identify modelled barriers known to be passable
(gradient, subsurface flow) once bcfishpass incorporates CABD falls


## user_cabd_dams_exclusions.csv

List of CABD dams to exclude from analysis (generally due to incorrect location or incorrect passability status).
To be used as temporary fix only - submit any location or passability status to CWF [here](https://forms.office.com/Pages/ResponsePage.aspx?id=A8N2i-wB1UCNmmwvbXjc15ERVmcC4dFPn5j4q5-aulRURE1TSjBJNEtDNlY0WTlXVFY5MkFOMzRVUS4u)


## user_falls.csv

Falls not present in FWA/FISS. Both barriers and non-barriers may be included.
Expand All @@ -62,6 +64,11 @@ Update the barrier status of PSCIS crossings (for bcfishpass modelling only). PS
support planning by adding barrier status of a crossing before a submission is made.


## wcrp.csv

A list of watershed groups and target species for CWF WCRP reporting.


## wsg_species_presence.csv

A list of all BC watershed groups and presence/absence of target species (Coho, Chinook, Sockeye, Steelhead, West Slope Cutthroat Trout).
Expand Down
7 changes: 0 additions & 7 deletions data/load.sh

This file was deleted.

3 changes: 3 additions & 0 deletions data/user_cabd_blkey_xref.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
cabd_id,blue_line_key,reviewer_name,review_date,notes
30115bb6-9a75-4c33-bb37-4243ce33e43d,356352213,SN,2024-05-28,matched to stream named in CABD
c3721358-4334-41c0-a4c1-1fa729803d47,354154385,SN,2024-05-28,matched to stream named in CABD (but it is unclear where cascade is actually located)
9 changes: 1 addition & 8 deletions data/user_cabd_dams_exclusions.csv
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
cabd_id,reviewer_name,review_date,source,notes
30b88f1b-dc21-4b42-8daa-d4cebae24142,SN,2023-01-01,not noted,
3ca692b8-37cf-44e8-a783-2a315ec83102,SN,2023-01-01,not noted,
ba5fe3eb-7bbe-45c1-b301-555872387c16,SN,2023-01-01,not noted,
8a6b10fa-0d4f-4c45-857c-764d7e8028f8,SN,2023-01-01,not noted,
48478e95-e063-4df6-a047-6aaf6087011b,SN,2023-01-01,not noted,
e8e4bd88-c3c9-407c-a7a0-15c6c51704fd,SN,2023-01-01,not noted,dam may or may not be a barrier but location was incorrect at time of review
6a792d8f-b9c5-44a4-a260-0f06c3b20821,SN,2023-01-01,not noted,dam may or may not be a barrier but location gets matched to Salmon River
cabd_id,reviewer_name,review_date,source,notes
Loading

0 comments on commit f6c26ec

Please sign in to comment.