From 7a4995bbfed8b154eebb61be8dd7581fd82b6764 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Sat, 15 Jun 2024 10:56:57 +0200 Subject: [PATCH 1/8] chore: update agent hash --- frontend/constants/serviceTemplates.ts | 4 ++-- templates/trader.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/constants/serviceTemplates.ts b/frontend/constants/serviceTemplates.ts index 7d9baf6c5..31fb744a7 100644 --- a/frontend/constants/serviceTemplates.ts +++ b/frontend/constants/serviceTemplates.ts @@ -3,12 +3,12 @@ import { ServiceTemplate } from '@/client'; export const SERVICE_TEMPLATES: ServiceTemplate[] = [ { name: 'Trader Agent', - hash: 'bafybeihv3nyh43rim6kcxdscdgsiojhbqfwndhwcrtxhi3gkxbnasdc7ui', + hash: 'bafybeifjtoqigilzka5kxqegdvcswji246a67536qfovhswdqterfxnw2q', description: 'Trader agent for omen prediction markets', image: 'https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75', configuration: { - nft: 'bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq', + nft: 'bafybeiei7wb5jvrn7e7fss2t6ajnkjakgf7uaz42fvvlkolhpnez2dlfsy', agent_id: 14, threshold: 1, use_staking: true, diff --git a/templates/trader.yaml b/templates/trader.yaml index ab22b8478..bb4a2e876 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -1,6 +1,6 @@ name: "Trader Agent" description: "Trader agent for omen prediction markets" -hash: bafybeihv3nyh43rim6kcxdscdgsiojhbqfwndhwcrtxhi3gkxbnasdc7ui +hash: bafybeifjtoqigilzka5kxqegdvcswji246a67536qfovhswdqterfxnw2q image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 configuration: nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq From 116efc95a21d97e459ce58a3a0cfe954dcb0f257 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Sat, 15 Jun 2024 10:59:58 +0200 Subject: [PATCH 2/8] chore: update version to 0.1.0rc46.1 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index 1869762a7..8efbc521c 100644 --- a/electron/install.js +++ b/electron/install.js @@ -16,7 +16,7 @@ const { BrewScript } = require("./scripts") * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc46'; +const OlasMiddlewareVersion = '0.1.0rc46.1'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/package.json b/package.json index af7a8b634..38041f7ad 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "main": "electron/main.js", "name": "olas-operate-app", "productName": "Pearl", - "version": "0.1.0-rc46", + "version": "0.1.0-rc46.1", "dependencies": { "@ant-design/cssinjs": "^1.18.4", "@ant-design/icons": "^5.3.0", diff --git a/pyproject.toml b/pyproject.toml index 61ae8d497..dbbb1a727 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc46" +version = "0.1.0-rc46.1" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 1562e2618be5531dda72bdc05e864b97664f0736 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Sat, 15 Jun 2024 11:18:50 +0200 Subject: [PATCH 3/8] chore: update version to 0.1.0rc46.1 --- electron/install.js | 2 +- pyproject.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/electron/install.js b/electron/install.js index 8efbc521c..1869762a7 100644 --- a/electron/install.js +++ b/electron/install.js @@ -16,7 +16,7 @@ const { BrewScript } = require("./scripts") * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc46.1'; +const OlasMiddlewareVersion = '0.1.0rc46'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/pyproject.toml b/pyproject.toml index dbbb1a727..61ae8d497 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc46.1" +version = "0.1.0-rc46" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From 15659d9050ddbb1c367526aa0699f86e0d549ec1 Mon Sep 17 00:00:00 2001 From: jmoreira-valory Date: Sat, 15 Jun 2024 15:50:15 +0200 Subject: [PATCH 4/8] chore: service hash --- frontend/constants/serviceTemplates.ts | 2 +- templates/trader.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/constants/serviceTemplates.ts b/frontend/constants/serviceTemplates.ts index 31fb744a7..249fe95a7 100644 --- a/frontend/constants/serviceTemplates.ts +++ b/frontend/constants/serviceTemplates.ts @@ -3,7 +3,7 @@ import { ServiceTemplate } from '@/client'; export const SERVICE_TEMPLATES: ServiceTemplate[] = [ { name: 'Trader Agent', - hash: 'bafybeifjtoqigilzka5kxqegdvcswji246a67536qfovhswdqterfxnw2q', + hash: 'bafybeieg45wcjcwd5znuwpjcp5scfhgdqwpfq43pzaare6nwvmy5bb56cm', description: 'Trader agent for omen prediction markets', image: 'https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75', diff --git a/templates/trader.yaml b/templates/trader.yaml index bb4a2e876..5be1fa187 100644 --- a/templates/trader.yaml +++ b/templates/trader.yaml @@ -1,6 +1,6 @@ name: "Trader Agent" description: "Trader agent for omen prediction markets" -hash: bafybeifjtoqigilzka5kxqegdvcswji246a67536qfovhswdqterfxnw2q +hash: bafybeieg45wcjcwd5znuwpjcp5scfhgdqwpfq43pzaare6nwvmy5bb56cm image: https://operate.olas.network/_next/image?url=%2Fimages%2Fprediction-agent.png&w=3840&q=75 configuration: nft: bafybeig64atqaladigoc3ds4arltdu63wkdrk3gesjfvnfdmz35amv7faq From 61e698488d1057552749e1e787fc899b05f8ffdc Mon Sep 17 00:00:00 2001 From: truemiller <31908788+truemiller@users.noreply.github.com> Date: Mon, 17 Jun 2024 16:21:23 +0100 Subject: [PATCH 5/8] chore: update version to 0.1.0rc47 --- electron/install.js | 73 ++++++++++++++++++++++++--------------------- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 41 insertions(+), 36 deletions(-) diff --git a/electron/install.js b/electron/install.js index 1869762a7..1d32a2351 100644 --- a/electron/install.js +++ b/electron/install.js @@ -1,6 +1,6 @@ // Installation helpers. -const nfs = require('node:fs') +const nfs = require('node:fs'); const fs = require('fs'); const os = require('os'); const sudo = require('sudo-prompt'); @@ -9,14 +9,14 @@ const axios = require('axios'); const Docker = require('dockerode'); const { spawnSync } = require('child_process'); -const { BrewScript } = require("./scripts") +const { BrewScript } = require('./scripts'); /** * current version of the pearl release * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc46'; +const OlasMiddlewareVersion = '0.1.0rc47'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; @@ -86,9 +86,9 @@ function runCmdUnix(command, options) { Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`, ); } - console.log(appendLog(`Executed ${command} ${options} with`)) - console.log(appendLog(`===== stdout ===== \n${output.stdout}`)) - console.log(appendLog(`===== stderr ===== \n${output.stderr}`)) + console.log(appendLog(`Executed ${command} ${options} with`)); + console.log(appendLog(`===== stdout ===== \n${output.stdout}`)); + console.log(appendLog(`===== stderr ===== \n${output.stderr}`)); } function runSudoUnix(command, options) { @@ -112,10 +112,10 @@ function runSudoUnix(command, options) { Error: ${output.error}; Stdout: ${output.stdout}; Stderr: ${output.stderr}`, ); } - console.log(appendLog(`Executed ${command} ${options} with`)) - console.log(appendLog(`===== stdout ===== \n${output.stdout}`)) - console.log(appendLog(`===== stderr ===== \n${output.stderr}`)) - resolve() + console.log(appendLog(`Executed ${command} ${options} with`)); + console.log(appendLog(`===== stdout ===== \n${output.stdout}`)); + console.log(appendLog(`===== stderr ===== \n${output.stderr}`)); + resolve(); }, ); }); @@ -126,37 +126,42 @@ function isBrewInstalled() { } async function installBrew() { - console.log(appendLog("Fetching homebrew source")) - let outdir = `${os.homedir()}/homebrew` - let outfile = `${os.homedir()}/homebrew.tar` - + console.log(appendLog('Fetching homebrew source')); + let outdir = `${os.homedir()}/homebrew`; + let outfile = `${os.homedir()}/homebrew.tar`; + // Make temporary source dir - fs.mkdirSync(outdir) - + fs.mkdirSync(outdir); + // Fetch brew source - runCmdUnix("curl", ["-L", "https://github.com/Homebrew/brew/tarball/master", "--output", outfile]) - runCmdUnix("tar", ["-xvf", outfile, "--strip-components", "1", "-C", outdir]) - + runCmdUnix('curl', [ + '-L', + 'https://github.com/Homebrew/brew/tarball/master', + '--output', + outfile, + ]); + runCmdUnix('tar', ['-xvf', outfile, '--strip-components', '1', '-C', outdir]); + // Check for cache and uninstall leftovers - if (fs.existsSync("/opt/homebrew")) { - console.log(appendLog("Removing homebrew leftovers")) + if (fs.existsSync('/opt/homebrew')) { + console.log(appendLog('Removing homebrew leftovers')); if (!Env.CI) { - await runSudoUnix("rm", `-rf /opt/homebrew`) + await runSudoUnix('rm', `-rf /opt/homebrew`); } else { - fs.rmdirSync("/opt/homebrew") + fs.rmdirSync('/opt/homebrew'); } } - console.log(appendLog("Installing homebrew")) + console.log(appendLog('Installing homebrew')); if (!Env.CI) { - await runSudoUnix("mv", `${outdir} /opt/homebrew`) - await runSudoUnix("chown", `-R ${os.userInfo().username} /opt/homebrew`) + await runSudoUnix('mv', `${outdir} /opt/homebrew`); + await runSudoUnix('chown', `-R ${os.userInfo().username} /opt/homebrew`); } else { - runCmdUnix("mv", [outdir, "/opt/homebrew"]) - runCmdUnix("chown", ["-R", os.userInfo().username, "/opt/homebrew"]) + runCmdUnix('mv', [outdir, '/opt/homebrew']); + runCmdUnix('chown', ['-R', os.userInfo().username, '/opt/homebrew']); } - runCmdUnix("brew", ["doctor"]) - fs.rmSync(outfile) + runCmdUnix('brew', ['doctor']); + fs.rmSync(outfile); } function isTendermintInstalledUnix() { @@ -177,7 +182,7 @@ async function downloadFile(url, dest) { writer.on('error', reject); }); } catch (err) { - fs.unlink(dest, () => { }); // Delete the file if there is an error + fs.unlink(dest, () => {}); // Delete the file if there is an error console.error('Error downloading the file:', err.message); } } @@ -199,8 +204,8 @@ async function installTendermintUnix() { // TOFIX: Install tendermint in .operate instead of globally if (!Env.CI) { - if (!fs.existsSync("/usr/local/bin")) { - await runSudoUnix('mkdir', '/usr/local/bin') + if (!fs.existsSync('/usr/local/bin')) { + await runSudoUnix('mkdir', '/usr/local/bin'); } await runSudoUnix('install', 'tendermint /usr/local/bin/tendermint'); } @@ -479,4 +484,4 @@ module.exports = { LogFile, OperateInstallationLog, }, -}; \ No newline at end of file +}; diff --git a/package.json b/package.json index 38041f7ad..3cb35748b 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "main": "electron/main.js", "name": "olas-operate-app", "productName": "Pearl", - "version": "0.1.0-rc46.1", + "version": "0.1.0-rc47", "dependencies": { "@ant-design/cssinjs": "^1.18.4", "@ant-design/icons": "^5.3.0", diff --git a/pyproject.toml b/pyproject.toml index 61ae8d497..9473b8574 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc46" +version = "0.1.0-rc47" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md" From ab5347d907e696c024fe17bf75cd92e5483e2f14 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Tue, 18 Jun 2024 15:47:31 +0300 Subject: [PATCH 6/8] pause all service on startup --- operate/cli.py | 17 +++++++++++++++++ operate/services/service.py | 4 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/operate/cli.py b/operate/cli.py index 821fa88ac..646435a33 100644 --- a/operate/cli.py +++ b/operate/cli.py @@ -179,6 +179,23 @@ def cancel_funding_job(service: str) -> None: if not status: logger.info(f"Funding job cancellation for {service} failed") + def pause_all_services_on_startup(): + logger.info(f"stopping services on startup") + services = [i["hash"] for i in operate.service_manager().json] + + for service in services: + if not operate.service_manager().exists(service=service): + continue + logger.info(f"stopping service {service}") + deployment = operate.service_manager().create_or_load(service).deployment + deployment.stop(force=True) + logger.info(f"Cancelling funding job for {service}") + cancel_funding_job(service=service) + logger.info(f"stopping services on startup: done") + + # on backend app started we assume there are now started agents, so we force to pause all + pause_all_services_on_startup() + app = FastAPI() app.add_middleware( diff --git a/operate/services/service.py b/operate/services/service.py index 1f03d93ab..2f05c6d9e 100644 --- a/operate/services/service.py +++ b/operate/services/service.py @@ -822,9 +822,9 @@ def start(self, use_docker: bool = False) -> None: self.status = DeploymentStatus.DEPLOYED self.store() - def stop(self, use_docker: bool = False) -> None: + def stop(self, use_docker: bool = False, force: bool=False) -> None: """Stop the deployment.""" - if self.status != DeploymentStatus.DEPLOYED: + if self.status != DeploymentStatus.DEPLOYED and not force: return self.status = DeploymentStatus.STOPPING From cbdf9ff3fe938b9cdad34febe29564b8d014c430 Mon Sep 17 00:00:00 2001 From: "Yuri (solarw) Turchenkov" Date: Tue, 18 Jun 2024 16:02:00 +0300 Subject: [PATCH 7/8] deleted state check added for pause services on startup --- operate/cli.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/operate/cli.py b/operate/cli.py index 646435a33..64a7bfd21 100644 --- a/operate/cli.py +++ b/operate/cli.py @@ -42,7 +42,7 @@ from operate.account.user import UserAccount from operate.constants import KEY, KEYS, OPERATE, SERVICES from operate.ledger import get_ledger_type_from_chain_type -from operate.types import ChainType +from operate.types import ChainType, DeploymentStatus from operate.wallet.master import MasterWalletManager @@ -186,8 +186,10 @@ def pause_all_services_on_startup(): for service in services: if not operate.service_manager().exists(service=service): continue - logger.info(f"stopping service {service}") deployment = operate.service_manager().create_or_load(service).deployment + if deployment.status == DeploymentStatus.DELETED: + continue + logger.info(f"stopping service {service}") deployment.stop(force=True) logger.info(f"Cancelling funding job for {service}") cancel_funding_job(service=service) From d46d371016df8e6ce1880f10b4b7b55a514ac74e Mon Sep 17 00:00:00 2001 From: truemiller Date: Tue, 18 Jun 2024 15:28:52 +0100 Subject: [PATCH 8/8] bump to rc50 --- electron/install.js | 2 +- package.json | 2 +- pyproject.toml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/electron/install.js b/electron/install.js index 1d32a2351..158918c40 100644 --- a/electron/install.js +++ b/electron/install.js @@ -16,7 +16,7 @@ const { BrewScript } = require('./scripts'); * - use "" (nothing as a suffix) for latest release candidate, for example "0.1.0rc26" * - use "alpha" for alpha release, for example "0.1.0rc26-alpha" */ -const OlasMiddlewareVersion = '0.1.0rc47'; +const OlasMiddlewareVersion = '0.1.0rc50'; const OperateDirectory = `${os.homedir()}/.operate`; const VenvDir = `${OperateDirectory}/venv`; const TempDir = `${OperateDirectory}/temp`; diff --git a/package.json b/package.json index 3cb35748b..7a22390d0 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "main": "electron/main.js", "name": "olas-operate-app", "productName": "Pearl", - "version": "0.1.0-rc47", + "version": "0.1.0-rc50", "dependencies": { "@ant-design/cssinjs": "^1.18.4", "@ant-design/icons": "^5.3.0", diff --git a/pyproject.toml b/pyproject.toml index 9473b8574..b4c266b81 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "olas-operate-middleware" -version = "0.1.0-rc47" +version = "0.1.0-rc50" description = "" authors = ["David Vilela ", "Viraj Patel "] readme = "README.md"