Skip to content

Commit

Permalink
Merge pull request #280 from valory-xyz/chore/cleaning
Browse files Browse the repository at this point in the history
chore: clean up tox.ini and Makefile
  • Loading branch information
DavidMinarsch authored Aug 24, 2022
2 parents 29e530b + d4884bc commit 65a5a10
Show file tree
Hide file tree
Showing 21 changed files with 185 additions and 162 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ jobs:
- name: License Check
run: tox -e liccheck
- name: AEA Package Hashes Check
run: tox -e hash_check -- --timeout 60.0
run: tox -e hash-check
- name: Check package versions in documentation
run: tox -e package_version_checks
run: tox -e package-version-checks
- name: Check package dependencies
run: tox -e package_dependencies_checks
run: tox -e package-dependencies-checks
- name: Check generate protocols
run: tox -e check_generate_all_protocols
run: tox -e check-generate-all-protocols
- name: Generate Documentation
run: tox -e docs

Expand Down Expand Up @@ -189,11 +189,11 @@ jobs:
- name: Install markdown-spellcheck
run: sudo npm install -g markdown-spellcheck
- name: Check Docs links and IPFS hashes
run: tox -e check_doc_links_hashes
run: tox -e check-doc-links-hashes
- name: Check API Docs updated
run: tox -e check_api_docs
run: tox -e check-api-docs
- name: Check spelling
run: tox -e spell_check
run: tox -e spell-check

scan:
name: gitleaks
Expand Down Expand Up @@ -235,7 +235,7 @@ jobs:
pip install -e .[all]
- name: Check aea dependenices and imports
run: |
tox -e dependencies_check
tox -e dependencies-check
plugins_install_check:
continue-on-error: False
Expand Down
5 changes: 5 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,11 @@ v0
ipfsdaemon
py3.6
async
gnosis
abci
metaclass
api
gitleaks
- docs/language-agnostic-definition.md
fetchai
protocol_id
Expand Down
2 changes: 1 addition & 1 deletion HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ AEA:
- Adds check to make sure all the packages in an AEA project are listed in the `aea-config.yaml`
- Fixes a bug related to async function call on `TCPSocketProtocol`
- Updates transaction building to handle gas estimation properly
- Update `ContractConfig` class to include contract dependencies in the depedency list
- Update `ContractConfig` class to include contract dependencies in the dependency list

Docs:
- Adds missing command on the `http-echo-demo.md` doc.
Expand Down
67 changes: 17 additions & 50 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: clean
clean: clean-build clean-pyc clean-test clean-docs
clean: clean-test clean-build clean-pyc clean-docs

.PHONY: clean-build
clean-build:
Expand All @@ -9,6 +9,7 @@ clean-build:
rm -fr pip-wheel-metadata
find . -name '*.egg-info' -exec rm -fr {} +
find . -name '*.egg' -exec rm -fr {} +
find . -type d -name __pycache__ -exec rm -rv {} +
rm -fr Pipfile.lock
rm -rf plugins/*/build
rm -rf plugins/*/dist
Expand All @@ -35,42 +36,20 @@ clean-test:
rm -fr .hypothesis
rm -fr .pytest_cache
rm -fr .mypy_cache/
rm -fr input_file
rm -fr output_file
rm -fr .hypothesis/
find . -name 'log.txt' -exec rm -fr {} +
find . -name 'log.*.txt' -exec rm -fr {} +

.PHONY: lint
lint:
black aea benchmark examples packages plugins scripts tests
isort aea benchmark examples packages plugins scripts tests
flake8 aea benchmark examples packages plugins scripts tests
vulture aea scripts/whitelist.py --exclude "*_pb2.py"
darglint aea benchmark examples libs packages plugins scripts

