Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added deployment option for hackathon participants #2

Closed
wants to merge 12 commits into from
29 changes: 29 additions & 0 deletions deployment/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Deployment of agents

This folder contains scripts for quickly deploying your agent to a cloud provider (Modal) and have it executed on a cron schedule. Additionally, a local setup is also provided.

## Pre-requisites

We suggest using Modal (modal.com) for deploying the agents for its simplicity. We don't use Modal in production.

For deploying on Modal, follow the steps below:
- Create account (https://modal.com/)
- Install modal, setup auth key
- Run
```bash
pip install modal
python3 -m modal setup
```

## Run locally

```shell
modal run deployment/local_runner.py
```

## Run on the cloud

- Run
```shell
modal deploy --name execute_agent deployment/remote_runner.py
```
7 changes: 7 additions & 0 deletions deployment/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from trader.main import main as trader_main

def run():
# Calls the trader agent for placing bets.
print("Started function execution")
trader_main()
print("Finished function execution")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is everything pushed to this PR? This doesn't initialize any agent nor places bets

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now I reference the main function from the trader folder.

15 changes: 15 additions & 0 deletions deployment/local_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import modal

from deployment.agent import run

app = modal.App("example-get-started")


@app.function()
def execute():
run()


@app.local_entrypoint()
def main():
execute.local()
20 changes: 20 additions & 0 deletions deployment/remote_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import os
import pathlib

from modal import Image, App, Period
from modal.secret import Secret

from deployment.agent import run

# Loading env and poetry files
dir_path = os.path.dirname(os.path.realpath(__file__))
path_to_pyproject_toml = pathlib.Path(dir_path).parent.joinpath("pyproject.toml")
path_to_env = pathlib.Path(dir_path).parent.joinpath(".env")

image = Image.debian_slim().poetry_install_from_file(poetry_pyproject_toml=path_to_pyproject_toml.as_posix())

app = App(image=image)

@app.function(schedule=Period(minutes=5),secrets=[Secret.from_dotenv(path_to_env.as_posix())])
def execute_remote():
run()
Loading