Unfortunately, the endpoint that GitHub provides for uploading data to a release (link) does not allow uploading if a resource already exists at the given asset's name. This is because GitHub envisions each release as a standalone item within a versioning system. This meant that when uploading a dataset that already existed in a given release (e.g., cps_2024.h5), the upload would fail with error 422. Unfortunately, GitHub's "update a release asset" endpoint (link) only exists to update metadata, not replace an existing asset.
Furthermore, the original code did not properly wrap the upload action in the tqdm library.
To get around this issue, this PR does the following:
Fixes the tqdm implementation
In the upload function, determines whether or not an item with the desired name already exists in the desired release. If so, it:
Downloads the given item and stores it locally as a backup
Deletes the given item
Uploads the new item
Deletes the backup
If at any point, this new simulated transaction fails, the code uploads the backup
Fixes #24.
Unfortunately, the endpoint that GitHub provides for uploading data to a release (link) does not allow uploading if a resource already exists at the given asset's name. This is because GitHub envisions each release as a standalone item within a versioning system. This meant that when uploading a dataset that already existed in a given release (e.g.,
cps_2024.h5
), the upload would fail with error 422. Unfortunately, GitHub's "update a release asset" endpoint (link) only exists to update metadata, not replace an existing asset.Furthermore, the original code did not properly wrap the
upload
action in thetqdm
library.To get around this issue, this PR does the following:
This PR also adds
tqdm
to thedownload
function.