Skip to content

Commit

Permalink
chore: remove config error and add deprecation warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jrriehl committed Jul 19, 2023
1 parent 48c363c commit d715dd5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
20 changes: 12 additions & 8 deletions src/uagents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
)
from uagents.mailbox import MailboxClient
from uagents.config import (
ConfigurationError,
CONTRACT_ALMANAC,
REGISTRATION_FEE,
REGISTRATION_DENOM,
Expand Down Expand Up @@ -87,13 +86,17 @@ def __init__(
self._endpoints = parse_endpoint_config(endpoint)
self._use_mailbox = False

# agentverse config overrides mailbox config
# but mailbox is kept for backwards compatibility
if agentverse and mailbox:
raise ConfigurationError(
"Cannot specify both agentverse and mailbox configuration"
if mailbox:
# agentverse config overrides mailbox config
# but mailbox is kept for backwards compatibility
if agentverse:
self._logger.warning(
"Ignoring the provided 'mailbox' configuration since 'agentverse' overrides it"
)
self._logger.warning(
"Then 'mailbox' configuration is deprecated in favor of 'agentverse'"
)
agentverse = mailbox if agentverse is None else agentverse
agentverse = mailbox
self._agentverse = parse_agentverse_config(agentverse)
self._use_mailbox = self._agentverse["use_mailbox"]
if self._use_mailbox:
Expand Down Expand Up @@ -373,7 +376,8 @@ def include(self, protocol: Protocol, publish_manifest: Optional[bool] = False):
def publish_manifest(self, manifest: Dict[str, Any]):
try:
resp = requests.post(
f"{self._agentverse['http_prefix']}://{self._agentverse['base_url']}/v1/almanac/manifests",
f"{self._agentverse['http_prefix']}://{self._agentverse['base_url']}"
+ "/v1/almanac/manifests",
json=manifest,
timeout=5,
)
Expand Down
4 changes: 0 additions & 4 deletions src/uagents/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,6 @@ class AgentNetwork(Enum):
DEFAULT_ENVELOPE_TIMEOUT_SECONDS = 30


class ConfigurationError(Exception):
pass


def parse_endpoint_config(
endpoint: Optional[Union[str, List[str], Dict[str, dict]]]
) -> List[Dict[str, Any]]:
Expand Down

0 comments on commit d715dd5

Please sign in to comment.