ome / omego

OME, Go! Installation and administration tool for OME applications.
GNU General Public License v2.0
6 stars 15 forks source link

Download GitHub release artifacts #127

Closed manics closed 2 years ago

manics commented 4 years ago

Support downloading from GitHub releases. Currently limited to:

E.g.:

$ omego download --github ome/omero-insight --release 5.5.5
Artifacts available for download. Initial partial matching is supported for all except named-components). Alternatively a full filename can be specified to download any artifact, including those not listed.

omerozips:
  imagej-5.5.5
  importer-5.5.5
  insight-5.5.5
zips:
  OMERO.imagej-5.5.5
  OMERO.importer-5.5.5
  OMERO.insight-5.5.5
$ omego download --github ome/omero-insight --release 5.5.5 insight
2020-03-19 17:57:12,123 [omego.artifa] INFO  Checking https://github.com/ome/omero-insight/releases/download/v5.5.5/OMERO.insight-5.5.5.zip
2020-03-19 17:57:12,124 [omego.fileut] INFO  Downloading https://github.com/ome/omero-insight/releases/download/v5.5.5/OMERO.insight-5.5.5.zip
2020-03-19 17:57:24,708 [omego.artifa] INFO  Unzipping OMERO.insight-5.5.5.zip
mtbc commented 4 years ago

:+1: for the helpful messages.

sbesson commented 4 years ago

Adding a few notes about my investigation of using this branch for private repository releases. Individual releases can be accessed by setting a valid GitHub OAuth token in the request header as per:

diff --git a/omego/fileutils.py b/omego/fileutils.py
index fb02653..f794dc8 100644
--- a/omego/fileutils.py
+++ b/omego/fileutils.py
@@ -96,6 +96,11 @@ def open_url(url, httpuser=None, httppassword=None, method=None):

     # Override method http://stackoverflow.com/a/4421485
     req = urllib.request.Request(url)
+    if 'GITHUB_TOKEN' in os.environ:
+        req.add_header(
+            'Authorization', 'token %s' % os.environ.get('GITHUB_TOKEN'))
+        log.debug('Setting authorization')
+
     if method:
         req.get_method = lambda: method

With this change GithubArtifacts.read_downloads will list all release assets as expected. However during the download, I was unable to consume browser_download_url even when also setting the Accept request header as per https://developer.github.com/v3/repos/releases/#get-a-single-release-asset. Likely the code might need to be adapted to consume the release asset endpoint instead. However, this might requires a larger refactoring of this code as the component name cannot be simply extracted from the asset URL.

manics commented 4 years ago

I think I've fixed Travis which looks like it was broken for a while. The remaining failing tests should be the ones that download from openmicroscopy.org

joshmoore commented 4 years ago

A few thoughts: