First pass at execution environments class [DRAFT] #357
+149
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Intent
Implement support for viewing execution environment runtimes.
Fixes #313
Approach
Implement an R6 class, following modified pattern from prior
connectapi
classes.The class includes custom
[[
and$
methods to make data properties (i.e. fields returned by Connects API) as easy as accessing methods.Create an active binding
all_runtimes
to return a data frame of all runtimes.Access "data" properties at top level.
Access other properties at top level as usual.
The print method currently includes the output of the
env$all_runtimes
active binding, since that's some of the most pertinent info.Redefining
[[
and$
for this classI initially tried an approach where each expected field had an active binding that looked up the property from
$data
. For example:However, this approach breaks extracting sub-objects, such as in the following code, which returns
NULL
:When redefining
[[
and$
, you can extract recursively as expected.Another approach I considered was explicitly creating literal fields dynamically when the object was initialized. There's nothing that stops us doing this dynamically with arbitrary fields at object initialization time, but it might be better to explicitly have fields present in a class's definition for documentation reasons.
Something seems right about having the class contain basically references to other
connectapi
objects, the data from the server, and some methods for manipulating that data — something about that seems parsimonious to me.I've been thinking about how to prevent possible name masking. Would probably make sense to check that the
$data
property does not contain any names that are in theself
environment and error if that's the case.Checklist
NEWS.md
(referencing the connected issue if necessary)?devtools::document()
?