I want to cover a topic I was SUPER intimidated by and never exposed to but now have come to love very much - unit tests! I’m going to explain the families or suites of unit tests we use in TidyBlocks rather than speak in abstractions. That way, if you want to add a new function or embelish on an existing block, you’ll have an outlined workflow for how to add the proper testing to make sure your code is doing what you think it should.
Dragging the colors dataset block into the workspace and hitting run produces a table in the bottom right corner. This only requires three user movements: a click, a drag and drop, and another click. We can leverage these three movements to understand the basic architecture of how a pipeline of blocks within TidyBlocks runs.
In my post laying out how blockly works, you have block code to design a block (the data block is yellow and doesn’t accept inputs, for example) and behind the scenes you have the block’s generator code.
The TidyBlocks project is open source - meaning I’d love for people to contribute! I’ve posted in abstractions in order to solidify a mental model of how blockly works, but I want to make this more concrete with an example. In this post I will outline the architecture of the TidyBlocks repository by walking you through all the files needed to:
Once I had a conceptual framework of blocks in place I could hit the ground running creating blocks that would simulate functions in dplyr.
DATA First off was a data set block. I created a block with a cap because data blocks shouldn’t have any inputs. The generator code was as simple as it only needs to return iris.
Let’s not demean getting a simple UI together with a dataframe that dynamically updated when you hit the run button!
A book is organized into chapters, a good program is divided into modules. In my blockly big picture post I used an inelegant hack within the CreateDataSet block to include the stringified class code into the block itself.
Where We’re Heading Simulating Blocks OUR MISSION We’re going to simulate 3 blocks:
CreateDataSet a dataset block that contains data (the number 0) IncrementDataSet an intermediate transformation block (a step function to increase the data by 1) DisplayDataSet a display block (a pop up alert of our new value).
I spent the beginning of the week pouring over the Blockly documentation which is sparse, at best. The Google team does a great job of explaining how to create a single block, but I struggled to create a big picture of how blocks interact.
After arranging a call with whom I thought was a developer of Blockly, Beka turned out to be an incredibly knowledgeable and driven high school student!
The end goal of the internship is obvious: a working proof of concept where I envision each block as a step in a chain of Tidy functions.
Before I officially begin my internship with RStudio, I’m familiarizing myself with data-forge.js the package. Created by Ashley Davis, data-forge transforms dataframes by stringing together functions like you would in R with pipes. I’ll be keeping a table here (and creating a third column with blocks!) as my internship progresses
tidyverse Data-Forge select .subset(["Some-Column", "Some-Other-Column"]); filter .where(row = row.