Skip to content

Commit

Permalink
entrypoint_function_name variable for GCP (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
kongzii authored Feb 20, 2024
1 parent 4908f23 commit 625bfb3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion prediction_market_agent_tooling/deploy/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,13 +75,14 @@ def deploy_gcp(
) -> None:
path_to_agent_file = os.path.relpath(inspect.getfile(self.__class__))

entrypoint_function_name = "main"
entrypoint_template = f"""
from {path_to_agent_file.replace("/", ".").replace(".py", "")} import *
import functions_framework
from prediction_market_agent_tooling.markets.markets import MarketType
@functions_framework.http
def main(request) -> str:
def {entrypoint_function_name}(request) -> str:
{self.__class__.__name__}().run(market_type={market_type.__class__.__name__}.{market_type.name})
return "Success"
"""
Expand All @@ -101,6 +102,7 @@ def main(request) -> str:
env_vars=env_vars,
secrets=secrets,
memory=memory,
entrypoint_function_name=entrypoint_function_name,
)

# Check that the function is deployed
Expand Down
3 changes: 2 additions & 1 deletion prediction_market_agent_tooling/deploy/gcp/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def deploy_to_gcp(
env_vars: dict[str, str] | None,
secrets: dict[str, str] | None,
memory: int, # in MB
entrypoint_function_name: str,
) -> str:
if requirements_file and not os.path.exists(requirements_file):
raise ValueError(f"File {requirements_file} does not exist")
Expand Down Expand Up @@ -63,7 +64,7 @@ def deploy_to_gcp(
cmd = gcloud_deploy_cmd(
gcp_function_name=gcp_fname,
source=tempdir,
entry_point="main", # TODO check this function exists in main.py
entry_point=entrypoint_function_name,
labels=labels,
env_vars=env_vars,
secrets=secrets,
Expand Down

0 comments on commit 625bfb3

Please sign in to comment.