From 385e536097b5de55f329074db34ce4f3f4ccc595 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 24 Jul 2024 18:27:43 +0300 Subject: [PATCH 1/5] refactor: create reusable parameter for the path to storage --- run_service.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/run_service.sh b/run_service.sh index 77d3ca7d..05d9a962 100755 --- a/run_service.sh +++ b/run_service.sh @@ -210,9 +210,9 @@ get_private_key() { # Function to warm start the policy warm_start() { - echo '["prediction-online", "prediction-online-sme", "prediction-online-summarized-info", "prediction-sentence-embedding-bold", "prediction-sentence-embedding-conservative"]' | sudo tee "$PWD/../$store/available_tools_store.json" > /dev/null - echo '{"counts": [0,0,0,0,0], "eps": 0.1, "rewards": [0.0,0.0,0.0,0.0,0.0]}' | sudo tee "$PWD/../$store/policy_store.json" > /dev/null - echo '{}' | sudo tee "$PWD/../$store/utilized_tools.json" > /dev/null + echo '["prediction-online", "prediction-online-sme", "prediction-online-summarized-info", "prediction-sentence-embedding-bold", "prediction-sentence-embedding-conservative"]' | sudo tee "${path_to_store}available_tools_store.json" > /dev/null + echo '{"counts": [0,0,0,0,0], "eps": 0.1, "rewards": [0.0,0.0,0.0,0.0,0.0]}' | sudo tee "${path_to_store}policy_store.json" > /dev/null + echo '{}' | sudo tee "${path_to_store}utilized_tools.json" > /dev/null } # Function to add a volume to a service in a Docker Compose file @@ -463,6 +463,7 @@ dotenv_set_key() { store=".trader_runner" +path_to_store="$PWD/$store/" env_file_path="$store/.env" rpc_path="$store/rpc.txt" operator_keys_file="$store/operator_keys.json" @@ -1165,8 +1166,8 @@ cd .. # warm start is disabled as no global weights are provided to calibrate the tools' weights # warm_start -add_volume_to_service "$PWD/trader_service/abci_build/docker-compose.yaml" "trader_abci_0" "/data" "$PWD/../$store/" -sudo chown -R $(whoami) "$PWD/../$store/" +add_volume_to_service "$PWD/trader_service/abci_build/docker-compose.yaml" "trader_abci_0" "/data" "$path_to_store" +sudo chown -R $(whoami) "$path_to_store" # Run the deployment export OPEN_AUTONOMY_PRIVATE_KEY_PASSWORD="$password" && poetry run autonomy deploy run --build-dir "$directory" --detach From 3a1949ff48885638902ddcc91e7ba9b78665c322 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 24 Jul 2024 18:27:54 +0300 Subject: [PATCH 2/5] chore: bump trader version --- run_service.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run_service.sh b/run_service.sh index 05d9a962..ea720bcb 100755 --- a/run_service.sh +++ b/run_service.sh @@ -614,7 +614,7 @@ directory="trader" service_repo=https://github.com/$org_name/$directory.git # This is a tested version that works well. # Feel free to replace this with a different version of the repo, but be careful as there might be breaking changes -service_version="v0.16.5" +service_version="v0.17.0" # Define constants for on-chain interaction gnosis_chain_id=100 From f176d7856441bb8407ecfe5669ca6ac962b3e4e8 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Wed, 24 Jul 2024 18:29:26 +0300 Subject: [PATCH 3/5] feat: update the policy's files if necessary The trader's version `v0.17.0` updates the policy which introduces a breaking change. This logic addresses this by keeping a backup of the old policy's files and allowing for the new files to be created by the service. --- run_service.sh | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/run_service.sh b/run_service.sh index ea720bcb..c9058f2b 100755 --- a/run_service.sh +++ b/run_service.sh @@ -273,6 +273,51 @@ get_on_chain_service_state() { echo "$state" } +move_if_exists() { + local source_file="$1" + local target_file="$2" + [ -e "$source_file" ] && mv "$source_file" "$target_file" || true +} + +backup_file() { + local filename="$1" + previous_version="v1" + move_if_exists "${path_to_store}${filename}" "${path_to_store}${filename}.${previous_version}" + echo "File $filename successfully backed up in $path_to_store with suffix '.$previous_version'." +} + +# Prepare for the new policy version's update +new_policy_update() { + echo "Updating the policy store to v2. Keeping a backup of the old store." + echo -n "v2" > "$policy_version_file" + backup_file "available_tools_store.json" + backup_file "policy_store.json" + backup_file "utilized_tools.json" + echo "Policy store has been updated to v2." +} + +# Check if we need to update the policy +check_for_policy_update() { + # Define the policy version file + policy_version_file="${path_to_store}policy_version.txt" + + # Check if the policy version file exists + if [ -f "$policy_version_file" ]; then + # Read the version from the file + echo "Reading the policy version file from $policy_version_file." + version=$(<"$policy_version_file") + + # Check the version and print the appropriate message + if [ "$version" != "v2" ]; then + echo "Updating the policy version file." + new_policy_update + fi + else + echo "Creating the policy version file." + new_policy_update + fi +} + # Asks if user wishes to use password-protected key files ask_confirm_password() { echo "Use a password?" @@ -1074,6 +1119,7 @@ fi echo "" echo "Finished checking Autonolas Protocol service $service_id state." +check_for_policy_update echo "" echo "------------------------------" From e82961f300875f490f12280c42c3a39f37d476f3 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Thu, 25 Jul 2024 13:56:39 +0300 Subject: [PATCH 4/5] chore: pin `cryptography` to avoid warnings from `paramiko` More info in paramiko/paramiko#2419. --- run_service.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/run_service.sh b/run_service.sh index c9058f2b..096a9fe0 100755 --- a/run_service.sh +++ b/run_service.sh @@ -828,6 +828,8 @@ cd $directory if [ "$(git rev-parse --is-inside-work-tree)" = true ] then poetry install + # temporarily pinning cryptography to `42.0.8` to address https://github.com/paramiko/paramiko/issues/2419 + poetry run pip install cryptography==42.0.8 poetry run autonomy packages sync poetry run autonomy init --reset --author $open_autonomy_author --remote --ipfs --ipfs-node "/dns/registry.autonolas.tech/tcp/443/https" poetry add tqdm From eff71ec38e46fc449ed2e517c57df687d989bc74 Mon Sep 17 00:00:00 2001 From: Adamantios Date: Fri, 26 Jul 2024 12:48:20 +0300 Subject: [PATCH 5/5] refactor: the pinning in e82961f3 --- run_service.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/run_service.sh b/run_service.sh index 096a9fe0..9b5643a6 100755 --- a/run_service.sh +++ b/run_service.sh @@ -828,11 +828,10 @@ cd $directory if [ "$(git rev-parse --is-inside-work-tree)" = true ] then poetry install - # temporarily pinning cryptography to `42.0.8` to address https://github.com/paramiko/paramiko/issues/2419 - poetry run pip install cryptography==42.0.8 poetry run autonomy packages sync poetry run autonomy init --reset --author $open_autonomy_author --remote --ipfs --ipfs-node "/dns/registry.autonolas.tech/tcp/443/https" - poetry add tqdm + # temporarily pinning cryptography to `42.0.8` to address https://github.com/paramiko/paramiko/issues/2419 + poetry add tqdm cryptography==42.0.8 else echo "$directory is not a git repo!" exit 1