Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
mhc_rank
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Skillman-Lawrence
mhc_rank
Commits
42698fe2
Commit
42698fe2
authored
5 years ago
by
Tim O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
fix
parent
035f56b1
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
mhcflurry/downloads.py
+17
-0
17 additions, 0 deletions
mhcflurry/downloads.py
mhcflurry/downloads_command.py
+11
-2
11 additions, 2 deletions
mhcflurry/downloads_command.py
with
28 additions
and
2 deletions
mhcflurry/downloads.py
+
17
−
0
View file @
42698fe2
...
@@ -16,6 +16,8 @@ from collections import OrderedDict
...
@@ -16,6 +16,8 @@ from collections import OrderedDict
from
appdirs
import
user_data_dir
from
appdirs
import
user_data_dir
from
pkg_resources
import
resource_string
from
pkg_resources
import
resource_string
import
pandas
ENVIRONMENT_VARIABLES
=
[
ENVIRONMENT_VARIABLES
=
[
"
MHCFLURRY_DATA_DIR
"
,
"
MHCFLURRY_DATA_DIR
"
,
"
MHCFLURRY_DOWNLOADS_CURRENT_RELEASE
"
,
"
MHCFLURRY_DOWNLOADS_CURRENT_RELEASE
"
,
...
@@ -130,15 +132,30 @@ def get_current_release_downloads():
...
@@ -130,15 +132,30 @@ def get_current_release_downloads():
metadata : dict
metadata : dict
Info about the download from downloads.yml such as URL
Info about the download from downloads.yml such as URL
up_to_date : bool or None
Whether the download URL(s) match what was used to download the current
data. This is None if it cannot be determined.
"""
"""
downloads
=
(
downloads
=
(
get_downloads_metadata
()
get_downloads_metadata
()
[
'
releases
'
]
[
'
releases
'
]
[
get_current_release
()]
[
get_current_release
()]
[
'
downloads
'
])
[
'
downloads
'
])
def
up_to_date
(
dir
,
urls
):
try
:
df
=
pandas
.
read_csv
(
join
(
dir
,
"
DOWNLOAD_INFO.csv
"
))
return
list
(
df
.
url
)
==
list
(
urls
)
except
IOError
:
return
None
return
OrderedDict
(
return
OrderedDict
(
(
download
[
"
name
"
],
{
(
download
[
"
name
"
],
{
'
downloaded
'
:
exists
(
join
(
get_downloads_dir
(),
download
[
"
name
"
])),
'
downloaded
'
:
exists
(
join
(
get_downloads_dir
(),
download
[
"
name
"
])),
'
up_to_date
'
:
up_to_date
(
join
(
get_downloads_dir
(),
download
[
"
name
"
]),
[
download
[
'
url
'
]]
if
'
url
'
in
download
else
download
[
'
part_urls
'
]),
'
metadata
'
:
download
,
'
metadata
'
:
download
,
})
for
download
in
downloads
})
for
download
in
downloads
)
)
...
...
This diff is collapsed.
Click to expand it.
mhcflurry/downloads_command.py
+
11
−
2
View file @
42698fe2
...
@@ -36,6 +36,7 @@ from tqdm import tqdm
...
@@ -36,6 +36,7 @@ from tqdm import tqdm
tqdm
.
monitor_interval
=
0
# see https://github.com/tqdm/tqdm/issues/481
tqdm
.
monitor_interval
=
0
# see https://github.com/tqdm/tqdm/issues/481
import
posixpath
import
posixpath
import
pandas
try
:
try
:
from
urllib.request
import
urlretrieve
from
urllib.request
import
urlretrieve
...
@@ -262,6 +263,10 @@ def fetch_subcommand(args):
...
@@ -262,6 +263,10 @@ def fetch_subcommand(args):
for
member
in
tqdm
(
tar
.
getmembers
(),
desc
=
'
Extracting
'
):
for
member
in
tqdm
(
tar
.
getmembers
(),
desc
=
'
Extracting
'
):
tar
.
extractall
(
path
=
result_dir
,
members
=
[
member
])
tar
.
extractall
(
path
=
result_dir
,
members
=
[
member
])
tar
.
close
()
tar
.
close
()
# Save URLs that were used for this download.
pandas
.
DataFrame
({
"
url
"
:
urls
}).
to_csv
(
os
.
path
.
join
(
result_dir
,
"
DOWNLOAD_INFO.csv
"
),
index
=
False
)
qprint
(
"
Extracted %d files to: %s
"
%
(
qprint
(
"
Extracted %d files to: %s
"
%
(
len
(
names
),
quote
(
result_dir
)))
len
(
names
),
quote
(
result_dir
)))
finally
:
finally
:
...
@@ -298,8 +303,8 @@ def info_subcommand(args):
...
@@ -298,8 +303,8 @@ def info_subcommand(args):
downloads
=
get_current_release_downloads
()
downloads
=
get_current_release_downloads
()
format_string
=
"
%-40s %-12s %-20s
"
format_string
=
"
%-40s %-12s
%-12s
%-20s
"
print
(
format_string
%
(
"
DOWNLOAD NAME
"
,
"
DOWNLOADED?
"
,
"
URL
"
))
print
(
format_string
%
(
"
DOWNLOAD NAME
"
,
"
DOWNLOADED?
"
,
"
UP TO DATE?
"
,
"
URL
"
))
for
(
item
,
info
)
in
downloads
.
items
():
for
(
item
,
info
)
in
downloads
.
items
():
urls
=
(
urls
=
(
...
@@ -313,6 +318,10 @@ def info_subcommand(args):
...
@@ -313,6 +318,10 @@ def info_subcommand(args):
print
(
format_string
%
(
print
(
format_string
%
(
item
,
item
,
yes_no
(
info
[
'
downloaded
'
]),
yes_no
(
info
[
'
downloaded
'
]),
""
if
not
info
[
'
downloaded
'
]
else
(
"
UNKNOWN
"
if
info
[
'
up_to_date
'
]
is
None
else
yes_no
(
info
[
'
up_to_date
'
])
),
url_description
))
url_description
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment