---
# System prepended metadata

title: Functions quickstart

---

# Functions quickstart 

### What are deepmux functions

DeepMux functions are serverless functions like AWS Lambda, Google Cloud Functions but with GPU support.

### What are we going to do

We are going to create a demo python funciton step-by-step with DeepMux platform.

## Make sure deepmux-cli is installed


Check out the [Installation guide](https://hackmd.io/uB5Z3Kt9QwiXtPZ1aTf98g)


## Setup project

We recommend creating your project in a separate directory. For example:
```bash
mkdir -p myproject
cd myproject
```

List function environments and choose:
```bash
deepmux env
```
We are going to use `python3.7` environment

Than initialize your project
```bash
deepmux init --name yourproject --env python3.7
```
Will create an empty function named `myproject` and `deepmux.yaml` file at your working directory.
```yaml=
name: myproject
env: python3.7
python:
  call: <required, module:function to call>
  requirements: <optional, path to requirements.txt>
```
We are going to fill those sections later.


## Implement function
Now it's time to implement the function itself.


In this example we will implement a functions that simply reverses it's input.

Create `main.py` file in project directory and fill it with following code:

Functions accept `bytes` and should return `bytes`
```python
def reverse_function(data):
    return data[::-1]

```

Let's save this function to a file `main.py` and add it as an entrypoint.

You need to open `deepmux.yaml` and add `main:reverse_function` to the `call:` section.

At this point `deepmux.yaml` would look like:
```yaml=
name: myproject
env: python3.7
python:
  call: main:reverse_function
  requirements: <optional, path to requirements.txt>
```

And the project structure should look like:

```
myproject/
myproject/deepmux.yaml
myproject/main.py
```

## Add requirements (Optional)

You can add requirements for your function. Let's say we need `numpy` package somewhere.

Write`requirements.txt` file
```txt
numpy==1.19.4
```
And add path to the file in your `deepmux.yaml`:
```yaml=
name: yourproject
env: python3.7
python:
  call: main:reverse_function
  requirements: requirements.txt
```


## Upload function

Once we've finished with function, requirements and `deepmux.yaml` we are able to upload function to the platform via cli.
```bash 
deepmux upload
```

## Run the function

You can use `deepmux list` command to get your functions and their statuses or simply check your functions via Web UI.

Once your function has finished processing and is in `READY` state you can call it with an HTTP request.

Here's an example using curl:
```
curl -X POST \
     -H "X-Token: <YOUR API TOKEN>" \
     http://api.deepmux.com/v1/function/myproject/run \
     --data "Hello!"
```
You should see the following on the screen:
```
!olleH
```
