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
63e9d76d
Commit
63e9d76d
authored
5 years ago
by
Tim O'Donnell
Browse files
Options
Downloads
Patches
Plain Diff
attempt travis fix
parent
78e527f7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
.travis.yml
+11
-1
11 additions, 1 deletion
.travis.yml
mhcflurry/downloads_command.py
+44
-10
44 additions, 10 deletions
mhcflurry/downloads_command.py
with
55 additions
and
11 deletions
.travis.yml
+
11
−
1
View file @
63e9d76d
...
@@ -39,6 +39,16 @@ env:
...
@@ -39,6 +39,16 @@ env:
script
:
script
:
# download data and models, then run tests
# download data and models, then run tests
-
mhcflurry-downloads fetch data_curated models_class1 models_class1_pan allele_sequences
-
mkdir -p /tmp/downloads
-
wget
$(mhcflurry-downloads url models_class1)
$(mhcflurry-downloads url models_class1_pan)
$(mhcflurry-downloads url allele_sequences)
-P /tmp/downloads
-
mhcflurry-downloads fetch
data_curated models_class1 models_class1_pan
--already-downloaded-dir /tmp/downloads
-
mhcflurry-downloads info
# just to test this command works
-
mhcflurry-downloads info
# just to test this command works
-
nosetests --with-timer -sv test
-
nosetests --with-timer -sv test
This diff is collapsed.
Click to expand it.
mhcflurry/downloads_command.py
+
44
−
10
View file @
63e9d76d
...
@@ -32,10 +32,14 @@ from tempfile import NamedTemporaryFile
...
@@ -32,10 +32,14 @@ from tempfile import NamedTemporaryFile
from
tqdm
import
tqdm
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
try
:
try
:
from
urllib.request
import
urlretrieve
from
urllib.request
import
urlretrieve
from
urllib.parse
import
urlsplit
except
ImportError
:
except
ImportError
:
from
urllib
import
urlretrieve
from
urllib
import
urlretrieve
from
urlparse
import
urlsplit
from
.downloads
import
(
from
.downloads
import
(
get_current_release
,
get_current_release
,
...
@@ -78,6 +82,10 @@ parser_fetch.add_argument(
...
@@ -78,6 +82,10 @@ parser_fetch.add_argument(
"
--release
"
,
"
--release
"
,
default
=
get_current_release
(),
default
=
get_current_release
(),
help
=
"
Release to download. Default: %(default)s
"
)
help
=
"
Release to download. Default: %(default)s
"
)
parser_fetch
.
add_argument
(
"
--already-downloaded-dir
"
,
metavar
=
"
DIR
"
,
help
=
"
Don
'
t download files, get them from DIR
"
)
parser_info
=
subparsers
.
add_parser
(
'
info
'
)
parser_info
=
subparsers
.
add_parser
(
'
info
'
)
...
@@ -87,6 +95,12 @@ parser_path.add_argument(
...
@@ -87,6 +95,12 @@ parser_path.add_argument(
nargs
=
"
?
"
,
nargs
=
"
?
"
,
default
=
''
)
default
=
''
)
parser_url
=
subparsers
.
add_parser
(
'
url
'
)
parser_url
.
add_argument
(
"
download_name
"
,
nargs
=
"
?
"
,
default
=
''
)
def
run
(
argv
=
sys
.
argv
[
1
:]):
def
run
(
argv
=
sys
.
argv
[
1
:]):
args
=
parser
.
parse_args
(
argv
)
args
=
parser
.
parse_args
(
argv
)
...
@@ -99,6 +113,7 @@ def run(argv=sys.argv[1:]):
...
@@ -99,6 +113,7 @@ def run(argv=sys.argv[1:]):
"
fetch
"
:
fetch_subcommand
,
"
fetch
"
:
fetch_subcommand
,
"
info
"
:
info_subcommand
,
"
info
"
:
info_subcommand
,
"
path
"
:
path_subcommand
,
"
path
"
:
path_subcommand
,
"
url
"
:
url_subcommand
,
None
:
lambda
args
:
parser
.
print_help
(),
None
:
lambda
args
:
parser
.
print_help
(),
}
}
command_functions
[
args
.
subparser_name
](
args
)
command_functions
[
args
.
subparser_name
](
args
)
...
@@ -204,20 +219,28 @@ def fetch_subcommand(args):
...
@@ -204,20 +219,28 @@ def fetch_subcommand(args):
temp
=
NamedTemporaryFile
(
delete
=
False
,
suffix
=
"
.tar.bz2
"
)
temp
=
NamedTemporaryFile
(
delete
=
False
,
suffix
=
"
.tar.bz2
"
)
try
:
try
:
for
(
url_num
,
url
)
in
enumerate
(
urls
):
for
(
url_num
,
url
)
in
enumerate
(
urls
):
qprint
(
"
Downloading [part %d/%d]: %s
"
%
(
delete_downloaded
=
True
url_num
+
1
,
len
(
urls
),
url
))
if
args
.
already_downloaded_dir
:
(
downloaded_path
,
_
)
=
urlretrieve
(
filename
=
posixpath
.
basename
(
urlsplit
(
url
).
path
)
url
,
downloaded_path
=
os
.
path
.
join
(
temp
.
name
if
len
(
urls
)
==
1
else
None
,
args
.
already_downloaded_dir
,
filename
)
reporthook
=
TqdmUpTo
(
delete_downloaded
=
False
unit
=
'
B
'
,
unit_scale
=
True
,
miniters
=
1
).
update_to
)
else
:
qprint
(
"
Downloaded to: %s
"
%
quote
(
downloaded_path
))
qprint
(
"
Downloading [part %d/%d]: %s
"
%
(
url_num
+
1
,
len
(
urls
),
url
))
(
downloaded_path
,
_
)
=
urlretrieve
(
url
,
temp
.
name
if
len
(
urls
)
==
1
else
None
,
reporthook
=
TqdmUpTo
(
unit
=
'
B
'
,
unit_scale
=
True
,
miniters
=
1
).
update_to
)
qprint
(
"
Downloaded to: %s
"
%
quote
(
downloaded_path
))
if
downloaded_path
!=
temp
.
name
:
if
downloaded_path
!=
temp
.
name
:
qprint
(
"
Append
ing to: %s
"
%
temp
.
name
)
qprint
(
"
Copy
ing to: %s
"
%
temp
.
name
)
with
open
(
downloaded_path
,
"
rb
"
)
as
fd
:
with
open
(
downloaded_path
,
"
rb
"
)
as
fd
:
copyfileobj
(
fd
,
temp
,
length
=
64
*
1024
*
1024
)
copyfileobj
(
fd
,
temp
,
length
=
64
*
1024
*
1024
)
os
.
remove
(
downloaded_path
)
if
delete_downloaded
:
os
.
remove
(
downloaded_path
)
temp
.
close
()
temp
.
close
()
tar
=
tarfile
.
open
(
temp
.
name
,
'
r:bz2
'
)
tar
=
tarfile
.
open
(
temp
.
name
,
'
r:bz2
'
)
...
@@ -292,3 +315,14 @@ def info_subcommand(args):
...
@@ -292,3 +315,14 @@ def info_subcommand(args):
def
path_subcommand
(
args
):
def
path_subcommand
(
args
):
print
(
get_path
(
args
.
download_name
))
print
(
get_path
(
args
.
download_name
))
def
url_subcommand
(
args
):
downloads
=
get_current_release_downloads
()
download
=
downloads
[
args
.
download_name
][
"
metadata
"
]
urls
=
[]
if
download
.
get
(
"
url
"
):
urls
.
append
(
download
[
"
url
"
])
if
download
.
get
(
"
part_urls
"
):
urls
.
extend
(
download
[
"
part_urls
"
])
print
(
"
\n
"
.
join
(
urls
))
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