-
Notifications
You must be signed in to change notification settings - Fork 4
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
Feat: Add quickstart scripts #690
base: staging
Are you sure you want to change the base?
Changes from 14 commits
3e6b646
e747819
5de9dcf
6faa044
dc07fdc
873f9f5
f877f0e
da4cf63
73072bc
db9f3d4
558b0d9
c5e3850
18c776a
2f9b03b
b839c5b
0e02b41
4fdff54
d6749a3
06f8692
6d13128
448edc9
4fa023c
a087719
d17616c
0d60c59
ae6e642
1f9ca73
a54b99e
e47e429
a106639
24c30b8
18e1408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,13 @@ | |
|
||
"""Constants.""" | ||
|
||
from pathlib import Path | ||
|
||
from operate.operate_types import Chain | ||
|
||
|
||
OPERATE = ".operate" | ||
OPERATE_HOME = Path.cwd() / OPERATE | ||
CONFIG = "config.json" | ||
SERVICES = "services" | ||
KEYS = "keys" | ||
|
@@ -31,12 +37,22 @@ | |
KEYS_JSON = "keys.json" | ||
DOCKER_COMPOSE_YAML = "docker-compose.yaml" | ||
SERVICE_YAML = "service.yaml" | ||
STAKED_BONDING_TOKEN = "OLAS" | ||
ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" | ||
|
||
ON_CHAIN_INTERACT_TIMEOUT = 120.0 | ||
ON_CHAIN_INTERACT_RETRIES = 40 | ||
ON_CHAIN_INTERACT_SLEEP = 3.0 | ||
|
||
HEALTH_CHECK_URL = "http://127.0.0.1:8716/healthcheck" # possible DNS issues on windows so use IP address | ||
|
||
SAFE_WEBAPP_URL = "https://app.safe.global/home?safe=gno:" | ||
TM_CONTROL_URL = "http://localhost:8080" | ||
IPFS_ADDRESS = "https://gateway.autonolas.tech/ipfs/f01701220{hash}" | ||
ZERO_ADDRESS = "0x0000000000000000000000000000000000000000" | ||
|
||
# TODO: These links may break in the future, use a more robust approach | ||
MECH_CONTRACT_JSON_URL = "https://raw.githubusercontent.com/valory-xyz/mech/refs/tags/v0.8.0/packages/valory/contracts/agent_mech/build/AgentMech.json" | ||
STAKING_TOKEN_INSTANCE_ABI_PATH = 'https://raw.githubusercontent.com/valory-xyz/trader/refs/tags/v0.23.0/packages/valory/contracts/staking_token/build/StakingToken.json' | ||
MECH_ACTIVITY_CHECKER_JSON_URL = 'https://raw.githubusercontent.com/valory-xyz/autonolas-staking-programmes/refs/heads/main/abis/0.8.25/SingleMechActivityChecker.json' | ||
SERVICE_REGISTRY_TOKEN_UTILITY_JSON_URL = "https://raw.githubusercontent.com/valory-xyz/open-autonomy/refs/tags/v0.18.4/packages/valory/contracts/service_registry_token_utility/build/ServiceRegistryTokenUtility.json" | ||
MECH_AGENT_FACTORY_JSON_URL = "https://raw.githubusercontent.com/valory-xyz/ai-registry-mech/main/abis/0.8.25/AgentFactory.json" | ||
Comment on lines
+52
to
+58
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why aren't we using the built-in framework contracts ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you mean from open-autonomy? They are not there. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -188,11 +188,18 @@ class LedgerConfig(LocalResource): | |
LedgerConfigs = t.Dict[str, LedgerConfig] | ||
|
||
|
||
class NodeConfig(TypedDict): | ||
"""Deployment node config.""" | ||
|
||
ports: t.Optional[t.Dict[t.Union[str, int], t.Dict[int, int]]] | ||
volumes: t.Optional[t.Union[t.Dict[str, str], t.Dict[t.Union[str, int], t.Dict[str, str]]]] | ||
|
||
|
||
class DeploymentConfig(TypedDict): | ||
"""Deployments template.""" | ||
|
||
volumes: t.Dict[str, str] | ||
|
||
agent: t.Optional[NodeConfig] | ||
tendermint: t.Optional[NodeConfig] | ||
|
||
class FundRequirementsTemplate(TypedDict): | ||
"""Fund requirement template.""" | ||
|
@@ -241,11 +248,13 @@ class ServiceTemplate(TypedDict, total=False): | |
"""Service template.""" | ||
|
||
name: str | ||
agent_id: int | ||
hash: str | ||
image: str | ||
description: str | ||
service_version: str | ||
home_chain: str | ||
staking_programs: t.Dict[str, str] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is the purpose of this ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. so I need you to check a service template of the quickstart There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense moving the staking program to the service template, but the staking contract addresses are per chain. I.e., let's not assume they can only be made on the home chain. |
||
configurations: ConfigurationTemplates | ||
env_variables: EnvVariables | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
import json | ||
import os | ||
import subprocess | ||
import sys | ||
from pathlib import Path | ||
from typing import TYPE_CHECKING | ||
|
||
from operate.constants import DEPLOYMENT | ||
|
||
if TYPE_CHECKING: | ||
from operate.cli import OperateApp | ||
|
||
|
||
def find_build_directory(config_file: Path, operate: "OperateApp") -> Path: | ||
"""Find the appropriate build directory of the configured service.""" | ||
with open(config_file, "r") as f: | ||
config = json.load(f) | ||
config_service_hash = config.get("hash") | ||
|
||
services = operate.service_manager()._get_all_services() | ||
for service in services: | ||
if service.hash == config_service_hash: | ||
build_dir = service.path / DEPLOYMENT | ||
if not build_dir.exists(): | ||
print(f"{config.get('name')} not deployed.") | ||
sys.exit(1) | ||
return build_dir | ||
|
||
print(f"{config.get('name')} not found.") | ||
sys.exit(1) | ||
|
||
|
||
def run_analysis(logs_dir, **kwargs): | ||
"""Run the log analysis command.""" | ||
command = [ | ||
"poetry", "run", "autonomy", "analyse", "logs", | ||
"--from-dir", logs_dir, | ||
] | ||
if kwargs.get("agent"): | ||
command.extend(["--agent", kwargs.get("agent")]) | ||
if kwargs.get("reset_db"): | ||
command.extend(["--reset-db"]) | ||
if kwargs.get("start_time"): | ||
command.extend(["--start-time", kwargs.get("start_time")]) | ||
if kwargs.get("end_time"): | ||
command.extend(["--end-time", kwargs.get("end_time")]) | ||
if kwargs.get("log_level"): | ||
command.extend(["--log-level", kwargs.get("log_level")]) | ||
if kwargs.get("period"): | ||
command.extend(["--period", kwargs.get("period")]) | ||
if kwargs.get("round"): | ||
command.extend(["--round", kwargs.get("round")]) | ||
if kwargs.get("behaviour"): | ||
command.extend(["--behaviour", kwargs.get("behaviour")]) | ||
if kwargs.get("fsm"): | ||
command.extend(["--fsm"]) | ||
if kwargs.get("include_regex"): | ||
command.extend(["--include-regex", kwargs.get("include_regex")]) | ||
if kwargs.get("exclude_regex"): | ||
command.extend(["--exclude-regex", kwargs.get("exclude_regex")]) | ||
|
||
try: | ||
subprocess.run(command, check=True) | ||
print("Analysis completed successfully.") | ||
except subprocess.CalledProcessError as e: | ||
print(f"Command failed with exit code {e.returncode}") | ||
sys.exit(e.returncode) | ||
except FileNotFoundError: | ||
print("Poetry or autonomy not found. Ensure they are installed and accessible.") | ||
sys.exit(1) | ||
|
||
|
||
def analyse_logs( | ||
operate: "OperateApp", | ||
config_path: str, | ||
**kwargs | ||
): | ||
|
||
config_file = Path(config_path) | ||
if not config_file.exists(): | ||
print(f"Config file '{config_file}' not found.") | ||
sys.exit(1) | ||
|
||
# Auto-detect the logs directory | ||
build_dir = find_build_directory(config_file, operate) | ||
logs_dir = os.path.join(build_dir, "persistent_data", "logs") | ||
if not os.path.exists(logs_dir): | ||
print(f"Logs directory '{logs_dir}' not found.") | ||
sys.exit(1) | ||
|
||
# Run the analysis | ||
run_analysis(logs_dir, **kwargs) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the removal of Path.cwd not cause any issue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OPERATE_HOME
is already defined asPath.cwd() / OPERATE
inoperate/constants.py