Datapane for Teams provides a Script Runner, which allows you to deploy Jupyter Notebooks or Python scripts and run them in the cloud with parameters. This means you can generate reports in an automated fashion, in addition to creating them in your local environment.
Once you deploy your script or notebook, it can be run in three ways:
Scripts can be run with parameters entered through friendly web forms, which allows you to create interactive, self-service reporting tools for stakeholders.
Scripts can generate and update reports on a schedule, allowing you to create "live" dashboards and automated reports.
You can trigger report generation through our API, which allows you to generate reports in response to events from other tools, such as Slack and Teams, or your own product.
If you have a local Python script or notebook which creates a report using Datapane's
Report.publish method (see Creating a Report), you can deploy it to Datapane using the CLI. Let's take our COVID script from before deploy it using Datapane's CLI. The report we publish in this code will be returned to the user when they run our script using the Datapane web interface.
simple_script.pyimport pandas as pdimport altair as altimport datapane as dpdataset = pd.read_csv('https://covid.ourworldindata.org/data/owid-covid-data.csv')df = dataset.groupby(['continent', 'date'])['new_cases_smoothed_per_million'].mean().reset_index()plot = alt.Chart(df).mark_area(opacity=0.4, stroke='black').encode(x='date:T',y=alt.Y('new_cases_smoothed_per_million:Q', stack=None),color=alt.Color('continent:N', scale=alt.Scale(scheme='set1')),tooltip='continent:N').interactive().properties(width='container')dp.Report(dp.Plot(plot),dp.Table(df)).publish(name='covid_report', open=True)
To deploy it, use Datapane's CLI.
datapane script deploy --script=simple_script.py --name=covid_scriptUploaded simple_script.py to https://acme.datapane.net/leo/scripts/covid_script/
This makes your script available on your private instance, where you can share it with other users. If you send them your script, they are able to generate the report from the previous example dynamically by hitting the Run button.
Every time the script is run, it pulls new COVID data and generates a fresh report, which can be shared or embedded.
In the previous example, we are deploying a single script and providing the name and file location through command-line arguments. This works well for simple scripts, but scripts often need other configuration, such as parameter definitions, other files or folders to deploy, and Python or OS requirements.
Datapane allows you to provide a configuration file called
datapane.yaml. When you run
deploy, Datapane looks for this file automatically. Before we continue, create a project structure with the
script init command, which creates a sample
datapane.yaml and a simple script.
~/C/d/d/my-new-proj> datapane script initCreated script 'my-new-proj', edit as needed and upload~/C/d/d/my-new-proj> lsdatapane.yaml dp-script.py
We already have a script from our previous example, so we can delete the sample
dp-script.py and copy in our own. Because we're replacing the default script, we should specify the filename of our script in
datapane.yaml using the
script field. Whilst we are there, we can also choose a name.
datapane.yamlname: covid_scriptscript: simple_script.py # this could also be ipynb if it was a notebook
If we run
datapane script deploy in this directory, Datapane will deploy our code with the configuration in
datapane.yaml. Because we have given the script the same name as our previous one, this will create version 2 of
In the next section, we will explore adding parameters to your script, to enable reports to be generated dynamically based on user inputs.