You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.Rmd
+31-13Lines changed: 31 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -40,16 +40,20 @@ The app is built and maintained by members of [the Strategy Unit's Data Science
40
40
Technically there are two apps: the main app in the `main` branch, and the inputs selection app (where users start or edit a scenario) in the `inputs_selection_app` branch.
41
41
Users arrive at the selection app before being routed to the main app.
42
42
43
-
Both apps are built with [Shiny](https://shiny.posit.co/) and the main app uses the [the {golem} package](https://thinkr-open.github.io/golem/). Server and UI modules can be found in `R/`, configuration in `inst/golem-config.yml` and supporting data and text in `inst/app/`.
44
-
45
-
Packages used in the app are listed in `DESCRIPTION`, and can be installed with `devtools::install_deps(dependencies = TRUE)`.
43
+
Both apps are built with [Shiny](https://shiny.posit.co/) and the main app uses the [the {golem} package](https://thinkr-open.github.io/golem/).
44
+
Server and UI modules can be found in `R/`, configuration in `inst/golem-config.yml` and supporting data and text in `inst/app/`.
46
45
47
46
### Run locally
48
47
49
48
Run the app locally on your machine to test that your changes work as expected.
50
49
51
-
To prepare, add an `.Renviron` file to the project root that contains the required environment variables. There is an `.Renviron.example` file which describes the required variables.
52
-
You can get these from a member of the Data Science team.
50
+
#### Setup
51
+
52
+
First, install the required packages listed in the DESCRIPTION with `pak::local_install_deps(dependencies = TRUE)`.
53
+
54
+
Then add an `.Renviron` file to the project root that contains the required environment variables.
55
+
Copy into it the required variables, which are listed in the `.Renviron.example`.
56
+
You can get the values you need from a member of the Data Science team.
53
57
54
58
Then, from the `main` branch (or your development branch of it), use Git's `worktree` function to put the `inputs_selection_app` branch (or your development branch of it) in its own subfolder.
The first argument is the name of the folder in which to put the branch content.
63
68
If you want a development version of the inputs selection app, you can specify the branch name as the second of the arguments to `git worktree add`.
64
69
65
-
To run the app from RStudio, start up the selection app by opening the `dev/watch.R` script, go to the 'Background Jobs' tab of the console pane and click the 'Start Background Job' button.
66
-
In the 'Run Script as Background Job' dialog box select the project root as the 'Working Directory', then hit 'Start'.
67
-
When ready, the app will tell you to visit `http://127.0.0.1:9081/` in your browser.
68
-
69
-
Note that your selections in the app remain local to you and the resulting json file of parameters for your scenario will live in your local `params/development/` directory.
70
-
These scenarios will be selectable and editable in future from your locally-run inputs selection app.
71
-
72
70
If you need to remove the selection-app folder at any point, you can terminate the background job (if running) and in the terminal run:
73
71
74
72
```
75
73
git worktree remove inputs_selection_app
76
74
```
77
75
76
+
#### Run the app
77
+
78
+
Once setup, we can run the app.
79
+
This is done by launching a background Shiny app and then watching the files for changes, which causes an auto-reload.
80
+
The method for doing this depends on your IDE.
81
+
82
+
In RStudio:
83
+
84
+
1. Open the `dev/watch.R` script and go to the 'Background Jobs' tab of the console pane and click the 'Start Background Job' button.
85
+
2. Click 'Start' after checking that the 'R Script' path is pre-populated with the path to `watch.R` (otherwise select it yourself).
86
+
3. When ready, a message will tell you to visit `http://127.0.0.1:9081/` in your browser.
87
+
88
+
In Positron: run `source('dev/watch.R')` and click the link to the URL when complete.
89
+
90
+
In VS Code: open the command palette (<kbd>Ctrl</kbd>+<kbd>Shift</kbd>+<kbd>P</kbd>), search for 'Tasks: Run Task', then select 'R: Run App (watch)' and finally click the link to the URL when complete.
91
+
92
+
Making selections in the app will cause values to be written to a local json file, which will live in your local `params/development/` directory.
93
+
These scenarios will be selectable and editable in future from your locally-run inputs selection app.
94
+
They will not be available from the deployed app.
95
+
78
96
### Test in dev
79
97
80
98
During pre-release QA we test both apps on the server.
@@ -84,7 +102,7 @@ To test the unreleased app in our development environment:
84
102
85
103
1. Merge any PRs you want to test into the `main` branch.
86
104
2. If you've changed any dependencies, run `dev/generate_manifest.R` to update `manifest.json`.
87
-
3. If you've made any changes to the inputs selection app, run the manual `deploy()` call under the 'development' heading in the `deploy.R` script in your selectionapp development branch.
105
+
3. If you've made any changes to the inputs selection app, run the manual `deploy()` call under the 'development' heading in the `deploy.R` script in your selection-app development branch.
88
106
89
107
When using the dev inputs selection app on Connect, make sure to set the 'Model Version' dropdown to 'dev' in the expandable 'Advanced Options' box.
90
108
That way you'll be taken to the dev inputs app when you hit 'Start'.
0 commit comments