Skip to content

Commit

Permalink
Merge pull request #100 from refgenie/bugfix
Browse files Browse the repository at this point in the history
v0.9.2
  • Loading branch information
stolarczyk authored Aug 19, 2020
2 parents bf42570 + c35f578 commit f22a06d
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html) and [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) format.

## [0.9.2] - 2020-08-19

### Added
- in `pull` the genome description is fetched from the server

## [0.9.1] - 2020-07-29

### Added
Expand Down
2 changes: 1 addition & 1 deletion refgenconf/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "0.9.1"
__version__ = "0.9.2"
12 changes: 8 additions & 4 deletions refgenconf/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
API_ID_ARCHIVE = CUSTOM_PFX + "_archive"
API_ID_DEFAULT_TAG = CUSTOM_PFX + "_default_tag"
API_ID_ASSET_ATTRS = CUSTOM_PFX + "_asset_attrs"
API_ID_GENOME_ATTRS = "download_genome_attributes_v2_genome__genome__get" # temporary, default operation ID assigned by FastAPI. Switch to custom once refgenieserver supports it
# API_ID_GENOME_ATTRS = CUSTOM_PFX + "_genome_attrs"
API_ID_DIGEST = CUSTOM_PFX + "_asset_digest"
API_ID_RECIPE = CUSTOM_PFX + "_asset_recipe"
API_ID_LOG = CUSTOM_PFX + "_asset_log"
Expand All @@ -38,14 +40,16 @@
# for systematic links generation in the splash pages
OPERATION_IDS = {
"asset": {
API_ID_ARCHIVE: "archive", API_ID_ASSET_ATTRS: "attributes", API_ID_DIGEST: "asset digest",
API_ID_ARCHIVE_DIGEST: "archive digest", API_ID_RECIPE: "build recipe", API_ID_LOG: "build log"
API_ID_ARCHIVE: "archive", API_ID_ASSET_ATTRS: "attributes",
API_ID_DIGEST: "asset digest", API_ID_ARCHIVE_DIGEST: "archive digest",
API_ID_RECIPE: "build recipe", API_ID_LOG: "build log"
}
}

API_IDS = [
"API_ID_ASSETS", "API_ID_ARCHIVE", "API_ID_DEFAULT_TAG", "API_ID_ASSET_ATTRS", "API_ID_DIGEST",
"API_ID_RECIPE", "API_ID_LOG", "API_ID_SPLASH", "API_ID_ARCHIVE_DIGEST"
"API_ID_ASSETS", "API_ID_ARCHIVE", "API_ID_DEFAULT_TAG", "API_ID_LOG",
"API_ID_DIGEST", "API_ID_RECIPE", "API_ID_ASSET_ATTRS", "API_ID_SPLASH",
"API_ID_ARCHIVE_DIGEST", "API_ID_GENOME_ATTRS"
]

CFG_FOLDER_KEY = "genome_folder"
Expand Down
12 changes: 9 additions & 3 deletions refgenconf/refgenconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -715,19 +715,22 @@ def _raise_unpack_error():
_LOGGER.debug("Determined tag: {}".format(determined_tag))
unpack or _raise_unpack_error()
gat = [genome, asset, determined_tag]
url_attrs = get_json_url(server_url, API_ID_ASSET_ATTRS).format(genome=genome, asset=asset)
url_asset_attrs = get_json_url(server_url, API_ID_ASSET_ATTRS).format(genome=genome, asset=asset)
url_genome_attrs = get_json_url(server_url, API_ID_GENOME_ATTRS).format(genome=genome)
url_archive = get_json_url(server_url, API_ID_ARCHIVE).format(genome=genome, asset=asset)

try:
archive_data = _download_json(url_attrs, params={"tag": determined_tag})
_LOGGER.debug("Determined server URL: {}".format(server_url))
archive_data = _download_json(url_asset_attrs, params={"tag": determined_tag})
except DownloadJsonError:
no_asset_json.append(server_url)
if num_servers == len(self[CFG_SERVERS_KEY]):
_LOGGER.error("Asset '{}/{}:{}' not available on any of the following servers: {}".
format(genome, asset, determined_tag, ", ".join(self[CFG_SERVERS_KEY])))
return _null_return()
continue
else:
_LOGGER.debug("Determined server URL: {}".format(server_url))
genome_archive_data = _download_json(url_genome_attrs)

if sys.version_info[0] == 2:
archive_data = asciify_json_dict(archive_data)
Expand Down Expand Up @@ -826,19 +829,22 @@ def preserve():
shutil.move(os.path.join(tmpdir, asset), tag_dir)
if os.path.isfile(filepath):
os.remove(filepath)

if self.file_path:
with self as rgc:
[rgc.chk_digest_update_child(gat[0], x, "{}/{}:{}".format(*gat), server_url)
for x in archive_data[CFG_ASSET_PARENTS_KEY] if CFG_ASSET_PARENTS_KEY in archive_data]
rgc.update_tags(*gat, data={attr: archive_data[attr]
for attr in ATTRS_COPY_PULL if attr in archive_data})
rgc.set_default_pointer(*gat)
rgc.update_genomes(genome=genome, data=genome_archive_data)
else:
[self.chk_digest_update_child(gat[0], x, "{}/{}:{}".format(*gat), server_url)
for x in archive_data[CFG_ASSET_PARENTS_KEY] if CFG_ASSET_PARENTS_KEY in archive_data]
self.update_tags(*gat, data={attr: archive_data[attr]
for attr in ATTRS_COPY_PULL if attr in archive_data})
self.set_default_pointer(*gat)
self.update_genomes(genome=genome, data=genome_archive_data)
self.run_plugins(POST_PULL_HOOK)
return gat, archive_data, server_url

Expand Down
1 change: 0 additions & 1 deletion requirements/requirements-all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ pyyaml
requests
tqdm>=4.38.0
yacman>=0.6.9
future
pyfaidx

0 comments on commit f22a06d

Please sign in to comment.