-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
91 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Docker specific ignores: | ||
.git | ||
|
||
# .gitignore ignores: | ||
.env | ||
.agents_workspace | ||
.cache | ||
__pycache__ | ||
*.egg-info | ||
logs | ||
.mypy_cache | ||
.pytest_cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,3 @@ | ||
requirements.txt | ||
.venv | ||
.env | ||
.agents_workspace | ||
.cache | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Install Poetry and create venv in the builder step, | ||
# then copy the venv to the runtime image, so that the runtime image is as small as possible. | ||
FROM --platform=linux/amd64 python:3.10.14-slim-bookworm AS builder | ||
|
||
RUN pip install poetry==1.8.2 | ||
|
||
ENV POETRY_NO_INTERACTION=1 \ | ||
POETRY_VIRTUALENVS_IN_PROJECT=1 \ | ||
POETRY_VIRTUALENVS_CREATE=1 \ | ||
POETRY_CACHE_DIR=/tmp/poetry_cache | ||
|
||
WORKDIR /app | ||
|
||
COPY pyproject.toml poetry.lock ./ | ||
|
||
RUN --mount=type=cache,target=$POETRY_CACHE_DIR poetry install --no-root --only main | ||
|
||
FROM --platform=linux/amd64 python:3.10.14-slim-bookworm AS runtime | ||
|
||
ENV VIRTUAL_ENV=/app/.venv \ | ||
PATH="/app/.venv/bin:$PATH" | ||
|
||
WORKDIR /app | ||
|
||
COPY --from=builder ${VIRTUAL_ENV} ${VIRTUAL_ENV} | ||
|
||
COPY prediction_market_agent ./prediction_market_agent | ||
|
||
ENV PYTHONPATH=/app | ||
|
||
CMD ["bash", "-c", "python prediction_market_agent/run_agent.py ${runnable_agent_name} ${market_type}"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
# TODO: This should be automated as part of CI/CD pipeline, but for now, execute it locally on the main branch. | ||
docker build . -t ghcr.io/gnosis/pma:latest && docker push ghcr.io/gnosis/pma:latest |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import random | ||
import typing as t | ||
|
||
from prediction_market_agent_tooling.deploy.agent import DeployableAgent | ||
from prediction_market_agent_tooling.markets.agent_market import AgentMarket | ||
|
||
|
||
class DeployableCoinFlipAgent(DeployableAgent): | ||
def pick_markets(self, markets: t.Sequence[AgentMarket]) -> t.Sequence[AgentMarket]: | ||
return random.sample(markets, 1) | ||
|
||
def answer_binary_market(self, market: AgentMarket) -> bool | None: | ||
return random.choice([True, False]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
""" | ||
Entrypoint for running the agent in GKE. | ||
If the agent adheres to PMAT standard (subclasses DeployableAgent), | ||
simply add the agent to the `RunnableAgent` enum and then `RUNNABLE_AGENTS` dict. | ||
Can also be executed locally, simply by running `python prediction_market_agent/run_agent.py <agent> <market_type>`. | ||
""" | ||
|
||
from enum import Enum | ||
|
||
import typer | ||
from prediction_market_agent_tooling.markets.markets import MarketType | ||
|
||
from prediction_market_agent.agents.coinflip_agent.deploy import DeployableCoinFlipAgent | ||
|
||
|
||
class RunnableAgent(str, Enum): | ||
coinflip = "coinflip" | ||
|
||
|
||
RUNNABLE_AGENTS = { | ||
RunnableAgent.coinflip: DeployableCoinFlipAgent, | ||
} | ||
|
||
|
||
def main(agent: RunnableAgent, market_type: MarketType) -> None: | ||
RUNNABLE_AGENTS[agent]().run(market_type) | ||
|
||
|
||
if __name__ == "__main__": | ||
typer.run(main) |