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

AEA-1189 Crypto plug-in mechanism #2112

Merged
merged 70 commits into from
Feb 22, 2021
Merged

Conversation

marcofavorito
Copy link
Contributor

Proposed changes

This PR introduces the plug-in mechanism proposed in #1229 for Cryptos.

Fixes

Addresses #1229

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
  • 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 checked that the documentation about the aea cli tool works
  • I have added necessary documentation (if appropriate)
  • Any dependent changes have been merged and published in downstream modules

Further comments

n/a

aea/__init__.py Outdated Show resolved Hide resolved
aea/crypto/plugin.py Outdated Show resolved Hide resolved
@codecov-io
Copy link

codecov-io commented Jan 5, 2021

Codecov Report

Merging #2112 (3d5e391) into develop (97b9a15) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           develop     #2112    +/-   ##
==========================================
  Coverage   100.00%   100.00%            
==========================================
  Files          301       299     -2     
  Lines        24240     23578   -662     
==========================================
- Hits         24240     23578   -662     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
aea/aea_builder.py 100.00% <ø> (ø)
aea/cli/utils/package_utils.py 100.00% <100.00%> (ø)
aea/configurations/constants.py 100.00% <100.00%> (ø)
aea/crypto/__init__.py 100.00% <100.00%> (ø)
aea/crypto/ledger_apis.py 100.00% <100.00%> (ø)
aea/crypto/plugin.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 97b9a15...6fa801e. Read the comment docs.

Error: "There are no .py[i] files in directory 'plugins'"
Copy link
Contributor

@DavidMinarsch DavidMinarsch left a comment

Choose a reason for hiding this comment

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

The tests should be collocated to the plugins

aea/crypto/ledger_apis.py Outdated Show resolved Hide resolved
benchmark/framework/aea_test_wrapper.py Outdated Show resolved Hide resolved
docs/build-aea-programmatically.md Outdated Show resolved Hide resolved
examples/crypto_ex/README.md Outdated Show resolved Hide resolved
examples/crypto_ex/my_crypto/__init__.py Outdated Show resolved Hide resolved
plugins/fetchai-crypto/setup.py Outdated Show resolved Hide resolved
scripts/whitelist.py Show resolved Hide resolved
setup.cfg Outdated Show resolved Hide resolved
setup.py Outdated Show resolved Hide resolved
.github/workflows/workflow.yml Outdated Show resolved Hide resolved
@DavidMinarsch DavidMinarsch changed the title Crypto plug-in mechanism AEA-1189 Crypto plug-in mechanism Jan 16, 2021
Comment on lines +72 to +101
[plugins]
commands =
python -m pip install --no-deps file://{toxinidir}/plugins/aea-crypto-ethereum
python -m pip install --no-deps file://{toxinidir}/plugins/aea-crypto-cosmos
python -m pip install --no-deps file://{toxinidir}/plugins/aea-crypto-fetchai
pytest -rfE plugins/aea-crypto-fetchai/tests --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov=aea_crypto_fetchai --cov-config=.coveragerc --suppress-no-test-exit-code {posargs}
pytest -rfE plugins/aea-crypto-ethereum/tests --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov=aea_crypto_ethereum --cov-config=.coveragerc --suppress-no-test-exit-code {posargs}
pytest -rfE plugins/aea-crypto-cosmos/tests --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov=aea_crypto_cosmos --cov-config=.coveragerc --suppress-no-test-exit-code {posargs}

[testenv:plugins-py3.6]
basepython = python3.6
commands = {[plugins]commands}

[testenv:plugins-py3.7]
basepython = python3.7
commands = {[plugins]commands}

[testenv:plugins-py3.7-cov]
basepython = python3.7
usedevelop = True
commands = {[plugins]commands}

[testenv:plugins-py3.8]
basepython = python3.8
commands = {[plugins]commands}

