Skip to content

Commit

Permalink
chore: merge errors
Browse files Browse the repository at this point in the history
  • Loading branch information
0xArdi committed Nov 20, 2024
1 parent 9b2df7b commit 412f3c1
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
7 changes: 1 addition & 6 deletions run_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import os
import sys
import time
import ast
import typing as t

from dotenv import load_dotenv
Expand Down Expand Up @@ -54,10 +53,6 @@
COST_OF_BOND = 1
COST_OF_STAKING = 10**20 # 100 OLAS
COST_OF_BOND_STAKING = 5 * 10**19 # 50 OLAS
DEFAULT_TOOLS_TO_PACKAGE_HASH = None
DEFAULT_MECH_TO_SUBSCRIPTION = None
DEFAULT_MECH_TO_CONFIG = None
DEFAULT_MECH_HASH = "bafybeibx772eooap6m7cdjwfyt5pespe22i2mva24y255vw22cd5d7bfuq"


CHAIN_ID_TO_METADATA = {
Expand Down Expand Up @@ -95,7 +90,7 @@ def get_service_template(config: MechQuickstartConfig) -> ServiceTemplate:
return ServiceTemplate(
{
"name": "mech_quickstart",
"hash": "bafybeibx772eooap6m7cdjwfyt5pespe22i2mva24y255vw22cd5d7bfuq",
"hash": str(config.mech_hash),
"description": "The mech executes AI tasks requested on-chain and delivers the results to the requester.",
"image": "https://gateway.autonolas.tech/ipfs/bafybeidzpenez565d7vp7jexfrwisa2wijzx6vwcffli57buznyyqkrceq",
"service_version": "v0.1.0",
Expand Down
47 changes: 47 additions & 0 deletions utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# utils.py
import ast
import getpass
import json
import os
Expand Down Expand Up @@ -37,6 +38,10 @@

WARNING_ICON = colored("\u26A0", "yellow")
OPERATE_HOME = Path.cwd() / ".mech_quickstart"
DEFAULT_TOOLS_TO_PACKAGE_HASH = None
DEFAULT_MECH_TO_SUBSCRIPTION = None
DEFAULT_MECH_TO_CONFIG = None
DEFAULT_MECH_HASH = "bafybeibx772eooap6m7cdjwfyt5pespe22i2mva24y255vw22cd5d7bfuq"

@dataclass
class MechQuickstartConfig(LocalResource):
Expand All @@ -50,6 +55,8 @@ class MechQuickstartConfig(LocalResource):
metadata_hash: t.Optional[str] = None
agent_id: t.Optional[int] = None
mech_address: t.Optional[str] = None
tools_to_packages_hash: t.Optional[dict] = None
mech_hash: t.Optional[str] = None
home_chain_id: t.Optional[int] = None

@classmethod
Expand Down Expand Up @@ -330,6 +337,46 @@ def get_local_config() -> MechQuickstartConfig:
# TODO: default value is not a good idea here, we need to think of better ways to do this.
mech_quickstart_config.metadata_hash = input_with_default_value("Please provide the metadata hash", "f01701220caa53607238e340da63b296acab232c18a48e954f0af6ff2b835b2d93f1962f0")

if mech_quickstart_config.tools_to_packages_hash is None:
tools_to_packages_hash = (
input(
f"Do you want to set the tools_to_packages_hash dict(set to {DEFAULT_TOOLS_TO_PACKAGE_HASH})? (y/n): "
).lower()
== "y"
)
if tools_to_packages_hash:
while True:
user_input = input(f"Please enter the tools_to_packages_hash dict: ")
tools_to_packages_hash = ast.literal_eval(user_input)
if not isinstance(tools_to_packages_hash, dict):
print("Error: Please enter a valid dict.")
continue
else:
mech_quickstart_config.tools_to_packages_hash = (
tools_to_packages_hash
)
break
else:
mech_quickstart_config.tools_to_packages_hash = (
DEFAULT_TOOLS_TO_PACKAGE_HASH
)

if mech_quickstart_config.mech_hash is None:
mech_hash = (
input(
f"Do you want to set the mech_hash dict(set to {DEFAULT_MECH_HASH})? (y/n): "
).lower()
== "y"
)
if mech_hash:
while True:
user_input = input(f"Please enter the mech_hash: ")
mech_quickstart_config.mech_hash = user_input
break
else:
mech_quickstart_config.mech_hash = DEFAULT_MECH_HASH


mech_quickstart_config.store()
return mech_quickstart_config

Expand Down

0 comments on commit 412f3c1

Please sign in to comment.