Skip to content

Commit

Permalink
Use bslib in tar_watch()
Browse files Browse the repository at this point in the history
  • Loading branch information
wlandau committed May 23, 2024
1 parent aa24578 commit 01c8ca0
Show file tree
Hide file tree
Showing 12 changed files with 75 additions and 69 deletions.
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Description: Pipeline tools coordinate the pieces of computationally
The methodology in this package
borrows from GNU 'Make' (2015, ISBN:978-9881443519)
and 'drake' (2018, <doi:10.21105/joss.00550>).
Version: 1.7.0.9000
Version: 1.7.0.9001
License: MIT + file LICENSE
URL: https://docs.ropensci.org/targets/, https://github.com/ropensci/targets
BugReports: https://github.com/ropensci/targets/issues
Expand Down Expand Up @@ -74,7 +74,7 @@ Imports:
vctrs (>= 0.2.4),
yaml (>= 2.2.1)
Suggests:
bs4Dash (>= 2.0.0),
bslib,
clustermq (>= 0.9.2),
crew (>= 0.9.0),
curl (>= 4.3),
Expand Down
4 changes: 2 additions & 2 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# targets 1.7.0.9000 (development)

# targets 1.7.0.9001 (development)

* Use `bslib` in `tar_watch()`.

# targets 1.7.0

Expand Down
2 changes: 1 addition & 1 deletion R/tar_renv.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
#' tar_option_reset()
tar_renv <- function(
extras = c(
"bs4Dash",
"bslib",
"crew",
"gt",
"markdown",
Expand Down
27 changes: 14 additions & 13 deletions R/tar_watch.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ tar_watch <- function(
supervise = TRUE,
poll_connection = TRUE,
stdout = "|",
stderr = "|"
stderr = "|",
theme = bslib::bs_theme()
) {
tar_assert_watch_packages()
tar_assert_chr(exclude)
Expand Down Expand Up @@ -114,7 +115,8 @@ tar_watch <- function(
display = display,
displays = displays,
host = host,
port = port
port = port,
theme = theme
)
if (!background) {
return(do.call(tar_watch_app, args))
Expand Down Expand Up @@ -154,7 +156,8 @@ tar_watch_app <- function(
display,
displays,
host,
port
port,
theme
) {
ui <- targets::tar_watch_app_ui(
seconds = seconds,
Expand All @@ -169,7 +172,8 @@ tar_watch_app <- function(
degree_to = degree_to,
height = height,
display = display,
displays = displays
displays = displays,
theme = theme
)
server <- function(input, output, session) {
targets::tar_watch_server(
Expand All @@ -193,6 +197,7 @@ tar_watch_app <- function(
#' @return A Shiny UI.
#' @inheritParams tar_watch_ui
#' @param label Label argument to [tar_visnetwork()].
#' @param theme A `bslib` theme object from `bs_theme()`.
tar_watch_app_ui <- function(
seconds,
seconds_min,
Expand All @@ -206,9 +211,10 @@ tar_watch_app_ui <- function(
degree_to,
height,
display,
displays
displays,
theme = bslib::bs_theme()
) {
body <- bs4Dash::bs4DashBody(
bslib::page(
shinybusy::add_busy_spinner(position = "top-left"),
tar_watch_ui(
id = "tar_watch_id",
Expand All @@ -226,14 +232,9 @@ tar_watch_app_ui <- function(
height = height,
display = display,
displays = displays
)
)
bs4Dash::bs4DashPage(
),
title = "",
body = body,
header = bs4Dash::bs4DashNavbar(controlbarIcon = NULL),
sidebar = bs4Dash::bs4DashSidebar(disable = TRUE),
dark = FALSE
theme = theme
)
}
# nocov end
64 changes: 31 additions & 33 deletions R/tar_watch_ui.R
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,10 @@ tar_watch_ui <- function(
seconds_max <- max(seconds_max, seconds)
seconds_step <- min(seconds_step, seconds_max)
ns <- shiny::NS(id)
shiny::fluidRow(
bs4Dash::bs4Card(
inputID = ns("control"),
title = "Control",
status = "primary",
closable = FALSE,
collapsible = FALSE,
width = 3,
solidHeader = TRUE,
accordion <- bslib::accordion(
id = ns("accordion"),
bslib::accordion_panel(
title = "Choose display",
shinyWidgets::radioGroupButtons(
inputId = ns("display"),
label = NULL,
Expand All @@ -83,25 +78,38 @@ tar_watch_ui <- function(
choiceValues = displays,
selected = display,
direction = "vertical"
),
)
),
bslib::accordion_panel(
title = "Refresh settings",
shinyWidgets::actionBttn(
inputId = ns("refresh"),
label = "refresh",
label = "Refresh once",
style = "simple",
color = "primary",
size = "sm",
block = FALSE,
no_outline = TRUE
),
shiny::br(),
shiny::br(),
shinyWidgets::materialSwitch(
inputId = ns("watch"),
label = "watch",
label = "Refresh periodically",
value = TRUE,
status = "primary",
right = TRUE
),
shiny::sliderInput(
inputId = ns("seconds"),
label = "Refresh seconds",
value = seconds,
min = seconds_min,
max = seconds_max,
step = seconds_step,
ticks = FALSE
)
),
bslib::accordion_panel(
title = "Graph settings",
shinyWidgets::materialSwitch(
inputId = ns("targets_only"),
label = "targets only",
Expand Down Expand Up @@ -130,15 +138,6 @@ tar_watch_ui <- function(
)
),
shinyWidgets::chooseSliderSkin("Flat", color = "blue"),
shiny::sliderInput(
inputId = ns("seconds"),
label = "seconds",
value = seconds,
min = seconds_min,
max = seconds_max,
step = seconds_step,
ticks = FALSE
),
shiny::sliderInput(
inputId = ns("level_separation"),
label = "level_separation",
Expand All @@ -162,17 +161,16 @@ tar_watch_ui <- function(
min = 0,
step = 1
)
),
bs4Dash::bs4Card(
inputID = ns("output"),
title = "Output",
status = "primary",
closable = FALSE,
collapsible = FALSE,
solidHeader = TRUE,
width = 9,
shiny::uiOutput(ns("display"))
)
)
sidebar <- bslib::sidebar(
title = "Settings",
id = ns("sidebar"),
accordion
)
bslib::card(
id = ns("ui"),
bslib::layout_sidebar(sidebar = sidebar, shiny::uiOutput(ns("display")))
)
}
# nocov end
2 changes: 1 addition & 1 deletion R/utils_assert.R
Original file line number Diff line number Diff line change
Expand Up @@ -751,7 +751,7 @@ tar_assert_unique_targets <- function(x) {
# tested in tests/interactive/test-tar_watch.R
tar_assert_watch_packages <- function() {
pkgs <- c(
"bs4Dash",
"bslib",
"DT",
"gt",
"markdown",
Expand Down
15 changes: 7 additions & 8 deletions codemeta.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
"codeRepository": "https://github.com/ropensci/targets",
"issueTracker": "https://github.com/ropensci/targets/issues",
"license": "https://spdx.org/licenses/MIT",
"version": "1.6.0.9001",
"version": "1.7.0.9001",
"programmingLanguage": {
"@type": "ComputerLanguage",
"name": "R",
"url": "https://r-project.org"
},
"runtimePlatform": "R version 4.3.2 (2023-10-31)",
"runtimePlatform": "R version 4.4.0 (2024-04-24)",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -62,16 +62,15 @@
"softwareSuggestions": [
{
"@type": "SoftwareApplication",
"identifier": "bs4Dash",
"name": "bs4Dash",
"version": ">= 2.0.0",
"identifier": "bslib",
"name": "bslib",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
"name": "Comprehensive R Archive Network (CRAN)",
"url": "https://cran.r-project.org"
},
"sameAs": "https://CRAN.R-project.org/package=bs4Dash"
"sameAs": "https://CRAN.R-project.org/package=bslib"
},
{
"@type": "SoftwareApplication",
Expand Down Expand Up @@ -643,7 +642,7 @@
"@type": "SoftwareApplication",
"identifier": "secretbase",
"name": "secretbase",
"version": ">= 0.4.0",
"version": ">= 0.5.0",
"provider": {
"@id": "https://cran.r-project.org",
"@type": "Organization",
Expand Down Expand Up @@ -721,7 +720,7 @@
},
"SystemRequirements": null
},
"fileSize": "2608.25KB",
"fileSize": "2602.537KB",
"citation": [
{
"@type": "ScholarlyArticle",
Expand Down
2 changes: 1 addition & 1 deletion inst/rstudio/addins.dcf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Binding: rstudio_addin_tar_make_bg
Interactive: false

Name: Launch app to watch progress
Description: Calls tar_watch(). Requires a _targets.R file and packages bs4Dash, pingr, shiny, and visNetwork.
Description: Calls tar_watch(). Requires a _targets.R file and packages bslib, pingr, shiny, and visNetwork.
Binding: tar_watch
Interactive: false

Expand Down
14 changes: 9 additions & 5 deletions inst/tar_watch/about.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
The `tar_watch()` app visualizes the status and progress of a `targets` pipeline.

## Views
## Displays

* __summary__: overall runtime progress summary of the pipeline. In the table, the "time" column shows the last time a target started, finished, errored, or canceled itself. The "since" columns shows how long ago that was.
* __branches__: like the summary view except with specific information about dynamic branching progress.
* __progress__: a large searchable table of progress information and metadata.
* __graph__: show the `tar_visnetwork()` dependency graph. If this graph may be slow to refresh, consider toggling the outdated switch, speeding up your `_targets.R` file, or selecting another view.

## Controls
## Refresh settings

* __Refresh once__: click this button to force the displays in the app to refresh.
* __Refresh periodically__: toggle whether the app refreshes automatically every few seconds.
* __Refresh seconds__: how often to refresh the displays in the app when the "Refresh periodically" switch is turned on.

## Graph settings

* __refresh__: click this button to force the displays in the app to refresh.
* __watch__: toggle whether the app refreshes automatically every few seconds.
* __targets_only__: whether to show only the targets or also show functions and other global objects.
* __outdated__: whether to color-code nodes depending on whether they are up to date. This feature may cause if the number of targets is enormous, so you may consider turning it off to just color by runtime progress in some cases.
* __label__: labels to append to the node names to optionally show the size, runtime, and number of branches of targets based on past recorded info in the metadata.
* __seconds__: how often to refresh the displays in the app when the "watch" switch is turned on.

* __level_separation__: how wide the graph should be.
2 changes: 1 addition & 1 deletion man/tar_renv.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion man/tar_watch.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion man/tar_watch_app_ui.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 01c8ca0

Please sign in to comment.