Category

News

Code Coverage Tool for R Working Group Achieves First Release

By | Blog, News, R Consortium Project, R Language

by Mark Hornick, Code Coverage Working Group Leader

The “Code Coverage Tool for R” project, proposed by Oracle and approved by the R Consortium Infrastructure Steering Committee, started just over a year ago. Project goals included providing an enhanced tool that determines code coverage upon execution of a test suite, and leveraging such a tool more broadly as part of the R ecosystem.

What is code coverage?

As defined in Wikipedia, “code coverage is a measure used to describe the degree to which the source code of a program is executed when a particular test suite runs. A program with high code coverage, measured as a percentage, has had more of its source code executed during testing which suggests it has a lower chance of containing undetected software bugs compared to a program with low code coverage.”

Why code coverage?

Code coverage is an essential metric for understanding software quality. For R, developers and users alike should be able to easily see what percent of an R package’s code has been tested and the status of those tests. By knowing code is well-tested, users have greater confidence in selecting CRAN packages. Further, automating test suite execution with code coverage analysis helps ensure new package versions don’t unknowingly break existing tests and user code.

Approach and main features in release

After surveying the available code coverage tools in the R ecosystem, the working group decided to use the covr package, started by Jim Hester in December 2014, as a foundation and continue to build on its success. The working group has enhanced covr to support even more R language aspects and needed functionality, including:

  • R6 methods support
  • Address parallel code coverage
  • Enable compiling R with Intel compiler ICC
  • Enhanced documentation / vignettes
  • Provide tool for benchmarking and defining canonical test suite for covr
  • Clean up dependent package license conflicts and change covr license to GPL-3

CRAN Process

Today, code coverage is an optional part of R package development. Some package authors/maintainers provide test suites and leverage code coverage to assess code quality. As noted above, code coverage has significant benefits for the R community to help ensure correct and robust software. One of the goals of the Code Coverage project is to incorporate code coverage testing and reporting into the CRAN process. This will involve working with the R Foundation and the R community on the following points:

  • Encourage package authors and maintainers to develop, maintain, and expand test suites with their packages, and use the enhanced covr package to assess coverage
  • Enable automatic execution of provided test suites as part of the CRAN process, just as binaries of software packages are made available, test suites would be executed and code coverage computed per package
  • Display on each packages CRAN web page its code coverage results, e.g., the overall coverage percentage and a detailed report showing coverage per line of source code.

Next Steps

The working group will assess additional enhancements for covr that will benefit the R community. In addition, we plan to explore with the R Foundation the inclusion of code coverage results in the CRAN process.

Acknowledgements

The following individuals are members of the Code Coverage Working Group:

  • Shivank Agrawal
  • Chris Campbell
  • Santosh Chaudhari
  • Karl Forner
  • Jim Hester
  • Mark Hornick
  • Chen Liang
  • Willem Ligtenberg
  • Andy Nicholls
  • Vlad Sharanhovich
  • Tobias Verbeke
  • Qin Wang
  • Hadley Wickham – ISC Sponsor

Improving DBI: A Retrospect

By | Blog, News, R Consortium Project, R Language

by Kirill Müller

The “Improving DBI” project, funded by the R consortium and started about a year ago includes the definition and implementation of a testable specification for DBI and making RSQLite fully compliant to the new specification. Besides the established DBI and RSQLite packages, I have spent a lot of time on the new DBItest package. Final updates to these packages will be pushed to CRAN at the end of May. This should give downstream maintainers some time to make accommodations. The follow-up project “Establishing DBI” will focus on fully DBI-compliant backends for MySQL/MariaDB and PostgreSQL, and on minor updates to the specs where appropriate.

DBItest: Specification

The new DBItest package provides a comprehensive backend-agnostic test suite for DBI backends. When the project started, it was merely a collection of test cases. I have considerably expanded the test cases and provided a human-readable description for each, using literate programming techniques powered by roxygen2. The DBI package weaves these chunks of text to a single document that describes all test cases covered by the test suite, the textual DBI specification. This approach ensures that further updates to the specification are reflected in both the automatic tests and the text.

This package is aimed at backend implementers, who now can programmatically check with very little effort if their DBI backend conforms to the DBI specification. The verification can be integrated in the automated tests which are run as part of R’s package check mechanism in R CMD check. The odbc package, a new DBI-compliant interface to the ODBC interface, has been using DBItest from day one to enable test-driven development. The bigrquery package is another user of DBItest.

Because not all DBMS support all aspects of DBI, the DBItest package allows developers to restrict which parts of the specification are tested, and “tweak” certain aspects of the tests, e.g., the format of placeholders in parameterized queries. Adapting to other DBMS may require more work due to subtle differences in the implementation of SQL between various DBMS.

DBI: Definition

This package has been around since 2001, it defines the actual DataBase Interface in R.

