Skip to content

Add/copy runs - #42

Merged
Ty-WDFW merged 17 commits into
mainfrom
add/copy_runs
Oct 22, 2025
Merged

Add/copy runs#42
Ty-WDFW merged 17 commits into
mainfrom
add/copy_runs

Conversation

@Ty-WDFW

@Ty-WDFW Ty-WDFW commented Nov 4, 2024

Copy link
Copy Markdown

#38

Copies a run's inputs x times. To save space not copying outputs, assuming that this will be used for sensitivity analyses.

@Ty-WDFW Ty-WDFW mentioned this pull request Nov 4, 2024
3 tasks
@Ty-WDFW Ty-WDFW linked an issue Nov 6, 2024 that may be closed by this pull request
3 tasks
@Ty-WDFW

Ty-WDFW commented Apr 23, 2025

Copy link
Copy Markdown
Author

Need SLRatio table for Chinook

@cbedwards-dfw

Copy link
Copy Markdown
Contributor

We should update copy_runs to silently return the new RunIDs. This will allow us to more easily leverage this with the multi-run FRAM option, as we can automate copying TAMMs with appropriate RunID suffixes. Happy to tackle this in the near term.

@cbedwards-dfw

Copy link
Copy Markdown
Contributor

Major changes:

  • added flexible modify_table() function that uses a "find/replace" dataframe framework.
  • developed flexible sensitivity analysis functions built on that framework
  • fixed unrelated issue with mortality_scaler
  • wrote vignette explaining sensitivity analysis process. Will add example once merge is complete and easily useable.
  • added validate_table() and `provide_table_name() to offload code in fetch_table() plus reuse elsewhere
  • added fetch_table_colnames() for quick validation code
  • updated post_season_abundance() to handle edge case when two species are represented in the stock table.

@Ty-WDFW Ty-WDFW left a comment

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

glue_statement <- glue::glue("UPDATE {{table_name}}
                            Set {glue_changes}
                            Where {glue_conditions};
                            ")
  results <- df |>
    dplyr::rowwise() |>
    dplyr::mutate(db_call = glue::glue(glue_statement)) |>
    dplyr::mutate(rows_affected = DBI::dbExecute(fram_db$fram_db_connection,
      statement = .data$db_call
    )) |>
dplyr::mutate(db_call = as.list(.data$db_call))

So the assumption on this is the that the there are the same number of rows between the two datasets. What if there a different number of rows? This would be a corner case in FRAM, but could lead to unexpected behavior, we should check the integrity of this

@cbedwards-dfw

Copy link
Copy Markdown
Contributor

Sounds good! We should talk through this to make sure I understand -- I haven't really wrapped my head around your SQL code here.

@cbedwards-dfw

Copy link
Copy Markdown
Contributor

We've talked through the modify_run() code above. Do we have any other concerns, or can we merge now?

@Ty-WDFW
Ty-WDFW merged commit 4619fbd into main Oct 22, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sensitiviy Analyses (Project)

3 participants