Skip to content

Conversation

@zuperzane
Copy link
Contributor

Description

Gathers list of names of binaries to download and downloads them and unzips to external runtime directory

Testing Done

Can test with UI I believe

Resolved Issues

resolves #3559

Length Justification and Key Files to Review

Review Checklist

It is the reviewers responsibility to also make sure every item here has been covered

  • Function & Class comments: All function definitions (usually in the .h file) should have a javadoc style comment at the start of them. For examples, see the functions defined in thunderbots/software/geom. Similarly, all classes should have an associated Javadoc comment explaining the purpose of the class.
  • Remove all commented out code
  • Remove extra print statements: for example, those just used for testing
  • Resolve all TODO's: All TODO (or similar) statements should either be completed or associated with a github issue

Copy link
Contributor

@Andrewyx Andrewyx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work so far! Left some comments

Comment on lines 18 to 20
url = "https://api.github.com/repos/UBC-Thunderbots/Software/releases"

headers = {"Accept": "application/vnd.github+json"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably move this to the constants class

Comment on lines 29 to 43
for release in releases:
for asset in release.get("assets", []):
binaries.append(
{
"name": asset["name"],
"download_url": asset["browser_download_url"],
"size_bytes": asset["size"],
"created_at": asset["created_at"],
"release_tag": release["tag_name"],
}
)
if len(binaries) == 5:
break
if len(binaries) == 5:
break
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is grabbing 5 binaries right? Each release should only have 1 binary for each platform (i.e. we should not grab binaries which do not match the client's platform).

Also 5 here is a magic number so ideally we should make it a constant

Comment on lines 61 to 62
url = "https://api.github.com/repos/UBC-Thunderbots/Software/releases"
headers = {"Accept": "application/vnd.github+json"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: see above const comment

Comment on lines 89 to 90
# Ensure target directory exists
subprocess.run(["sudo", "mkdir", "-p", str(target_dir)], check=True)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like shared functionality (checking if the external runtimes dir exists + creating it) between this PR and #3569. We should move this operation to the superclass

headers = {"Accept": "application/vnd.github+json"}

response = requests.get(url, headers=headers)
response.raise_for_status()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should log this error, then default to the local runtimes instead. This would be handy given there are many times we might lose wifi unknowingly


for release in releases:
for asset in release.get("assets", []):
if asset["browser_download_url"].endswith(TARGET_SUFFIX):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, agree with storing the last looked up binaries and checking within that before, before making the API call to fetch releases again


for release in releases:
for asset in release.get("assets", []):
if asset["browser_download_url"].endswith(TARGET_SUFFIX):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also, the fetching code here is similar to the code block in fetch_remote_runtimes. could probably extract the API call logic into a new method that just returns the releases json, and each method can filter accordingly


else:
subprocess.run(
["cp", str(archive_path), str(INSTALL_DIR / filename)],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

archive_path and INSTALL_DIR are not defined, I think you meant tmp_path and target_dir

nycrat
nycrat previously approved these changes Jan 25, 2026
Copy link
Member

@nycrat nycrat left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, works on my local. left a few nits but perhaps we should just get this merged asap

Comment on lines +33 to +35
# I'm going to assume you are trying to reload the assets so reset the download_urls
if len(self.download_urls) != 0:
self.download_urls = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not necessary, the fetch_remote_runtimes function only runs once

Comment on lines +50 to +56
url = RuntimeManagerConstants.INSTALL_URL
headers = {"Accept": "application/vnd.github+json"}

response = requests.get(url, headers=headers)
logger.warning(response)

releases = response.json()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is necessary

Comment on lines 62 to 64
for i in range(len(self.download_urls)):
if self.download_urls[i].endswith(TARGET_SUFFIX):
selected_asset = self.download_urls[i]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would just do download_url in self.download_urls instead of a range-based loop

Comment on lines +400 to +401
INSTALL_URL = "https://api.github.com/repos/UBC-Thunderbots/Software/releases"
DOWNLOAD_PREFIX = "https://github.com/UBC-Thunderbots/Software/releases/download/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: perhaps change to RELEASES_URL, and DOWNLOAD_URL

Andrewyx
Andrewyx previously approved these changes Jan 25, 2026
@zuperzane zuperzane dismissed stale reviews from Andrewyx and nycrat via 8e4036c January 25, 2026 00:33
@williamckha williamckha dismissed sauravbanna’s stale review January 25, 2026 07:17

eric will clean the pr up later

@nycrat nycrat merged commit c43cf6f into UBC-Thunderbots:master Jan 25, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SIM RFC: AI Download Backend

5 participants