I have taken over maintenance, and released versions 0.4-1, 0.5-1, and 0.6-1, with release of version 0.7 pending. The most prominent change in this package is, of course, the textual DBI specification, which is included as an HTML vignette in the package. The documentation for the various methods defined by DBI is obtained directly from the specification. These help topics are combined in a sensible order to a single, self-contained document. This format is useful for both DBI users and implementers: users can look up the behavior of a method directly from its help page, and implementers can browse a comprehensive document that describes all aspects of the interface. I have also revised the description and the examples for all help topics. Other changes include:

  • the definition of new generics dbSendStatement() and dbExecute(), for backends that distinguish between queries that return a table and statements that manipulate data,
  • the new dbWithTransaction() generic and the dbBreak() helper function, thanks Barbara Borges Ribero,
  • improved or new default implementations for methods like dbGetQuery(), dbReadTable(), dbQuoteString(), dbQuoteIdentifier(),
  • internal changes that allow methods that don’t have a meaningful return value to return silently,
  • translation of a helper function from C++ to R, to remove the dependency on Rcpp (thanks Hannes Mühleisen).

Fortunately, none of the changes seemed to have introduced any major regression issues with downstream packages. The news contain a comprehensive list of changes.

RSQLite: Implementation

RSQLite 1.1-2 is a complete rewrite of the original C implementation. Before focusing on compliance to the new DBI specification, it was important to assert compatibility to more than 100 packages on CRAN and Bioconductor that use RSQLite. These packages revealed many usage patterns that were difficult to foresee. Most of these usage patterns are supported in version 1.1-2, the more esoteric ones (such as supplying an integer where a logical is required) trigger a warning.

Several rounds of “revdep checking” were necessary before most packages showed no difference in their check output compared to the original implementation. The downstream maintainers and the Bioconductor team were very supportive, and helped spotting functional and performance regressions during the release process. Two point releases were necessary to finally achieve a stable state.

Supporting 64-bit integers also was trickier than anticipated. There is no built-in way to represent 64-bit integers in R. The bit64 package works around this limitation by using a numeric vector as storage, which also happens to use 8 bytes per element, and providing coercion functions. But when an integer column is fetched, it cannot be foreseen if a 64-bit value will occur in the result, and smaller integers must use R’s built-in integer type. For this purpose, an efficient data structure for collecting vectors, which is capable of changing the data type on the fly, has been implemented in C++. This data structure will be useful for many other DBI backends that need support for a 64-bit integer data type, and will be ported to the RKazam package in the follow-up project.

Once the DBI specification was completed, the process of making RSQLite compliant was easy: enable one of the disabled tests, fix the code, make sure all tests pass, rinse, and repeat. If you haven’t tried it, I seriously recommend test-driven development, especially when the tests are already implemented.

The upcoming release of RSQLite 2.0 will require stronger adherence to the DBI specification also from callers. Where possible, I tried to maintain backward compatibility, but in some cases breaks were inevitable because otherwise I’d have had to introduce far too many exceptions and corner cases in the DBI spec. For instance, row names are no longer included by default when writing or reading tables. The original behavior can be re-enabled by calling pkgconfig::set_config(), so that packages or scripts that rely on row names continue to work as before. (The setting is active for the duration of the session, but only for the caller that has called pkgconfig::set_config().) I’m happy to include compatibility switches for other breaking changes if necessary and desired, to achieve both adherence to the specs and compatibility with existing behavior.

A comprehensive list of changes can be found in the news.

Other bits and pieces

The RKazam package is a ready-to-use boilerplate for a DBI backend, named after the hypothetical DBMS used as example in a DBI vignette. It already “passes” all tests of the DBItest package, mostly by calling a function that skips the current test. Starting a DBI backend from scratch requires only copying and renaming the package’s code.

R has limited support for time-of-day data. The hms package aims at filling this gap. It will be useful especially in the follow-up project, because SQLite doesn’t have an intrinsic type for time-of-day data, unlike many other DBMS.

Next steps

The ensemble CRAN release of the three packages DBI, DBItest and RSQLite will occur in parallel to the startup phase for the “Establishing DBI” follow-up project. This project consists of:

  • Fully DBI compatible backends for MySQL/MariaDB and Postgres
  • A backend-agnostic C++ data structure to collect column data in the RKazam package
  • Support for spatial data

In addition, it will contain an update to the DBI specification, mostly concerning support for schemas and for querying the structure of the table returned for a query. Targeting three DBMS instead of one will help properly specify these two particularly tricky parts of DBI. I’m happy to take further feedback from users and backend implementers towards further improvement of the DBI specification.

Acknowledgments

Many thanks to the R Consortium, which has sponsored this project, and to the many contributors who have spotted problems, suggested improvements, submitted pull requests, or otherwise helped make this project a great success. In particular, I’d like to thank Hadley Wickham, who suggested the idea, supported initial development of the DBItest package, and provided helpful feedback; and Christoph Hösler, Hannes Mühleisen, Imanuel Costigan, Jim Hester, Marcel Boldt, and @thrasibule for using it and contributing to it. I enjoyed working on this project, looking forward to “Establishing DBI”!

Gordon and Betty Moore Foundation Joins R Consortium to Encourage Development, Maintenance and Distribution of R Software

By | Announcement, News

Grant is a part of the Moore Foundation’s Data-Driven Discovery Initiative to support data scientists

SAN FRANCISCO – [Jan 11, 2017, 10:00 ET] – The R Consortium, an open source foundation supporting the R user community and a Linux Foundation project, today welcomed the Gordon and Betty Moore Foundation to the Consortium as a supporting Platinum member. The Moore Foundation grant will enable the R Consortium to expand its support for the community developing, maintaining, distributing and using the R programming language.

Thousands of statisticians, analysts and scientists worldwide rely on the R language to allow them to analyze, model and visualize large, complex datasets and to create statistical software. In addition, R provides interfaces to other computing platforms, providing users with access to the best computations for understanding data. Interest in the language is growing across industries that rely on statistical computing, such as healthcare and finance, as well as newer disciplines like machine learning.

The Moore Foundation was established to create positive outcomes for future generations. In pursuit of that vision, the Foundation fosters path-breaking scientific discovery, environmental conservation, patient care improvements and preservation of the character of the San Francisco Bay Area. As part of its work to support scientific discovery, the Moore Foundation has a $60 million initiative in Data-Driven Discovery that supports new ways to effectively harness scientific datasets that are so large and complex that they require use of fundamentally different techniques and better tools. Participation in the R Consortium is a part of the Moore Foundation’s efforts to encourage progress in data science practice.

“The Moore Foundation has joined the R Consortium because we want to further the organization’s mission of supporting the R community,” said Chris Mentzel, program director of the Moore Foundation’s Data-Driven Discovery Initiative. “The R language and packages are well established and widely used, but is still incredibly dynamic due to strong community involvement and evolving needs of scientists, statisticians and many others. We believe our support will help the community continue to create technology that is freely available to all who want to leverage modern scale scientific data for new discoveries.”

Mr. Mentzel will participate in meetings of the Board of Directors and the Infrastructure Steering Committee (ISC), which provides support and technical guidance to the R community.

“We’re delighted to welcome the Moore Foundation as a member of the R Consortium,” said Louis Bajuk-Yorgan, chair of the R Consortium Board of Directors and senior director of product management, streaming and advanced analytics at TIBCO Software. “The organization’s participation will permit us to intensify our support through the Infrastructure Steering Committee for development of new projects for the benefit of the full R community.”

R Consortium ISC Accepting Proposals

The infrastructure Steering Committee is now accepting proposals for the first round of funding in 2017. The ISC is broadly interested in projects that will make a difference to the R community.

Infrastructure includes:

  • Ambitious technical projects such as R-hub, which require dedicated time to supply infrastructure that is currently missing in the R ecosystem.
  • Community projects like R-ladies and SatRdays, which help catalyze and support the growth of the R community around the world.
  • Smaller projects to develop packages similar to DBI and sf, which provide key infrastructure used by thousands of R programmers.

The deadline for submitting a proposal is midnight PST on Friday February 10, 2017. For information on the mechanics of submitting a proposal and some guidance on how to write a good proposal, see the Call for Proposals page.

About the Gordon and Betty Moore Foundation

The Gordon and Betty Moore Foundation fosters path-breaking scientific discovery, environmental conservation, patient care improvements and preservation of the special character of the Bay Area. Visit moore.org and follow @MooreFound.

About The R Consortium

The R Consortium is a 501(c)6 nonprofit organization and Linux Foundation project dedicated to the support and growth of the R user community. The R Consortium provides support to the R Foundation and to the greater R Community for projects that assist R package developers, provide documentation and training, facilitate the growth of the R Community and promote the use of the R language. For more information about R Consortium, please visit: http://www.r-consortium.org.

# # #

Media Contact:

Dan Brown
The Linux Foundation
dbrown@linuxfoundation.org

Introducing RC RUGS: R Consortium R User Group Support Program

By | Announcement, News

The R Consortium is very happy to announce RC RUGS, the R Consortium R User Group Support Program. We believe that user groups are a great strength of the R Community and we would like to do all that we can to encourage the formation of new user groups and to help existing R user groups flourish.

The 2016/2017 RC RUGS program provides financial support for R User Groups based on their size and the frequency with which they meet. “Vector” level membership, appropriate for new and small groups, comes with a grant of $150 per year. Larger, established groups that have a track record of meeting frequently may qualify for “Matrix” or “Array” level membership with respective annual grants of $500 and $1,000.

For program details, requirements for consideration, and an application form please visit the page:

Esri joins the R Consortium

By | News

In another sign of R’s push into the enterprise, leading GIS vendor Esri has joined the R Consortium, adding to a roster of tech companies that includes Microsoft, IBM, Oracle and Google.

READ MORE