.PHONY: pylint
pylint:
pylint -j4 aea benchmark packages scripts plugins/aea-ledger-fetchai/aea_ledger_fetchai plugins/aea-ledger-ethereum/aea_ledger_ethereum plugins/aea-ledger-cosmos/aea_ledger_cosmos plugins/aea-cli-ipfs/aea_cli_ipfs examples/*

.PHONY: static
static:
mypy aea benchmark examples --disallow-untyped-defs
mypy packages tests plugins/aea-ledger-fetchai/aea_ledger_fetchai plugins/aea-ledger-ethereum/aea_ledger_ethereum plugins/aea-ledger-cosmos/aea_ledger_cosmos plugins/aea-cli-ipfs/aea_cli_ipfs

.PHONY: package_checks
.PHONY: package-checks
package_checks:
python -m aea.cli hash all --check
python -m aea.cli hash all --packages-dir=./tests/data/packages --check
python scripts/check_package_versions_in_docs.py
python -m aea.cli check-packages
tox -e hash-check
tox -e package-version-checks
tox -e package-dependencies-checks

.PHONY: docs
docs:
mkdocs build --clean

.PHONY: common_checks
common_checks: security misc_checks lint static docs

.PHONY: test
test:
pytest -rfE plugins/aea-ledger-fetchai/tests --cov=aea_ledger_fetchai --cov-report=term --cov-report=term-missing --cov-config=.coveragerc
Expand Down Expand Up @@ -128,12 +107,7 @@ release:
v := $(shell pip -V | grep virtualenvs)

.PHONY: all-checks
all-checks:
make clean \
&& make formatters \
&& make code-checks \
&& make common-checks \
&& make security \
all-checks: clean formatters code-checks common-checks-1 common-checks-2 security

.PHONY: new_env
new_env: clean
Expand Down Expand Up @@ -191,26 +165,19 @@ security:
# update copyright headers
.PHONY: generators
generators:
tox -e fix-copyright
python -m aea.cli generate-all-protocols
python -m aea.cli generate-all-protocols tests/data/packages
python -m aea.cli hash all
python -m aea.cli hash all --packages-dir=./tests/data/packages
python scripts/generate_api_docs.py
python scripts/check_copyright_notice.py
python scripts/check_doc_ipfs_hashes.py --fix
tox -e generate-api-documentation
tox -e fix-doc-hashes

.PHONY: common-checks
.PHONY: common-checks-1
common-checks:
tox -p -e check-copyright -e hash_check -e package_dependencies_checks

.PHONY: doc-checks
doc-checks:
tox -e check_doc_links_hashes -e check_api_docs

.PHONY: copyright
copyright:
python scripts/check_copyright_notice.py
tox -p -e check-copyright -e hash_check -e package-dependencies-checks

.PHONY: check-copyright
check-copyright:
tox -e check-copyright
.PHONY: common-checks-2
common-checks-2:
tox -e check-api-docs
tox -e check-doc-links-hashes
2 changes: 1 addition & 1 deletion aea/cli/add.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def fetch_item_remote(

if get_default_remote_registry() == REMOTE_IPFS:
try:
return fetch_ipfs(item_type, item_public_id, dest_path)
return cast(Path, fetch_ipfs(item_type, item_public_id, dest_path))
except HashNotProvided:
click.echo(f"Hash was not provided for: {item_public_id}")
click.echo("Will try with http repository.")
Expand Down
2 changes: 1 addition & 1 deletion aea/cli/push.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ def push_item_ipfs(component_path: Path, public_id: PublicId) -> None:
)

ipfs_tool = IPFSTool(get_ipfs_node_multiaddr())
_, package_hash, _ = ipfs_tool.add(component_path)
_, package_hash, _ = ipfs_tool.add(str(component_path))
package_hash = to_v1(package_hash)

click.echo("Pushed component with:")
Expand Down
41 changes: 13 additions & 28 deletions docs/api/plugins/aea_ledger_ethereum/ethereum.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,11 @@ Returns multiplier value.
#### estimate`_`priority`_`fee

```python
def estimate_priority_fee(web3_object: Web3, base_fee_gwei: int,
block_number: int,
priority_fee_estimation_trigger: int,
default_priority_fee: int, fee_history_blocks: int,
fee_history_percentile: int,
priority_fee_increase_boundary: int) -> int
def estimate_priority_fee(
web3_object: Web3, base_fee_gwei: int, block_number: int,
priority_fee_estimation_trigger: int, default_priority_fee: int,
fee_history_blocks: int, fee_history_percentile: int,
priority_fee_increase_boundary: int) -> Optional[int]
```

Estimate priority fee from base fee.
Expand Down Expand Up @@ -72,7 +71,8 @@ Get the gas price strategy.
def get_gas_price_strategy_eip1559_polygon(
gas_endpoint: str,
fallback_estimate: Dict[str, Optional[int]],
speed: Optional[str] = SPEED_FAST) -> Callable[[], Dict[str, Wei]]
speed: Optional[str] = SPEED_FAST
) -> Callable[[Any, Any], Dict[str, Wei]]
```

Get the gas price strategy.
Expand Down Expand Up @@ -793,18 +793,10 @@ the contract instance
#### get`_`deploy`_`transaction

```python
def get_deploy_transaction(
contract_interface: Dict[str, str],
deployer_address: Address,
value: int = 0,
gas: Optional[int] = None,
max_fee_per_gas: Optional[int] = None,
max_priority_fee_per_gas: Optional[str] = None,
gas_price: Optional[str] = None,
gas_price_strategy: Optional[str] = None,
gas_price_strategy_extra_config: Optional[Dict] = None,
raise_on_try: bool = False,
**kwargs: Any) -> Optional[JSONLike]
def get_deploy_transaction(contract_interface: Dict[str, str],
deployer_address: Address,
raise_on_try: bool = False,
**kwargs: Any) -> Optional[JSONLike]
```

Get the transaction to deploy the smart contract.
Expand All @@ -813,13 +805,6 @@ Get the transaction to deploy the smart contract.

- `contract_interface`: the contract interface.
- `deployer_address`: The address that will deploy the contract.
- `value`: value to send to contract (in Wei)
- `gas`: the gas to be used (in Wei)
- `max_fee_per_gas`: maximum amount you’re willing to pay, inclusive of `baseFeePerGas` and `maxPriorityFeePerGas`. The difference between `maxFeePerGas` and `baseFeePerGas + maxPriorityFeePerGas` is refunded (in Wei).
- `max_priority_fee_per_gas`: the part of the fee that goes to the miner (in Wei).
- `gas_price`: the gas price (in Wei)
- `gas_price_strategy`: the gas price strategy to be used.
- `gas_price_strategy_extra_config`: extra config for gas price strategy.
- `raise_on_try`: whether the method will raise or log on error
- `kwargs`: keyword arguments

Expand Down Expand Up @@ -875,8 +860,8 @@ the call result
```python
def build_transaction(contract_instance: Any,
method_name: str,
method_args: Dict,
tx_args: Dict,
method_args: Optional[Dict[Any, Any]],
tx_args: Optional[Dict[Any, Any]],
raise_on_try: bool = False) -> Optional[JSONLike]
```

Expand Down
2 changes: 1 addition & 1 deletion docs/gym-skill.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
The AEA gym skill demonstrates how a custom Reinforcement Learning agent, that uses OpenAI's <a href="https://www.gymlibrary.ml" target="_blank">gym</a> library, may be embedded into an AEA skill and connection.
The AEA gym skill demonstrates how a custom Reinforcement Learning agent, that uses OpenAI's <a href="https://github.com/openai/gym" target="_blank">gym</a> library, may be embedded into an AEA skill and connection.

### Discussion

Expand Down
2 changes: 1 addition & 1 deletion docs/limits.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ This could be taken further, and a reduced spec version for <a href="https://mic

#### Compiled AEA

Python is not a compiled language. However, various projects attempt this, e.g. <a href="https://nuitka.net/doc/user-manual.html" target="_blank">Nuitka</a> and it would be desirable to explore how useful and practical this would be in the context of AEA.
Python is not a compiled language. However, various projects attempt this, e.g. <a href="https://github.com/Nuitka/Nuitka" target="_blank">Nuitka</a> and it would be desirable to explore how useful and practical this would be in the context of AEA.

#### DID integration

Expand Down
6 changes: 3 additions & 3 deletions examples/gym_ex/proxy/env.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def step(self, action: Action) -> Feedback:

return observation, reward, done, info

def render(self, mode="human") -> None:
def render(self, mode: str = "human") -> None:
"""
Render the environment.
Expand Down Expand Up @@ -177,7 +177,7 @@ def close(self) -> None:

self._disconnect()

def _connect(self):
def _connect(self) -> None:
"""Connect to this proxy environment. It starts a proxy agent that can interact with the framework."""
if cast(Thread, self._agent_thread).is_alive():
raise ValueError("Agent already running.")
Expand All @@ -186,7 +186,7 @@ def _connect(self):
while not self._agent.runtime.is_running: # check agent completely running
time.sleep(0.01)

def _disconnect(self):
def _disconnect(self) -> None:
"""Disconnect from this proxy environment. It stops the proxy agent and kills its thread."""
self._agent.stop()
cast(Thread, self._agent_thread).join()
Expand Down
15 changes: 11 additions & 4 deletions plugins/aea-cli-ipfs/aea_cli_ipfs/ipfs_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import signal
import subprocess # nosec
from pathlib import Path
from typing import Dict, List, Optional, Set, Tuple, cast
from typing import Dict, IO, List, Optional, Set, Tuple, cast

import ipfshttpclient # type: ignore
import requests
Expand Down Expand Up @@ -163,7 +163,11 @@ def start(self) -> None:
env=os.environ.copy(),
)
empty_outputs = 0
for stdout_line in iter(self.process.stdout.readline, ""):

if self.process.stdout is None:
raise RuntimeError("Could not start IPFS daemon.")

for stdout_line in iter(cast(IO[bytes], self.process.stdout).readline, ""):
if b"Daemon is ready" in stdout_line:
break
if stdout_line == b"":
Expand All @@ -175,7 +179,10 @@ def stop(self) -> None: # pragma: nocover
"""Terminate the ipfs daemon if it was started internally."""
if self.process is None:
return
self.process.stdout.close()

if self.process.stdout is not None:
self.process.stdout.close()

self.process.send_signal(signal.SIGTERM)
self.process.wait(timeout=30)
poll = self.process.poll()
Expand Down Expand Up @@ -207,7 +214,7 @@ def __init__(self, addr: Optional[str] = None):
if addr is None:
addr = os.environ.get("OPEN_AEA_IPFS_ADDR", DEFAULT_IPFS_URL)

_, host, *_ = resolve_addr(addr) # verify addr
_, host, *_ = resolve_addr(cast(str, addr)) # verify addr

self._addr = addr
self.is_remote = is_remote_addr(host)
Expand Down
2 changes: 1 addition & 1 deletion plugins/aea-cli-ipfs/aea_cli_ipfs/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ def fetch_ipfs(
ipfs_tool = IPFSTool(addr=DEFAULT_IPFS_URL_LOCAL)

try:
package_hash = public_id.hash
package_hash: Optional[str] = public_id.hash
except ValueError:
package_hash = (
None if remote else get_ipfs_hash_from_public_id(item_type, public_id)
Expand Down
4 changes: 2 additions & 2 deletions plugins/aea-ledger-cosmos/aea_ledger_cosmos/cosmos.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def get_event_attributes(tx_receipt: JSONLike) -> Dict:
"""
return {
i["key"]: i["value"]
for i in chain(*[i["attributes"] for i in tx_receipt["logs"][0]["events"]])
for i in chain(*[i["attributes"] for i in tx_receipt["logs"][0]["events"]]) # type: ignore
}

@classmethod
Expand Down Expand Up @@ -1307,7 +1307,7 @@ def _get_transaction(
)

# Get account and signer info for each sender
signer_infos: List[SignerInfo] = []
signer_infos: List[SignerInfo] = [] # type: ignore
sign_data: JSONLike = {}
for from_address, pub_key, sequence, account_number in zip(
from_addresses, pub_keys, sequences, account_numbers
Expand Down
Loading

0 comments on commit 65a5a10

Please sign in to comment.