When building a
dstack application, you can use your own packages and modules as well as third-party libraries.
The information on these packages, modules, and libraries must be specified within the call of the
dstack.app() function. Here's an example:
import dstack as dsfrom handlers import fake_handler# Create an instance of an application an pass over# dependencies to local modules "handlers" and "utils" and third-party packagesapp = ds.app(depends=["handlers", "utils"], requirements="requirements.txt")# The line above is equal to the line below# app = ds.app(depends=["numpy", "pandas", "faker==5.5.0", "handlers", "utils"])# An output with a handler from one of the modules the application depends onapp.output(handler=fake_handler)# Deploy the application with the name "faker" and print its URLurl = app.deploy("faker")print(url)
As you see here, we use the
requirements arguments to specify what modules, packages, and libraries the application depends on. In this case, the application depends on the module
handlers, the package
utils, and on all libraries specified in the
When you run the application the first time,
dstack makes sure all dependencies are installed on the first run.