Skip to main content

Tier0 adopts Marimo for easy python script usage. For example, you can train models, run SQL queries and design dashboards with data connected in Namespace.

Creating Notebooks

  1. Log in to Tier0, and then select Notebook.
No.ItemDescription
1CategoryDisplays notebooks by their status.
2Notebook TreemapLists notebooks in a folder-file hierarchical manner, you can add notebooks, refresh lists and search for notebooks.
3Details ListDisplays all notebooks of the selected folder in details.
4ImportImport notebooks.
  1. Select > New Folder.
  1. Enter a folder name and click Create.
  2. Click the created folder, and then select > New Notebook.
  1. Enter the notebook information and click Create.
  2. Click the created notebook on the right side, and start editing.
No.ItemDescription
1CategoryDisplays notebook hierarchy, data sources and dependency packages.
2CanvasLists cells in the notebook. You can select to create different types of cells, shutdown the notebook and change its settings.
3Tool BarRefreshes cells and save the notebook to different versions.
4OperationsSave the notebook. change current viewer style between cells & result, and pure result. Stop/run all cells.

Using Notebook to Run SQL Queries

  1. Log in to Tier0, and then select Notebook.

  2. Enter the added notebook, and run the default cell to connect Tier0 namespace as data sources.

  1. Add a cell, write import marimo as mo, and run it.
  1. Find the table you need on the left, click next to the table name to generate SQL statements automatically.
tip
  • You can click under DATA SOURCES on the left to add sources as needed.
  • It can happen that certain packages are missing while connecting to some types of databases. In this case, click Manage packages on the left to install.
  1. (optional) Click SQL to add a new cell, and then select a connected database to run SQL statements.

Using Notebook to Draw Charts

  1. Log in to Tier0, and then select Notebook.
  2. Create a new notebook, and then add the following 3 cells to draw a simple line chart.
  • Cell 1: Import libraries
import marimo as mo
  • Cell 2: Query data from the database
_df = mo.sql(
f"""
SELECT *
FROM "table_name"
LIMIT 100
""",
engine=tsdb_engine
)
data = _df
tip

Use a SQL cell to write queries and then click on the cell end to switch the cell to Python. Make sure you assign the query result to a variable (e.g. data).

  • Cell 3: Draw a line chart
import matplotlib.pyplot as plt

plt.figure(figsize=(10,5))
plt.plot(data["actual_runtime"])
plt.title("Actual Runtime")
plt.xlabel("Index")
plt.ylabel("actual_runtime")
plt.grid(True)
plt.show()
  1. Click at the lower-right corner to run all cells and view the chart.