Skip to content

Commit

Permalink
Merge pull request #47 from r-lib/upkeep
Browse files Browse the repository at this point in the history
Upkeep
  • Loading branch information
lionel- authored Aug 28, 2024
2 parents 8cf2232 + 6a3e44b commit a45f1f5
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 62 deletions.
24 changes: 12 additions & 12 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ on:
pull_request:
branches: [main, master]

name: R-CMD-check
name: R-CMD-check.yaml

permissions: read-all

jobs:
R-CMD-check:
Expand All @@ -25,17 +27,15 @@ jobs:
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}
# use 4.0 or 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: 'oldrel-4'}

- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'oldrel-3'}
- {os: ubuntu-latest, r: 'oldrel-4'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ on:
types: [published]
workflow_dispatch:

name: pkgdown
name: pkgdown.yaml

permissions: read-all

jobs:
pkgdown:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ on:
issue_comment:
types: [created]

name: Commands
name: pr-commands.yaml

permissions: read-all

jobs:
document:
Expand All @@ -13,6 +15,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand Down Expand Up @@ -50,6 +54,8 @@ jobs:
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v4

Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ Suggests:
testthat (>= 3.0.0)
VignetteBuilder:
knitr
Config/testthat/edition: 3
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
Roxygen: list(markdown = TRUE)
RoxygenNote: 7.2.3
RoxygenNote: 7.3.2
77 changes: 43 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,36 +7,35 @@

[![CRAN
status](https://www.r-pkg.org/badges/version/coro)](https://cran.r-project.org/package=coro)
[![R build
status](https://github.com/r-lib/coro/workflows/R-CMD-check/badge.svg)](https://github.com/r-lib/coro/actions)
[![R-CMD-check](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/r-lib/coro/actions/workflows/R-CMD-check.yaml)
<!-- badges: end -->

## Overview

coro implements **coroutines** for R, i.e. functions that can be
suspended and resumed later on. There are two kinds:

- **Async** functions, which make it straightforward to program
concurrently
- **Generators** for iterating over complex sequences
- **Async** functions, which make it straightforward to program
concurrently
- **Generators** for iterating over complex sequences

Supported features:

- Suspending within loops and if/else branches
- Suspending within `tryCatch()`
- `on.exit()` expressions and stack-based cleanup such as provided by
`local_` functions in the [withr](https://github.com/r-lib/withr/)
package
- Step-debugging and `browser()` within coroutines
- Suspending within loops and if/else branches
- Suspending within `tryCatch()`
- `on.exit()` expressions and stack-based cleanup such as provided by
`local_` functions in the [withr](https://github.com/r-lib/withr/)
package
- Step-debugging and `browser()` within coroutines

Compatibility with:

- Python iterators from the
[reticulate](https://rstudio.github.io/reticulate/) package
- Async operations from the
[promises](https://github.com/rstudio/promises/) package
- Parallel computations from the
[future](https://github.com/HenrikBengtsson/future) package
- Python iterators from the
[reticulate](https://rstudio.github.io/reticulate/) package
- Async operations from the
[promises](https://github.com/rstudio/promises/) package
- Parallel computations from the
[future](https://github.com/HenrikBengtsson/future) package

Attach the package to follow the examples:

Expand Down Expand Up @@ -105,10 +104,10 @@ my_async <- async(function() {

Generators are based on a simple iteration protocol:

- Iterators are functions.
- They can be advanced by calling the function. The new value is
returned.
- An exhausted iterator returns the sentinel symbol `exhausted`.
- Iterators are functions.
- They can be advanced by calling the function. The new value is
returned.
- An exhausted iterator returns the sentinel symbol `exhausted`.

The `generator()` function creates a generator factory which returns
generator instances:
Expand All @@ -130,11 +129,13 @@ A generator instance is an iterator function which yields values:
``` r
abc
#> <generator/instance>
#> function() {
#> for (x in letters[1:3]) {
#> yield(x)
#> }
#> function ()
#> {
#> for (x in letters[1:3]) {
#> yield(x)
#> }
#> }
#> <environment: 0x1258e3818>

abc()
#> [1] "a"
Expand Down Expand Up @@ -250,11 +251,13 @@ state machine that is running under the hood:
``` r
print(generate_abc, internals = TRUE)
#> <generator>
#> function() {
#> for (x in letters[1:3]) {
#> yield(x)
#> }
#> function ()
#> {
#> for (x in letters[1:3]) {
#> yield(x)
#> }
#> }
#> <environment: 0x1258e3818>
#> State machine:
#> {
#> if (exhausted) {
Expand Down Expand Up @@ -305,12 +308,12 @@ keeps track of the source references from the original code.

## Acknowledgements

- The [regenerator](https://facebook.github.io/regenerator/)
Javascript package which uses a similar transformation to implement
generators and async functions in older versions of Javascript.
- The [regenerator](https://facebook.github.io/regenerator/) Javascript
package which uses a similar transformation to implement generators
and async functions in older versions of Javascript.

- Gabor Csardi for many interesting discussions about concurrency and
the design of coro.
- Gabor Csardi for many interesting discussions about concurrency and
the design of coro.

## Installation

Expand All @@ -320,3 +323,9 @@ Install the development version from github with:
# install.packages("devtools")
devtools::install_github("r-lib/coro", build_vignettes = TRUE)
```

## Code of Conduct

Please note that the coro project is released with a [Contributor Code
of Conduct](https://coro.r-lib.org/CODE_OF_CONDUCT.html). By
contributing to this project, you agree to abide by its terms.
14 changes: 14 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
comment: false

coverage:
status:
project:
default:
target: auto
threshold: 1%
informational: true
patch:
default:
target: auto
threshold: 1%
informational: true
15 changes: 3 additions & 12 deletions tests/testthat/helper-flowery.R
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
# Work around for `{{` blocks
# Branching is for compatibility with r-lib/testthat#1492
if ("enquo0" %in% all.names(body(expect_snapshot))) {
expect_snapshot0 <- function(expr, cran = TRUE) {
inject(
expect_snapshot(!!enquo0(expr), cran = cran)
)
}
} else {
expect_snapshot0 <- function(expr, cran = TRUE) {
expect_snapshot(!!enquo0(expr), cran = cran)
}
expect_snapshot0 <- function(expr, cran = TRUE) {
skip_on_covr()
inject(expect_snapshot(!!enquo0(expr), cran = cran))
}

expect_exhausted <- function(x) {
Expand Down

0 comments on commit a45f1f5

Please sign in to comment.