[testenv:plugins-py3.9]
basepython = python3.9
commands = {[plugins]commands}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I feel this might still be improved, as the "main testenv" above, still good enough.

@@ -356,6 +356,9 @@ jobs:
name: Unit tests
run: |
tox -e py${{ matrix.python_version }} -- -m 'not integration and not unstable'
- name: Plugin tests
run: |
tox -e plugins-py${{ matrix.python_version }} -- --cov-append -m 'not integration and not unstable'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

note --cov-append. An alternative is to generate different coverage file for each plugin and then merge with coverage combine:

https://coverage.readthedocs.io/en/latest/cmd.html#cmd-combine

run: tox -e py3.7-cov -- --ignore=tests/test_docs --ignore=tests/test_examples --ignore=tests/test_packages/test_contracts --ignore=tests/test_packages/test_skills_integration -m 'not unstable'
run:
tox -e py3.7-cov -- --ignore=tests/test_docs --ignore=tests/test_examples --ignore=tests/test_packages/test_contracts --ignore=tests/test_packages/test_skills_integration -m 'not unstable'
tox -e py3.7-cov -- --cov-append -m 'not unstable'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

see --cov-append

@marcofavorito marcofavorito marked this pull request as ready for review February 22, 2021 14:36
@@ -0,0 +1,201 @@
Apache License
Version 2.0, January 2004
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we not point to root license from Manifest file?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

but we could add a check that make sure the LICENSE is the same

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok, let's worry about these checks separately (new PR)...there are a few more

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 8af620f

# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
#
# Copyright 2018-2019 Fetch.AI Limited
Copy link
Contributor

@DavidMinarsch DavidMinarsch Feb 22, 2021

Choose a reason for hiding this comment

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

Why does this not show relative changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we have another file in tests/test_crypto/test_ethereum.py.

Copy link
Contributor

Choose a reason for hiding this comment

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

What's in the other one? Why is not everything here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

a test on an ethereum contract

Comment on lines +41 to +42
; because we use --no-deps to install the plugins.
; aea_crypto_cosmos/aea_crypto_fetchai
Copy link
Contributor

Choose a reason for hiding this comment

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

Why the no deps install?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

because we want to test the plugins with the aea on develop (installed by tox during env setup), not from PyPI.

Copy link
Contributor

Choose a reason for hiding this comment

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

True that!

@@ -25,22 +25,16 @@
from unittest.mock import MagicMock, patch
Copy link
Contributor Author

@marcofavorito marcofavorito Feb 22, 2021

Choose a reason for hiding this comment

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

@DavidMinarsch now diffs work :-)

Copy link
Contributor

@solarw solarw left a comment

Choose a reason for hiding this comment

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

Why do we have mentions of the crypto plugins as constants in aea?
Do we need to load all the plugins on aea module load?

@@ -100,6 +105,7 @@ jobs:
sudo apt-get autoremove
sudo apt-get autoclean
pip install tox
pip install --user --upgrade setuptools
Copy link
Contributor

Choose a reason for hiding this comment

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

pip and setuptools always show a warning that can be updated.

Copy link
Contributor

@DavidMinarsch DavidMinarsch left a comment

Choose a reason for hiding this comment

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

LGTM

in workflow, coverage_checks:

- missing '|'
- plugin-py3.7-cov test environment should have been called, instead of py3.7-cov.
@DavidMinarsch DavidMinarsch merged commit 29b8dee into develop Feb 22, 2021
marcofavorito added a commit that referenced this pull request Feb 24, 2021
- add instructions regarding the 'dependencies' field in 'aea-config.yaml';
- add instructions regarding crypto plug-ins.
DavidMinarsch added a commit that referenced this pull request Feb 24, 2021
DavidMinarsch added a commit that referenced this pull request Feb 24, 2021
AEA-1189 Fixes to Crypto plugin PR #2112
@DavidMinarsch DavidMinarsch deleted the feature/crypto-plugin branch February 25, 2021 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants