Getting started with Daeploy

daeploy
5 min readMay 5, 2021

--

Getting started with daeploy!

Daeploy is a tool created to make software deployment, primarily for Machine Learning algorithms, quick and easy for anyone who has basic knowledge of Python. It has two components: a SDK that helps you to create APIs out of Python code and a runtime manager that packages and deploys the code as web services.

In this tutorial we explain how to configure the manager, create, and deploy your first service using Daeploy. This guide gives access to a free trial of the manager, that can be used without restrictions for 12 hours before it needs to be restarted. Daeploy also offers a full free license for private and non-commercial use, that can be requested here.

  1. Installation

To use Daeploy, you need to have Python 3.6 or newer installed in your development environment and Docker in your deployment environment.

Begin by installing the Daeploy python library with pip.

$ pip install daeploy

Then, start the free trial manager container on localhost by running the following command:

$ docker run -v /var/run/docker.sock:/var/run/docker.sock -p 80:80 -p 443:443 -d daeploy/manager:latest

You can check that it started correctly by opening http://localhost/ in your browser.

This configuration should not be used in production, as it doesn’t include features like authentication and secured communication. An example of a production setup can be found in our documentation.

2. Start with your first service

Once the Manager is up and running you are ready to start using Daeploy. The easiest way to interact with the Manager is to use the Command-line Interface (CLI) that comes packaged with the SDK. The CLI contains a host of useful commands that make the deployment and monitoring of services fast and painless.

To get a list and short description of the available commands, look at the help

$ daeploy --help

Here is how the output looks like:

The screenshot of the result of daeploy — help

To get help or a longer description of any command, use

$ daeploy <COMMAND> --help

3. Logging in to the Manager

The first step is to login to the host where the manager is running. If you started the manager with the command above, your host is http://localhost. To do this, we call the daeploy login command. If the manager has authentication enabled, you will be prompted for a username and password.

$ daeploy login

We haven’t enabled the authentication for this example. So we can login without username and password. This is how it looks:

daeploy login in action

Once you have logged in, you are connected to your specified host and able to communicate with the Manager running there. Logins expire after seven days, then you’ll be prompted to login again. We can check if we are logged in by calling daeploy ls. It should return an empty list.

$ daeploy ls

Currently you don’t have any services so the output looks like this:

daeploy ls result — currently there are no service running

4. Creating a new service

When creating a new service, we recommend using a project template with daeploy init. This creates a new directory called my_project in your current working directory, which contains a fully functioning hello world service that can be deployed straight away.

Bootstrap starting a new project with daeploy init

5. Deploying a service

To deploy your service, the CLI will require you to give it a name and version and then specify the path to the project directory. Lets call our first service hello_world with version 1.0.0. The last argument, my_project is the path to the folder containing the project files.

$ daeploy deploy hello_world 1.0.0 my_project

After a few seconds, the service should be up and running. We can check with daeploy ls that it started properly. Here is the result of deploying our first service!

deploying a hello world service using daeploy CLI

If you open http://localhost in a browser you should see the dashboard where you can get much of the same information as through the CLI. And at http://localhost/services/hello_world_1.0.0/docs you can read the automated API documentation of the service and test its functionality.

The manager dashboard showing our hello_world service running.

6. Communicate with the service

The service documentation is interactive and can be used to test the API.

The service documentation provides interactive API — hello method is converted to an API.

To communicate with your services from outside the documentation you can use any HTTP library, which are available in most programming languages. In python, requests is commonly used. You can also use curl in bash or applications such as postman.

Here is an example using curl:

$curl -X 'POST' 'http://localhost/services/hello_world_1.0.0/hello'\ -H 'accept: application/json' \   
-H 'Content-Type: application/json' \
-d '{ "name": "world" }'

7. Killing a service

When you are done with a service, you can kill it with the kill command:

$ daeploy kill hello_world
Killing a service using daeploy CLI

Now that you know the basics of deploying a service using the CLI, take a look at our documentation learn how to write your own service. If you have questions, suggestions or need support, join our Daeploy Slack channel, we’re always there to help. Happy daeploying!

--

--

daeploy
daeploy

Written by daeploy

Daeploy helps you to create APIs out of your existing #python code and deploy it as web services. Get started now!

No responses yet