The other day, after having secured a comfy corner chair in my favorite cafe, I had an exciting idea: What if you would apply the agile programming methodology to the burgeoning field of data science?

What had occurred to me was that none of the data science projects I have been involved with over the past years had started out with a solidly engineered normalized and referentially constrained database schema to store the data and with an algorithm of equally thorough design to perform analyses on them. Rather, there had always been a simple, functional prototype at the outset, say, a spreadsheet with macros from a domain expert or a CSV file and a script from an IT expert. As the project evolved, over many iterations, and often with a growing team in which domain and IT experts joined forces, the data set and the analysis algorithm had grown more sophisticated, and so had the tools and technologies that were applied in the process.

To conceptualize this workflow in terms of the agile software development framework with its focus on working code and iterative change in cross functional teams seemed like a very appealing idea to me; in fact, I realized that, having worked in agile developer teams for years, I had intuitively managed my data science projects the “agile way”.

It did not take long to find out that I was not the first to have this idea. On the contrary, “agile data” seems to be actually quite hip these days, with a dedicated web site and a whole book devoted to agile data science. Fascinated, I embarked on a survey of the available web resources on this topic; I was particularly curious to learn which tools the other practitioners of agile data science are using.

Not surprizingly, most of the agile data science folks seem to follow the established best practices of the general data sciences field and subscribe to the Hadoop ecosystem. However, I was pleased to see that a number of agile data scientists have, like myself, put KNIME, an Open Source data workflow analytics platform, at the center of their data analysis environment (see this article for a good introduction).

In my experience, KNIME is uniquely positioned for large data science projects because it allows all members of the team, IT and domain experts alike, to work together within the same environment. The IT experts can provide access to structured data using the database connector or, preferably, a web service[1], and the domain experts can choose from a huge collection of data manipulation, analytics and visualization nodes to generate the results they are looking for. There is also the option to delegate more complex or computationally expensive processing steps to R or Python, the two most widely used languages by data scientists. Finally, KNIME also offers a number of ways of scaling out to cope with large data volumes, including a (commercial) connector to Hadoop/HDFS file systems through Hive.

It seems almost as a contradiction to the spirit of the agile method to argue that all members of an agile data science team should use one particular tool – after all, the Agile Manifesto tells us to value “Individuals and interactions over Processes and tools”. However, KNIME is not so much a tool as an integration platform that gives you enormous freedom with regard to how you get the job done while making it transparent to everybody in the team what happens to the data at every step in the workflow. It is this combination of flexibility and transparency that makes KNIME such a great platform for agile data science projects.

To conclude, it was very revealing to me to re-frame my thinking about data science projects in terms of the agile programming paradigm and I am eager to apply these insights to my next KNIME project.

Footnotes    (↵ returns to text)
  1. Also see this blog post on using KNIME and REST for Life Sciences Discovery Informatics applications.

Many Life Sciences Discovery Informatics applications have to deal with some unpleasant combination of high data volume, high data velocity, and high data variety – the classic “3Vs of Big Data”. While applications that combine high values for all three Vs are rare in the Life Sciences – High-Content Screening (HCS) and Next-Generation Sequencing (NGS) come to mind – you can always rely on your input data to be variable, either in terms of the input formatting, or in terms of of the input data structures, or both. Moreover, in the vast majority of cases the data volume is too large to be handled properly with a collection Excel files, so a robust IT infrastructure for storing and validating the incoming data is required. In short, the average Life Sciences Discovery Informatics application needs to be very nimble and very robust at the same time.

In this post, I want to outline an application architecture that fits this bill exceptionally well – namely, the combination of KNIME with a RESTful server.

KNIME and REST

KNIME is a powerful and extensible platform for data analytics based on the concept of data analysis workflows where data flows (mostly) in tables from one data processing node to the next. With a vibrant and rapidly growing community built around its Open Source development model, the KNIME platform now offers more than 1000 different processing nodes from a wide variety of data analytics disciplines such as text processing, network analysis, and cheminformatics.

The typical KNIME workflow follows an “Extract, Transform, and View” approach, i.e., data is extracted from various sources, processed through some fancy analysis algorithm, and then visualized, often in an interactive and iterative fashion. Less common, but equally easy to do with KNIME, are workflows that follow the widely known “Extract, Transform, and Load” (ETL) approach where the result data from the analysis are pushed back into storage for subsequent reporting, possibly in an entirely automated cycle.

With a classical relational database backend, the “Load” part of the ETL cycle in KNIME is typically implemented using the builtin database connection nodes to perform appropriate database inserts. However, accessing the database layer directly is notoriously brittle (think schema changes) and is also not looked kindly upon in corporate environments (think end users editing INSERT statements). A more elegant, robust and safe approach is to wrap the load operation in a web service and submit the data from KNIME through a web service call – and this is where REST enters the picture.

