diff --git a/Makefile b/Makefile index 64b7e57..6bcaf62 100644 --- a/Makefile +++ b/Makefile @@ -70,19 +70,3 @@ security: tox -p -e safety -e bandit gitleaks detect --report-format json --report-path leak_report -.PHONY: common-checks-1 -common-checks-1: - tox -p -e check-copyright -e check-hash -e check-packages - - -.PHONY: docs -docs: - mkdocs build --clean --strict - -.PHONY: test -test: - pytest -rfE tests/ --cov=open_autonomy_client --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc - find . -name ".coverage*" -not -name ".coveragerc" -exec rm -fr "{}" \; - -.PHONY: all-checks -all-checks: clean formatters code-checks security common-checks-1 diff --git a/deploy.sh b/deploy.sh index bcd6bd5..2b5b322 100755 --- a/deploy.sh +++ b/deploy.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e -export BASE_URL=https://app.propel-dev1.autonolas.tech/ +export BASE_URL=https://app.propel.staging.valory.xyz/ export CMD="propel -U $BASE_URL" export AGENT_NAME=test_agent1_2 export KEY_ID=1 @@ -20,7 +20,7 @@ for i in "agent1 3" "agent2 4" "agent3 5" "agent4 6"; do IFS=' ' read -r -a array <<< "$i" AGENT_ID=${array[0]} - KEY_ID=${array[1]} + KEY_ID=${array[1]} # check user has seats to perform agent creation $CMD seats ensure @@ -30,7 +30,7 @@ do $CMD agents ensure-deleted $AGENT_NAME # cerate agent. name has to be unique. will not allow create several agents with same name and/or key - $CMD agents create --name $AGENT_NAME --key $KEY_ID --service-ipfs-hash $IPFS_HASH --variables $VARIABLES + $CMD agents deploy --name --key $KEY_ID --service-ipfs-hash $IPFS_HASH --variables $VARIABLES # wait for deployed. but it actually started. callr restart to have clean STARTED state $CMD agents wait $AGENT_NAME DEPLOYED --timeout=120 diff --git a/propel_client/cli.py b/propel_client/cli.py index f022898..384a7eb 100644 --- a/propel_client/cli.py +++ b/propel_client/cli.py @@ -568,6 +568,42 @@ def agents_stop(obj: ClickAPPObject, name_or_id: str) -> None: print_json(agent) +@click.command(name="variables-add") +@click.pass_obj +@click.argument("name_or_id", type=str, required=True) +@click.argument("variables", type=str, required=False) +def agents_variables_add(obj: ClickAPPObject, name_or_id: str, variables: str) -> None: + """ + Add variables to agent. + + :param name_or_id: str + :param variables: str + :param obj: ClickAPPObject + """ + variables_list = variables.split(",") or [] if variables else [] + agent = obj.propel_client.agents_variables_add(name_or_id, variables_list) + print_json(agent) + + +@click.command(name="variables-remove") +@click.pass_obj +@click.argument("name_or_id", type=str, required=True) +@click.argument("variables", type=str, required=False) +def agents_variables_remove( + obj: ClickAPPObject, name_or_id: str, variables: str +) -> None: + """ + Remove variables from agent. + + :param name_or_id: str + :param variables: str + :param obj: ClickAPPObject + """ + variables_list = variables.split(",") or [] if variables else [] + agent = obj.propel_client.agents_variables_remove(name_or_id, variables_list) + print_json(agent) + + @click.command(name="delete") @click.pass_obj @click.argument("name_or_id", type=str, required=True) diff --git a/propel_client/propel.py b/propel_client/propel.py index 0329341..11a43be 100644 --- a/propel_client/propel.py +++ b/propel_client/propel.py @@ -241,7 +241,7 @@ def agents_restart(self, agent_name_or_id: Union[int, str]) -> Dict: :return: dict """ - url = self._get_url(self.API_AGENTS_LIST) + f"/{agent_name_or_id}/restart" + url = self._get_url(self.API_AGENTS_LIST) + f"/{agent_name_or_id}/restart/" response = requests.get(url, **self._get_credentials_params()) self._check_response(response) return response.json() @@ -254,11 +254,56 @@ def agents_stop(self, agent_name_or_id: Union[int, str]) -> Dict: :return: dict """ - url = self._get_url(self.API_AGENTS_LIST) + f"/{agent_name_or_id}/stop" + url = self._get_url(self.API_AGENTS_LIST) + f"/{agent_name_or_id}/stop/" response = requests.get(url, **self._get_credentials_params()) self._check_response(response) return response.json() + def agents_variables_add( + self, agent_name_or_id: Union[int, str], variables: List[str] + ) -> Dict: + """ + Add variables to agent. + + :param agent_name_or_id: str or int + :param variables: list of str + + :return: dict + """ + url = ( + self._get_url(self.API_AGENTS_LIST) + f"/{agent_name_or_id}/variables_add/" + ) + response = requests.post( + url, + json={"variables": variables}, + **self._get_credentials_params(), + allow_redirects=False, + ) + self._check_response(response) + return response.json() + + def agents_variables_remove( + self, agent_name_or_id: Union[int, str], variables: List[str] + ) -> Dict: + """ + Remove variables from agent. + + :param agent_name_or_id: str or int + :param variables: list of str + + :return: dict + """ + url = ( + self._get_url(self.API_AGENTS_LIST) + + f"/{agent_name_or_id}/variables_remove/" + ) + + response = requests.post( + url, **self._get_credentials_params(), json={"variables": variables} + ) + self._check_response(response) + return response.json() + def agents_delete(self, agent_name_or_id: Union[int, str]) -> Dict: """ Delete agent by name or id. diff --git a/tox.ini b/tox.ini index e13342d..7730800 100644 --- a/tox.ini +++ b/tox.ini @@ -16,6 +16,7 @@ deps = click==8.0.2 requests<3.0.0,>=2.28.2 pytest + poetry pytest-coverage types-requests @@ -139,7 +140,7 @@ skip_install = True deps = tomte[flake8]==0.2.3 commands = - flake8 propel_client tests + flake8 --ignore=W503 propel_client tests [testenv:mypy] skipsdist = True