biothings / biothings_studio

Pre-configured & ready-to-use BioThings API development environment
Apache License 2.0
4 stars 3 forks source link

Add "dumper.version" section in manifest to better handle version detection #8

Closed sirloon closed 6 years ago

sirloon commented 6 years ago

Several options:

  1. version is hard-coded
  2. version is taken from a specific HTTP header field (specify "last-modified", "etag", others)
  3. specify a "module:function" that will take anything the dumper has access to (url, headers, etc...) as input, and return a version
sirloon commented 6 years ago

done in https://github.com/biothings/biothings.api/commit/7101f5336948a9e7059007ee8ad213c41e6c8c89

Here's how it works:

{
    "version": "0.1",
    "dumper" : {
        "data_url" : "https://www.cancergenomeinterpreter.org/data/cgi_biomarkers_latest.zip",
        "uncompress" : true,
        "release" : "version:get_release"
    },
    "uploader" : {
        "parser" : "parser:load_data",
        "on_duplicates" : "ignore"
    }
}

Added “release” key under “dumper”. It refers to module “version.py” and a function inside, named “get_release”.

Content of version.py:

def get_release(self):
    return "1.3"

the signature has “self”, it is the dumper instance (self) and all of its methods, properties, etc... In order, for instance, to access the filenames (URLs) and get the release number from it, self.class.SRC_URLS can be used.

get_release should return a release number