Skip to content
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

Add support for dictionary overrides #750

Merged
merged 6 commits into from
Oct 3, 2024
Merged

Conversation

Adamantios
Copy link
Collaborator

Proposed changes

Adds support for dictionary overrides.

Fixes

n/a

Types of changes

What types of changes does your code introduce to agents-aea?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist

Put an x in the boxes that apply.

  • I have read the CONTRIBUTING doc
  • I am making a pull request against the develop branch (left side). Also you should start your branch off our develop.
  • Lint and unit tests pass locally with my changes and CI passes too
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that code coverage does not decrease.
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

n/a

This is a workaround to fix the types of numeric keys as they can only be represented as strings in the json overrides.
@Adamantios Adamantios added the enhancement New feature or request label Aug 9, 2024
Comment on lines +306 to +318
# this is a workaround to fix the type of numeric keys as they can only be represented as strs in the json overrides
for path in original_config:
path_as_str = tuple(map(str, path))
if path_as_str in overrides and path not in overrides:
value = overrides[path_as_str]
del overrides[path_as_str]
up_to_last_key = data
for key in path_as_str[:-1]:
up_to_last_key = up_to_last_key[key]
del up_to_last_key[path_as_str[-1]]
overrides[path] = value
vals = reduce(lambda d, key: {key: d}, reversed(path), value)
update_nested_dict(data, vals)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats this about?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checks the type of the original format in the skill.yaml and uses this for the override. The overrides can only contain str keys, but they might be int, float, bool, etc.

@Adamantios
Copy link
Collaborator Author

The tests will need to be fixed.

The new overrides format is demonstrated on valory-xyz/trader#311.
This has been tested and works when running the trader as an agent.

Additionally, breaking changes will be necessary in the open-autonomy framework to implement the corresponding feature at the service-level overrides.

@Adamantios Adamantios marked this pull request as draft August 9, 2024 14:30
@Adamantios Adamantios changed the title Add support for dictionary overrides [WIP]: Add support for dictionary overrides Aug 9, 2024
@Adamantios Adamantios force-pushed the feat/override-dicts branch 2 times, most recently from 20dd077 to abbe71f Compare August 22, 2024 13:47
@Adamantios Adamantios changed the title [WIP]: Add support for dictionary overrides Add support for dictionary overrides Aug 22, 2024
@Adamantios Adamantios marked this pull request as ready for review August 22, 2024 14:25
@Adamantios Adamantios changed the base branch from main to release/1.58.0 October 3, 2024 10:10
@Adamantios Adamantios merged commit 73f3a22 into release/1.58.0 Oct 3, 2024
35 of 36 checks passed
@Adamantios Adamantios deleted the feat/override-dicts branch October 3, 2024 10:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants