Installing and running
dstack is very easy:
pip install dstack==0.6.5dstack go
If you run it for the first time, it may take a while. Once it's done, you'll see the following output:
$ dstack goTo access the application, open this URL in the browser: http://localhost:8080/auth/verify?user=dstack&code=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx&next=/The default profile in "~/.dstack/config.yaml" is already configured. You are welcome to push your data using Python or R packages.What's next?------------- Checkout our documentation: https://docs.dstack.ai- Ask questions and share feedback: https://discord.gg/8xfhEYa- Star us on GitHub: https://github.com/dstackai/dstack
If you open the URL, you'll see the following interface:
You're logged as the
dstack user. The current page is
Applications. It shows you all published applications to which you have access. The sidebar on the left lets you open other pages:
Now let's build a simple application to see how
dstack works in action.
Here's an elementary example of using
dstack for building an application that takes stock exchange data and renders it for the company selected by the user.
In a real
dstack application, you'd use a real data source, via a connection to a database or a data warehouse. In this simple example, we'll use
plotly 's bundled dataset as the source of the data for our application. Here's how it looks like:
The first column is the date, and the others are the prices for the stock associated with the column.
Let's now see how you can use
dstack to build an application that uses this data:
import dstack as dsimport plotly.express as pxapp = ds.app() # create an instance of the application# an utility function that loads the datadef get_data():return px.data.stocks()# a drop-down control that shows stock symbolsstock = app.select(items=get_data().columns[1:].tolist())# a handler that updates the plot based on the selected stockdef output_handler(self, stock):# a plotly line chart where the X axis is date and Y is the stock's priceself.data = px.line(get_data(), x='date', y=stock.value())# a plotly chart outputapp.output(handler=output_handler, depends=[stock])# deploy the application with the name "stocks" and print its URLurl = app.deploy("stocks")print(url)
If you run this code and click the URL printed to the output, you'll see the application:
As you see, the user is prompted to choose a stock symbol to view how its price change from date to date.
Now that you've seen how easy it's to build and deploy a simple application, proceed to the Concepts page to learn in more detail about what
dstack applications consist of, and how to use all their features.
To see more advanced examples, please check out the Tutorials page.