In recent years, REST has become ubiquitous as the architecture of choice for web applications. Key to this phenomenal success are the concept of URL-addressable resources, the statelessness and uniform interface of all client-server interactions, and hypermedia. Portal sites like Mashape and companies like Apigee are among the most visible examples for this new paradigm of web application development.

Example application

I would like to illustrate what the KNIME & REST dream team can do with a simple application that allows KNIME users to execute arbitrary command line tools remotely in a convenient and secure fashion. This is only meant to show the basics of what a KNIME and REST based application architecture can do and it deliberately skips many of the implementation and installation details; please refer to the links in the footnotes for further information.

The REST service for the remote command execution application is called “telex” (short for “tele-execution” [1]). It exposes only two top-level resources, a ShellCommandDefinition resource and a ShellCommand resource. A new shell command definition is created with a POST request to the ShellCommandDefinition resource. If the telex server runs at http://telex in your local network, the POST request would go to http://telex/shell-command-definitions with the following JSON request body [2]:

The server responds with a HTTP 201 Created message and sends a representation of the newly created command in the body of the response.

The echo command takes a single parameter, the text to be echoed. To create a parameter definition for this parameter, we next perform a POST request to the nested ParameterDefinition resource at http://telex/shell-command-definitions/echo/parameter-definitions with this JSON request body:

Again, the server acknowledges the creation of the parameter definition resource with a HTTP 201 Created response.

With the echo command now operational, to run it we perform one more POST, this time to the Commands resource at http://telex/shell-commands with this JSON request body:

Once the command finished, the server returns the new ShellCommand resource containing the exit code of the program in the exit_code attribute, the output captured from stdout in the output_string attribute and the output captured from stderr in the error_string attribute [3]. Note that the ShellCommand resource gives you a complete record of who issued which command at what time, including parameters and output, which can come in very handy the next time you are trying to run the same command (and can be queried any time with a simple GET request).

To perform these REST operations in KNIME, we use the KREST extension from the trusted KNIME community site [4]. A simple workflow for the interactions with the telex server described above could look like this:

telex_workflow_tc

The user specifies the base URL of the telex service with the String Input node at the top and then composes the tables needed to generate the JSON representations for the desired command and parameter definitions using Table Creator nodes.

Manually entering data using the Table Creator node is not very user friendly, as the column names in the table must exactly match the attribute names in the resulting JSON representation [5]. To simplify this task, I wrote the Assisted Table Creator (ATC) node [6], which uses a RGG template to assist the user with a dialog for entering the parameter data. An RGG template is a simple text file; for example, the template for submitting an echo command as shown above looks like this:

During node configuration, this template is then translated to the following – very simple – data entry dialog:

Screen Shot 2014-10-18 at 17.46.28

Once the dialog is closed, the output table is generated which in turn can be converted to JSON and submitted to the telex server as in the example above.

But wait, there is more: With the RGG plugin for the telex server, you don’t even have to write these templates – they will be generated automatically for all telex commands. Technically, the RGG plugin just adds a new renderer which knows how to convert ShellCommandDefinition member resources into RGG templates. Once the plugin is installed, all it takes to make the telex commands available as auto-generated RGG templates in KNIME is to add the URL http://telex/shell-command-definitions/@@rgg in the preferences dialog of the Assisted Table Creator node [7].

The shell command execution API that the telex server provides is a very simple example demonstrating the power and versatility of combining a REST API with KNIME. Of course, the concept of passing parameters collected with an RGG template in KNIME as JSON payload can easily be transferred to calls into your own application server’s REST API. For the adventurous, the telex server also provides RestCommandDefinition and RestCommand resources that allow you to define and execute such REST calls just like calls to shell commands. In such a setup, the telex server can act as a portal to well defined REST services for your KNIME users, all conveniently configurable through auto-generated RGG templates.

I better stop now to keep this short; hopefully, this overview has sparked your interest in teaming up KNIME and REST to solve complex discovery informatics problems!

Footnotes    (↵ returns to text)
  1. The service was implemented as an everest application and is available here.
  2. The __jsonclass__ attribute is used internally by the telex server to infer the class of the POSTed object (“class hinting”).
  3. In the interest of brevity, I will skip discussing issues of error handling and timeouts with non-terminating commands here.
  4. The KREST nodes were developed at Cenix BioScience during a research project funded by the EU and the German Federal Ministry of Education and Research (BMBF).
  5. This includes a number of columns for internal use by the telex server such as the __jsonclass__ fields and dotted column names for nested attributes.
  6. This node is based on the excellent MPI scripting nodes and is available from this Eclipse update site.
  7. Provided you have the telex server including the RGG plugin and the ATC node set up, you can play with the workflow shown above after downloading it here.