Skip to content

Commit

Permalink
feat: Better loading of actual latest vega (#480)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomMcL authored Aug 8, 2023
1 parent 6f67a3c commit 875d214
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion vega_sim/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from importlib import metadata
from pathlib import Path

VEGA_VERSION = "0.72.6"
VEGA_VERSION = "v0.72.6"
try:
__version__ = metadata.version(__package__)
except metadata.PackageNotFoundError:
Expand Down
20 changes: 13 additions & 7 deletions vega_sim/tools/load_binaries.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

logger = logging.getLogger(__name__)

URL_BASE = "https://github.com/vegaprotocol/vega/releases/download/v{version}/"
URL_LATEST_BASE = "https://github.com/vegaprotocol/vega/releases/latest/download/"
URL_BASE = "https://github.com/vegaprotocol/vega/releases/download/{version}/"
DATA_NODE = "data-node-{platform}-{chipset}64.zip"
VEGA_CORE = "vega-{platform}-{chipset}64.zip"
VEGAWALLET = "vegawallet-{platform}-{chipset}64.zip"
Expand Down Expand Up @@ -41,6 +40,17 @@ def download_binaries(force: bool = False, latest: bool = False):
with tempfile.TemporaryDirectory() as dir:
if not os.path.exists(vega_sim.vega_bin_path):
os.mkdir(vega_sim.vega_bin_path)

if latest:
vega_versions = requests.get(
"https://api.github.com/repos/vegaprotocol/vega/releases"
).json()
vega_version = vega_versions[0]["tag_name"]
else:
vega_version = vega_sim.VEGA_VERSION

logger.info(f"Downloading Vega version {vega_version}")

for remote_file in FILES:
file_name = remote_file.format(platform=platf, chipset=chipset)
if (
Expand All @@ -50,11 +60,7 @@ def download_binaries(force: bool = False, latest: bool = False):
) or force:
logger.info(f"Downloading {file_name}")

url_base = (
URL_BASE.format(version=vega_sim.VEGA_VERSION)
if not latest
else URL_LATEST_BASE
)
url_base = URL_BASE.format(version=vega_version)
url = url_base + file_name
res = requests.get(url)
file_path = os.path.join(dir, f"{file_name}")
Expand Down

0 comments on commit 875d214

Please sign in to comment.