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
```
12 changes: 12 additions & 0 deletions deployment/agent.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from eth_typing import HexAddress, HexStr
from prediction_market_agent_tooling.markets.omen.omen_subgraph_handler import OmenSubgraphHandler


def run():
# This class entails the agent logic for placing bets.
# It could call for example the main() function from the trader folder.
market_id = HexAddress(HexStr("0x57c6bab1ba758d911f11e67ef323acebcfca04b7"))
print("Started function execution")
market = OmenSubgraphHandler().get_omen_market_by_market_id(market_id)
print(f"market {market}")
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()
11 changes: 11 additions & 0 deletions deployment/remote_runner.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from modal import Image, App, Period

from deployment.agent import run

image = Image.from_registry("ghcr.io/gnosis/prediction-market-agent:main").pip_install("pydantic==2.6.1")
gabrielfior marked this conversation as resolved.
Show resolved Hide resolved

app = App(image=image)

@app.function(schedule=Period(minutes=5))
def execute_remote():
run()
Loading