Pushing data

dstack.ai lets you upload datasets and visualizations, and arrange them into reports and interactive dashboards.

Uploading datasets and visualization to dstack.ai is done via the dstack package available for both Python and R. These packages can be used from Jupyter notebooks, RMarkdown, Python and R scripts and applications. Learn how to install dstack package

Pushing static visualizations or datasets

Here's an example of the code that pushes a data visualization to dstack.ai:

import matplotlib.pyplot as plt
from dstack import push_frame
fig = plt.figure()
plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
push_frame("simple", fig, "My first plot")
df <- data.frame(x = c(1, 2, 3, 4), y = c(1, 4, 9, 16))
image <- ggplot(data = df, aes(x = x, y = y)) + geom_line()
push_frame("simple", image, "My first plot")

The dstack package can be used with pandas, tidyverse, matplotlib, ggplot2, bokeh and plotly. The commit and push_frame methods accept pandas.core.frame.DataFrame, data.frame, data.table, tibble, plotly.graph_objs._figure.Figure, bokeh.plotting.figure.Figure, etc.

Pushing interactive visualizations and datasets

In some cases, you want to have plots that are interactive and that can change when the user change its parameters. Suppose you want to publish a line plot that depends on the value of the parameterCoefficient:

import matplotlib.pyplot as plt
from dstack import create_frame
def line_plot(a):
xs = range(0, 21)
ys = [a * x for x in xs]
fig = plt.figure()
plt.axis([0, 20, 0, 20])
plt.plot(xs, ys)
return fig
frame = create_frame("line_plot")
coeff = [0.5, 1.0, 1.5, 2.0]
for c in coeff:
f"Line plot with the coefficient of {c}", {"Coefficient": c})
line_plot <- function(a) {
x <- c(0:20)
y <- sapply(x, function(x) { return(a * x) })
df <- data.frame(x = x, y = y)
plot <- ggplot(data = df, aes(x = x, y = y)) +
geom_line() + xlim(0, 20) + ylim(0, 20)
coeff <- c(0.5, 1.0, 1.5, 2.0)
frame <- create_frame(stack = "line_plot")
for(c in coeff) {
frame <- commit(frame, line_plot(c),
paste0("Line plot with the coefficient of ", c),
Coefficient = c)

You can have use many parameters as you want. Within one frame, you can combine different types of data: dataframes and figures.

dstack.ai tracks every submitted frame and lets you rollback between revisions via the web application if needed.

All visualizations and datasets pushed to dstack.ai follow the privacy settings specified for the registered profile. You can make all data submitted to dstack.ai either public or private. You also can change the privacy settings for individual datasets and visualizations to make them either public or private, or share them only with selected users. Learn more on sharing and collaboration

That is it. Once the data is pushed to dstack.ai, you can share it with the team or arrange into comprehensive dashboards 📈.

Using Markdown and LaTeX

Sometimes you need to have more than just text in frame description. Fortunately, dstack supports Markdown with embedded LaTeX formulas. There is an example how to use them all together:

from dstack import push_frame
import matplotlib.pyplot as plt
import numpy as np
x = np.linspace(-3, 3, 100)
y = np.exp(x)
fig = plt.figure()
plt.plot(x, y)
text = """
# Using markdown
* item1
* item2
* item3
Here is an example of $\LaTeX$ math:
$$e^x=\sum_{i=0}^\infty \\frac{1}{i!}x^i$$
It's sometimes very useful.
push_frame("exponent", fig, description=text)

Be sure that you escape all special symbols, e.g. \f in \frac. Certainly it is possible to escape all \ to be safe.