Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge dev to master #2

Open
wants to merge 294 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
294 commits
Select commit Hold shift + click to select a range
b866258
Shapefile checker works as expected at this point
Dec 20, 2022
56c0f9c
Added a script that renew download url for shapefile submission
Dec 29, 2022
696e4b7
All checks have been implemented into the checker, BUT not tested
Dec 29, 2022
04efef5
Fixed bugs in shapefile custom
Dec 29, 2022
3391990
Fixed the emailing function of shapefile checker
Dec 30, 2022
dbbd283
Fixed bugs in the shapefile custom checks
r7butler Jan 4, 2023
228d9e6
id description for checks and warnings updated for consistency with Q…
Jan 4, 2023
64e9f4f
added zaib to maintainers
Jan 5, 2023
1f53a8f
lowercased bad column argument for checkData functio so mark_workbook…
Jan 5, 2023
24a2bbc
enable all datatypes for submission type drop down button on login page
Jan 5, 2023
778bfbe
lowercased badcolumn argument for checkData functions for all importe…
Jan 5, 2023
dc4a2a2
commented issue on algae check 2 due to inconsistencies between lu_or…
Jan 6, 2023
37a4528
convert_dtype function added to functions.py for custom checks to con…
Jan 6, 2023
c5d19cc
added check - value in results column is numeric and import convert_d…
Jan 6, 2023
2469f5d
check 5 - replaced numpy float64 type with python float type for resu…
Jan 6, 2023
ff221cc
lu_algae_ste no longer in use by algae custom checks - replaced with …
Jan 26, 2023
547036e
Remove agency from login window for shapefile submission
r7butler Jan 30, 2023
7aadffa
Start implementing visualization feature to the shapefile checker
r7butler Jan 31, 2023
aea5a2f
implemented the map for shapefile submission
r7butler Feb 2, 2023
b811a86
imported two functions for custom checks (i) multivalue_lookup_check …
r7butler Feb 6, 2023
147885a
added lastchangedate column to system_fields so match_table routine w…
r7butler Feb 6, 2023
ec8743a
Check for existing records based on masterid, date
Feb 6, 2023
c7495af
The shapefile works as expected
r7butler Feb 6, 2023
bc0a25c
wrote check #5 and tested
r7butler Feb 7, 2023
6eaf06b
make sure the match routine runs first
r7butler Feb 14, 2023
751d17c
minor changes to the map
r7butler Feb 14, 2023
f020b97
Fixed bugs for the shape checker, particularly the custom check
r7butler Feb 16, 2023
36e0635
commented out the tool for visual map function for shapefile checker
r7butler Feb 17, 2023
c2179c4
imported re for check 2, created tmp_row column from index for each …
Feb 24, 2023
ee6c45d
Added check 1:If Other for the bottom field then corresponding bottom…
Feb 27, 2023
f156e61
Added Check 2: If Other for the determination field then correspond…
Feb 27, 2023
fcc2368
Added Check 3:# Check 3: If Other for the leftsideofstructure field t…
Feb 28, 2023
7850be8
updated maintainers to include an additional part timer working on sm…
r7butler Feb 28, 2023
5cdb092
Added2 checks. Check 4: If Other for the rightsideofstructure fiel…
Feb 28, 2023
540ee41
updated maintainers list to add part timer testing and validating che…
Mar 1, 2023
50d1ce2
imoprted g from flask, and pandas, added check 6:(Engineered Channels…
Mar 2, 2023
5e17078
change tbl_phab_newformat to tbl_phab
Mar 15, 2023
3f8c75a
too many changes to track - this is before updating the dev server
Mar 15, 2023
9894861
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
Mar 15, 2023
1051793
Fixed bugs in shapefile checker
Mar 17, 2023
6ad24b3
we need to figure out how to determine the projection of a spatial da…
Mar 17, 2023
c867dd5
Added a column to system fields
Mar 17, 2023
e011e9b
check polygon's geometries
r7butler Mar 17, 2023
780d55b
added field form for downloading
r7butler Mar 29, 2023
7d46808
channelengineering checks transferfrom old checker and qa in progress
r7butler Mar 30, 2023
b3959af
phab checks transfer from old checker and qa in progress
r7butler Mar 30, 2023
d7860ea
site evaluation checks transfer from old checker and qa in progress
r7butler Mar 30, 2023
34b6387
importing generalized templater routine from generalized checker routine
r7butler Mar 30, 2023
c1472c1
added boto3 for aws related tasks
Mar 30, 2023
ac6da89
templater routine return argument was updated, attachment_filename up…
Mar 30, 2023
4179a78
merge conflict from templater routine resolved
Mar 30, 2023
c1e3c70
Commited checks 2,3 and 4
Apr 12, 2023
67a45b2
the checking tool for shapefile works correctly
r7butler Apr 18, 2023
b070623
used geopandas to check for shapefile's projections
r7butler Apr 18, 2023
85fa405
change placeholders
Apr 18, 2023
ea50544
if a user submits all empty tabs, they will be notified on the front end
Apr 21, 2023
5ebd975
finalized the shapefile checker
Apr 24, 2023
097aef6
Adjusted the shapefile checking tool based on Rafi request
Apr 26, 2023
aaa18a7
changed stationid to stationcode
Apr 26, 2023
9962408
changes to the shapefile checking tool
r7butler Apr 27, 2023
7cf71fe
change app maintainers in init, remove print statements in process_sh…
May 12, 2023
a5d4b20
trash,siteeval,hydrostate custom checks are working properly. I've QA…
r7butler May 12, 2023
8950328
Aria - I wrote these checks and QA them. They are working properly
r7butler May 23, 2023
86f9942
Aria - toxicity checks are done
May 23, 2023
e0d3f9a
Checks 1, 2, 3 for hydromod. Commited by Ayah
May 24, 2023
56bb24c
modified the export route for data query tool - Duy
r7butler May 30, 2023
6d34f6d
fixed a bug in export route
r7butler May 30, 2023
265fce1
Aria- Trash checks are all done and QA is complete and verified
r7butler May 30, 2023
8e5d623
renumber the phab checks and adding the starttime endtime check for t…
May 30, 2023
c4a6b56
changes - im only doing this now so i can resolve the potential merge…
r7butler May 30, 2023
93088f6
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
r7butler May 30, 2023
68ddb96
resolving merge conflict
May 30, 2023
2eab80b
Added function to check 1 and 2 for taxonomy
May 31, 2023
8ea22cf
Added fucntion consecutive_date for taxonomy check 1 and 2
May 31, 2023
dc3018c
Aria - added Batch_Example to excel_tabs_to_ignore for a check in che…
May 31, 2023
618ba99
Aria -5/32/23 - I finished writting, QA, and product log for the rema…
May 31, 2023
5543217
Aria -5/32/23 - this is Aria pushing on behalf of Ayah modified a fu…
May 31, 2023
1896f80
Aria -5/32/23 -Aria and Ayah working on taxonomy still unfinished
May 31, 2023
bc2e770
Aria- Updated Chemistry file by adding old server file comments in, s…
Jun 5, 2023
baa4e92
Aria- Finished Chemistry and validated remaining checks and added old…
Jun 6, 2023
ff45302
/schema and /track are up
r7butler Jun 7, 2023
9ba1b71
bug in california check - commented out for nwo
r7butler Jun 7, 2023
2652108
attempting to add download button to schema app
r7butler Jun 7, 2023
66c6291
shapefile_checker- in case the code fails to convert projection to 43…
r7butler Jun 9, 2023
135afd9
attempting to dry up the channelengineering checks about required fie…
Jun 12, 2023
b86646a
deleted old engineered channel code
Jun 12, 2023
146f77a
revising the RL check in chemistrychecks - needs to be QAd
Jun 12, 2023
72894f1
just making my added comment more readable
Jun 12, 2023
2c526b9
just added a comment about how the channel engineering section needs …
Jun 12, 2023
f4fd6ac
replace 'channeltype' with the correct variablename 'field'
Jun 12, 2023
dcc764a
ChannelEngineering is now completed, modified, and went through the Q…
Jun 12, 2023
3b43b48
adding geopy to the list of installs for the docker image
Jun 14, 2023
389dc12
Aria- Taxonomy completed minus check 10
Jun 14, 2023
fb6d427
Aria - taxonomy completed
Jun 15, 2023
dd8e547
Aria- resolved the issue from taxonomy_custom all checks are reevalua…
Jun 21, 2023
f48d52f
Aria - pushed the R folder with the R files
Jun 21, 2023
4832590
Aria - analysis R script is added and working
Jun 23, 2023
dab86e6
Aria - analysis R script is added and working
Jun 23, 2023
aff5429
Aria - Rscript template added to phab
Jun 23, 2023
b3cf049
Aria- Updated Taxonomy to include logic check
Jun 27, 2023
b6171ed
Aria's changes for implementing a placeholder analysis script for the…
Jun 27, 2023
42b0c45
pulled latest changes
Jun 27, 2023
394bfd0
added core api check function to interface with lambda function
Jun 28, 2023
ff75d3d
Aria- Logic check for taxonomy has been updated
Jun 28, 2023
cdea8fa
Aria- Added a new check which takes collectiontime field and checks i…
Jun 30, 2023
f2d4d12
Aria-Updated checks 2 and 3: it was not functioning properly due to a…
Jun 30, 2023
21356a2
added instructions for map check
r7butler Jul 5, 2023
c96773c
change error msg for invalid shapefile custom check
r7butler Jul 10, 2023
f5e8fb6
changed from errs to warnings for the distance check in custom shapefile
r7butler Jul 11, 2023
fc605bc
added the description field in the schema app
r7butler Jul 11, 2023
52e8509
make point-outside-polygon warning check type
r7butler Jul 12, 2023
4650b73
permission needs to be granted to export folder also
r7butler Jul 17, 2023
7332179
fixed shapefile custom bug - should return when the validation check …
r7butler Jul 17, 2023
aeca408
Merge branch 'dev' of github.com:SCCWRP/smcchecker into lambda-core
Jul 18, 2023
15d6967
Clean shapefile custom checks file
r7butler Jul 18, 2023
c79361d
preparing to add the map checks
r7butler Jul 18, 2023
92bfcc2
Merge branch 'dev' of github.com:SCCWRP/smcchecker into lambda-core
Jul 18, 2023
6efe293
adding time format check to algae
Jul 18, 2023
bf04afb
downloaded shapefile bug fix
r7butler Jul 21, 2023
8fb4ecb
bug fix shapefile download tool
r7butler Jul 22, 2023
c3ca296
finished fixing shapefile download tool bugs
r7butler Jul 22, 2023
ef14804
bug fixing in download shapefile tool
r7butler Jul 24, 2023
7fc0415
schema and column-order tools should be working now
r7butler Jul 24, 2023
4c411ce
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
r7butler Jul 24, 2023
343adaf
removed the renew shapefile download url function-this function is us…
r7butler Jul 24, 2023
3fdbbc3
bug fix
r7butler Jul 24, 2023
921e262
changed the custom log
r7butler Jul 25, 2023
14fba5b
added data validation to shapefile download tool
r7butler Jul 25, 2023
d5e6a88
added data validation to shapefile download tool
r7butler Jul 25, 2023
e20bd6c
fixed .index and changeed it to .tmp_row - Ayah 07/27/23
Jul 27, 2023
bf66540
sped up fix_case function, doesn't iterate through entire submission …
Aug 2, 2023
197194a
fixed a typo in downloadsf.js
r7butler Aug 11, 2023
6706960
fixed a typo in downloadsf.js
r7butler Aug 11, 2023
badfa16
implemented asci script
r7butler Aug 12, 2023
24e83e7
removed ASCI tab in the submitted excel file in the load routine
r7butler Aug 13, 2023
e1c067e
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
Aug 14, 2023
cae03ef
writing data to shapefile seems to cause many issues with the API. It…
r7butler Aug 15, 2023
9dd1654
There are some bugs with the core lambda, so i get the corecheck code…
r7butler Aug 15, 2023
0183d6b
uncomment the clean_data function in main.py
r7butler Aug 16, 2023
6fe971e
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
Aug 16, 2023
5b1b562
added Rhistory to gitignore
Aug 16, 2023
b0df115
implemented CSCI script, so user can download it when they submit cle…
r7butler Aug 17, 2023
b206451
Aria 8/22/2023 -Updated format and revised some checks as well as re-…
Aug 22, 2023
49f14e3
Aria Askaryar 08/23/2023 - Updated Trash file fixed errors found by P…
Aug 23, 2023
5408688
finished trash checks
r7butler Aug 25, 2023
733b2d7
Aria Askaryar 08/29/2023 -New Formatting for Algae checks is implemen…
Aug 29, 2023
8238bfc
Aria Askaryar 08/29/2023 -New Formatting for Chemistry checks is imp…
Aug 29, 2023
8894265
Aria Askaryar 08/29/2023 -New Formatting for Hydrostate checks is imp…
Aug 29, 2023
bf048ae
Aria Askaryar 08/29/2023 -New Formatting for PHAB checks is implement…
Aug 29, 2023
0e6f1dd
Aria Askaryar 08/29/2023 -New Formatting for Siteevaluation checks is…
Aug 29, 2023
6fba53d
Aria Askaryar 08/29/2023 -New Formatting for Taxonomy checks is imple…
Aug 29, 2023
7cb331e
Aria Askaryar 08/29/2023 -New Formatting for algae checks is implemen…
Aug 29, 2023
5a979b2
Aria Askaryar 08/29/2023 -New Formatting for toxicity checks is imple…
Aug 29, 2023
80cd852
Aria Askaryar 08/29/2023 -New Formatting for vertebrate checks is imp…
Aug 29, 2023
71286db
Aria Askaryar 08/29/2023 -New Formatting for hydromod checks is imple…
Aug 29, 2023
a46c591
Aria Askaryar 08/29/2023 -New Formatting for algae checks is implemen…
Aug 29, 2023
2f44276
added 2023 to year options
r7butler Aug 30, 2023
a4287ec
fixed merge conflicts on the dev server
Aug 30, 2023
8f25087
QAed Hydromod and ChannelEngineering
r7butler Aug 30, 2023
59501eb
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
r7butler Aug 30, 2023
a7b300c
make links relative
r7butler Aug 30, 2023
600de00
making links relative
r7butler Aug 30, 2023
2fb444e
updated the templater code, updated the tables required for timeseries
r7butler Aug 30, 2023
ad2e681
Aria -8/31/2023 - implemneted formatting to channelengineering
Aug 31, 2023
0efd76a
changed the messsage for column description for templater
r7butler Aug 31, 2023
2a2e7d7
fixed bugs in timeseries
r7butler Aug 31, 2023
e332c19
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
Aug 31, 2023
c6a12f6
fixed regex match for optional seconds characters (i.e. HH:MM:SS) in …
r7butler Aug 31, 2023
d1c13cf
added 2 fields vertsuscept and averagelatsuscept to system fields. th…
r7butler Sep 1, 2023
915a463
fixed a logic in hydromod custom check
r7butler Sep 5, 2023
c31b607
fixed logic errors in hydromod
r7butler Sep 5, 2023
a8ba333
added docker folder to gitignore
Sep 5, 2023
c4a8fda
replace writer=pd.ExcelWriter by using with keyword
Sep 5, 2023
cbbce6d
added the latest mismatch funcs to custom funcs
Sep 5, 2023
c99eb3a
added columns to drop for shapefile checker
r7butler Sep 6, 2023
a6605c8
uncomment the check, I am not sure why it is commented out - Last Edi…
Sep 6, 2023
d35f182
check 6 is improperly written, Duy needs to rewrite it
Sep 6, 2023
75625ff
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
Sep 6, 2023
08a7334
fixed template save/download path
Sep 12, 2023
74c6b47
fixed checks 5 and 6
Sep 13, 2023
1d95266
fixed some library import references
Sep 13, 2023
a2a8ce5
changed checks 7 and 8 to warnings, changed checks 9 and 10 to use mi…
Sep 13, 2023
17ceb68
Nick experimented something with the custom taxonomy check - he confi…
Sep 18, 2023
56b6f2a
fixed bugs in shapefile checker
r7butler Oct 2, 2023
9882f2d
fixed bugs in the downloadsf tool
r7butler Oct 4, 2023
faa9a6f
adjusted for PHAB routine
r7butler Oct 5, 2023
6c494ec
added starter code for check10
r7butler Oct 5, 2023
f5d48fb
changed from error to warning for siteeval custom checks
r7butler Oct 5, 2023
67a634a
fixed bugs in trash custom
r7butler Oct 5, 2023
0f1b1a9
Robert made changes to the chemistry custom check
r7butler Oct 5, 2023
d880feb
changed from err to warning in chemistry_custom check
Oct 5, 2023
fa79f15
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
Oct 5, 2023
aac34a0
added lu_list links to vertebrate error message for check 1
Oct 6, 2023
3f069c9
one of the custom vertebrate checks was pulling values from lu_statio…
r7butler Oct 9, 2023
eace3e8
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
r7butler Oct 9, 2023
de63b29
update check 7
Oct 10, 2023
0c74577
Merge branch 'dev' of github.com:SCCWRP/smcchecker into dev
Oct 10, 2023
e28425c
adding comments about vertebrate code
r7butler Oct 10, 2023
336bc22
engineered channel checks should say 'or Other' for left and right si…
r7butler Oct 11, 2023
296641c
changed failed-to-convert-projection error message of shapefile checker
r7butler Oct 11, 2023
07bb255
Aria Askaryar 10/16/2023 -Fixed all hyperlink issues for trash dataty…
Oct 16, 2023
c698e44
Aria Askaryar 10/16/2023 -I fixed the follwing issues: fixed the hype…
Oct 16, 2023
a0d1cad
Aria Askaryar 10/16/2023 -forgot to update the documentation blocks
Oct 16, 2023
22b120e
Aria Askaryar 10-17-2023 -working on check 1 and 2
Oct 17, 2023
47f4544
fixed merge conflicts
Oct 17, 2023
b311a1e
added target = _blank to vertebrate checks
r7butler Oct 17, 2023
e1c39dc
uncommented the distance check
r7butler Oct 17, 2023
f363bc0
fixed a bug with check_missing_phab_data function. it should merge on…
r7butler Oct 19, 2023
00eaede
for the shapefile checking tool, remove left and right whitespaces
r7butler Oct 19, 2023
175a123
null values will be denoted by only empty strings (empty cells) so th…
r7butler Oct 20, 2023
6c8f2f9
fixed an error in datasets.json
r7butler Oct 23, 2023
6b6fc45
changed from '%' to '% recovery' for chemistry custom check 22,24
r7butler Oct 30, 2023
0dc6c4e
Robert fixed the scaling issue in core check
r7butler Oct 30, 2023
7f20db3
fixed broken lookup list link
r7butler Nov 1, 2023
fb615ac
Select from a different view for the ASCI gis predictors - this is be…
r7butler Nov 1, 2023
85e2e8f
temporarily disable the generate map and download shapefile function …
r7butler Nov 1, 2023
8b9c622
fixed a bunch of stuff with the shapefile checking tool
r7butler Nov 3, 2023
6a602f0
clarified instructions to the shapefile checking tool
r7butler Nov 3, 2023
733971b
added a reset all button
r7butler Nov 3, 2023
d1dc4a1
temporarily disable projection auto-convert in shapefile checker
r7butler Nov 3, 2023
7369d53
added alias check within submission for shapefile checker
r7butler Nov 9, 2023
783b850
remove a print statement in algae custom since it caused a critical e…
r7butler Nov 20, 2023
e877bdd
if shapefile is improperly formatted, we cannot read the crs of a geo…
r7butler Nov 20, 2023
7bc7841
created sqi_rawdata route
r7butler Nov 27, 2023
65340d0
adjusted siteeval custom check
r7butler Nov 27, 2023
a1da018
made adjustments to the delineation checking tool
r7butler Nov 28, 2023
a584e1f
attempted to make a delineation audit tool for jeff
r7butler Nov 28, 2023
60ed67c
use script_root in tracking tool so downloading the files acutally works
r7butler Dec 5, 2023
7cd3596
convert new_lat and new_long to floats
r7butler Dec 5, 2023
97af502
robert fixed a bug in read_shapefile function
r7butler Dec 6, 2023
7c8ae87
Ayah added algae custom checks, there were changes to index.html and …
r7butler Feb 20, 2024
024468c
changed custom phab check 1 to warning
r7butler Feb 23, 2024
357c4bb
putting maintainance notice for check-delineation tool
r7butler Feb 28, 2024
e57b5d0
removed maintainance notice
r7butler Feb 28, 2024
aa2b820
changes
r7butler May 23, 2024
29aeb7e
round the number to 10 decimal points in checkscale function
r7butler Aug 16, 2024
7460196
removed ayah from maintainers
r7butler Sep 5, 2024
c2c3010
allowed null timestamp (when column is not required) into the database
r7butler Sep 6, 2024
3e29b30
some code for shapefile custom are redundant - Dui removed it
r7butler Sep 25, 2024
356c3a6
changed from vw_sqi_dat to materialized view
r7butler Oct 1, 2024
52c4d5d
ensuring a scientific notation not treated as number, this is regardi…
r7butler Oct 14, 2024
86adac1
turn off the warning that PHAB data is not submitted, PHab data will …
r7butler Oct 14, 2024
864822f
no longer need gis object to download shapefile
r7butler Oct 18, 2024
a60d73d
disabled the check that raises a phab data not exists warning
r7butler Oct 25, 2024
03c8af5
check the time format for values that are not NR
r7butler Oct 25, 2024
21a86d3
Changed the texts for final-error and final-warning containers
r7butler Oct 25, 2024
99602aa
fixed convert_dtype in core check by putting t(x) back in
r7butler Oct 28, 2024
b3ef8da
Hosted some icons for the SQI dashboard
r7butler Oct 31, 2024
1197c03
fixed a taxonomy custom check
r7butler Nov 12, 2024
2cb68df
do not allow a period in the filename
r7butler Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ proj/templates/__pycache__/
# not for the smc checker
# proj/custom/*_custom.py

docker/deploy.sh
docker
R/.Rhistory
44 changes: 44 additions & 0 deletions R/asci.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
library(DBI)
library(dplyr)
library(RPostgreSQL)
library(ASCI)
library(readxl)

args = commandArgs(trailingOnly=TRUE)

dir <- args[1]
filename <- args[2]

print('Connecting to the database')
con <- dbConnect(
PostgreSQL(),
host = Sys.getenv('DB_HOST'),
dbname = Sys.getenv('DB_NAME'),
user = Sys.getenv('DB_USER'),
password = Sys.getenv('DB_PASSWORD')
)
print('Created database connection')

alg <- readxl::read_excel(file.path(dir, filename))

# Select from vw_asci_checker_gispredictors since the other view vw_asci_gispredictors only grabs records for stations in unified algae
# That view is for the sync script
gis <- dbGetQuery(con, 'SELECT * FROM vw_asci_checker_gispredictors') %>% filter(StationCode %in% alg$stationcode)

alg <- alg %>%
select(c('stationcode','sampledate','replicate','sampletypecode','baresult','result','finalid')) %>%
rename(
`StationCode` = stationcode,
`SampleDate` = sampledate,
`Replicate` = replicate,
`SampleTypeCode` = sampletypecode,
`BAResult` = baresult,
`Result` = result,
`FinalID` = finalid
)


output <- ASCI(alg, gis) %>% smcify

write.csv(output, file = file.path(dir, 'ASCI_scores.csv'), row.names = FALSE)

70 changes: 70 additions & 0 deletions R/csci.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
library(DBI)
library(dplyr)
library(RPostgreSQL)
library(CSCI)
library(readxl)

args = commandArgs(trailingOnly=TRUE)

dir <- args[1]
filename <- args[2]

print('Connecting to the database')
con <- dbConnect(
PostgreSQL(),
host = Sys.getenv('DB_HOST'),
dbname = Sys.getenv('DB_NAME'),
user = Sys.getenv('DB_USER'),
password = Sys.getenv('DB_PASSWORD')
)
print('Created database connection')

bugs <- readxl::read_excel(file.path(dir, filename))

# This view does not limit the stations to the ones that are in unified_taxonomy, for some reason
gis <- dbGetQuery(con, 'SELECT * FROM vw_csci_gispredictors') %>% filter(StationCode %in% bugs$stationcode)

bugs <- bugs %>%
mutate(
sampleid = paste(stationcode, gsub("[/\\s:]", "", format(sampledate, "%Y%m%d")), fieldreplicate, sep = "_")) %>%
select(c('stationcode', 'sampleid' ,'baresult', 'lifestagecode', 'distinctcode', 'finalid')) %>%
rename(
`StationCode` = stationcode,
`SampleID` = sampleid,
`FinalID` = finalid,
`BAResult` = baresult,
`LifeStageCode` = lifestagecode,
`Distinct` = distinctcode
)

bugs <- cleanData(bugs)
bugs <- bugs %>% mutate(BAResult = as.numeric(BAResult)) # this can be altered in the view definition
metadata <- BMIMetrics::loadMetaData()
namecheck <- paste(bugs$FinalID, bugs$LifeStageCode) %in% paste(metadata$FinalID, metadata$LifeStageCode)
missing <- which(!namecheck)
if(length(missing)>0){
casenamecheck <- paste(toupper(bugs$FinalID[missing]), bugs$LifeStageCode[missing]) %in% paste(toupper(metadata$FinalID), metadata$LifeStageCode)
bugs$FinalID[missing][casenamecheck] <-
as.character(metadata$FinalID[match(toupper(bugs$FinalID[missing][casenamecheck]), toupper(metadata$FinalID))])
if(length(namecheck) != (sum(namecheck) + sum(casenamecheck)))
warning(c("The following FinalID/LifeStageCode combinations did not match with the internal database:",
paste(unique(paste(bugs$FinalID[!namecheck], bugs$LifeStageCode[!namecheck])), collapse=", ")))
}
notfound <- bugs %>% filter(!namecheck)
bugs <- bugs %>% filter(namecheck)

result <- CSCI(bugs, gis)

core <- result$core
suppl1_grps <- result$Suppl1_grps
suppl1_mmi <- result$Suppl1_mmi
suppl2_mmi <- result$Suppl2_mmi
suppl1_oe <- result$Suppl1_OE
suppl2_oe <- result$Suppl2_OE

write.csv(core, file = file.path(dir, 'core.csv'), row.names = FALSE)
write.csv(suppl1_grps, file = file.path(dir, 'suppl1_grps.csv'), row.names = FALSE)
write.csv(suppl1_mmi, file = file.path(dir, 'suppl1_mmi.csv'), row.names = FALSE)
write.csv(suppl2_mmi, file = file.path(dir, 'suppl2_mmi.csv'), row.names = FALSE)
write.csv(suppl1_oe, file = file.path(dir, 'suppl1_oe.csv'), row.names = FALSE)
write.csv(suppl2_oe, file = file.path(dir, 'suppl2_oe.csv'), row.names = FALSE)
29 changes: 29 additions & 0 deletions R/phab.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
library(PHABMetrics)
library(PHAB)


##########---R Script----##############################
randomdataframe <- data.frame(testcol1 = c(1,2,3,4,5), testcol2 = c(5,6,7,8,9), testcol3 = c('a','b','c','d','e'))
print("dataframe: ")
randomdataframe

args <- commandArgs(trailingOnly=TRUE)
print("args:")
args
dir <- args[1]
print("dir:")
dir
filename <- args[2]
print("filename:")
filename
wbpath <- file.path(dir, filename)
print("wbpath:")
wbpath
output <- (randomdataframe)
print("Output:")
output

write.csv(randomdataframe, file = file.path(dir, 'output.csv'), row.names=FALSE)


########################################
55 changes: 0 additions & 55 deletions docker/Dockerfile

This file was deleted.

4 changes: 2 additions & 2 deletions permissions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ fi

DIRECTORY=$(cd `dirname $0` && pwd)
chown -R $editor.$editor $DIRECTORY;
chown -R www-data.$editor $DIRECTORY/files $DIRECTORY/proj/custom $DIRECTORY/proj/static $DIRECTORY/proj/config;
chmod -R 775 $DIRECTORY/files $DIRECTORY/proj/custom $DIRECTORY/proj/static;
chown -R www-data.$editor $DIRECTORY/files $DIRECTORY/export $DIRECTORY/proj/custom $DIRECTORY/proj/static $DIRECTORY/proj/config;
chmod -R 775 $DIRECTORY/files $DIRECTORY/export $DIRECTORY/proj/custom $DIRECTORY/proj/static;
chmod -R 575 $DIRECTORY/proj/config;
26 changes: 24 additions & 2 deletions proj/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,19 @@
from sqlalchemy import create_engine
import psycopg2
from psycopg2 import sql

from flask_cors import CORS
# import blueprints to register them
from .main import upload
from .login import homepage
from .load import finalsubmit
from .download import download
from .scraper import scraper
from .templater import templater # for dynamic lookup lists called into template before output to user

from .process_shapefile import sfprocessing
from .load_shapefile import sfloading
from .map_check import map_check, get_map_info
from .admin import admin
from .query import query

CUSTOM_CONFIG_PATH = os.path.join(os.getcwd(), 'proj', 'config')

Expand All @@ -26,17 +30,28 @@


app = Flask(__name__, static_url_path='/static')

# CORS(app, resources={r"/arcgis/*": {"origins": "https://nexus.sccwrp.org"}})

CORS(app)

app.debug = True # remove for production


# does your application require uploaded filenames to be modified to timestamps or left as is
app.config['APP_SCRIPT_ROOT'] = 'smcchecker'

app.config['CORS_HEADERS'] = 'Content-Type'

app.config['MAIL_SERVER'] = os.environ.get('FLASK_APP_MAIL_SERVER')

app.config['MAX_CONTENT_LENGTH'] = 200 * 1024 * 1024 # 200MB limit

app.config['BACKGROUND_IMAGE'] = BASIC_CONFIG.get("BACKGROUND_IMAGE")

app.secret_key = os.environ.get("FLASK_APP_SECRET_KEY")


# set the database connection string, database, and type of database we are going to point our application at
#app.eng = create_engine(os.environ.get("DB_CONNECTION_STRING"))
def connect_db():
Expand Down Expand Up @@ -138,9 +153,16 @@ def teardown_request(exception):
# need to assert that the table names are in (SELECT table_name FROM information_schema.tables)

app.register_blueprint(upload)
app.register_blueprint(sfprocessing)
app.register_blueprint(sfloading)
app.register_blueprint(homepage)
app.register_blueprint(finalsubmit)
app.register_blueprint(get_map_info)
app.register_blueprint(download)
app.register_blueprint(scraper)
app.register_blueprint(templater)
app.register_blueprint(map_check)
app.register_blueprint(admin)
app.register_blueprint(query)


Loading