Skip to content

Commit 6bdaff9

Browse files
committed
Update formatting
1 parent 45dfe68 commit 6bdaff9

File tree

12 files changed

+445
-263
lines changed

12 files changed

+445
-263
lines changed

ggd/__main__.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@
1414
from .uninstall import add_uninstall
1515

1616
if sys.version_info[0] < 3:
17-
print("\n:ggd:WARNING: Python 2 is no longer maintained by python developers."
18-
" GGD will not maintain support for python 2 past December 31, 2020."
19-
" Python 2 may still work, but continued maintenance and support will"
20-
" be focused on python >= 3\n")
17+
print(
18+
"\n:ggd:WARNING: Python 2 is no longer maintained by python developers."
19+
" GGD will not maintain support for python 2 past December 31, 2020."
20+
" Python 2 may still work, but continued maintenance and support will"
21+
" be focused on python >= 3\n"
22+
)
23+
2124

2225
def main(args=None):
2326
if args is None:

ggd/check_recipe.py

Lines changed: 208 additions & 107 deletions
Large diffs are not rendered by default.

ggd/install.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ def check_ggd_recipe(ggd_recipe, ggd_channel):
9090

9191
package_list = search_packages(jdict, [ggd_recipe])
9292

93-
9493
if ggd_recipe in package_list:
9594
print(
9695
"\n:ggd:install: %s exists in the ggd-%s channel"
@@ -251,9 +250,9 @@ def install_from_cached(ggd_recipes, ggd_channel, ggd_jdict, debug=False, prefix
251250
True if successful install
252251
"""
253252
from .utils import (
253+
ChecksumError,
254254
bypass_satsolver_on_install,
255255
update_installed_pkg_metadata,
256-
ChecksumError,
257256
)
258257

259258
conda_channel = "ggd-" + ggd_channel
@@ -339,9 +338,9 @@ def conda_install(ggd_recipes, ggd_channel, ggd_jdict, debug=False, prefix=None)
339338
True if successful install
340339
"""
341340
from .utils import (
341+
ChecksumError,
342342
get_required_conda_version,
343343
update_installed_pkg_metadata,
344-
ChecksumError,
345344
)
346345

347346
## Get the target prefix
@@ -351,8 +350,7 @@ def conda_install(ggd_recipes, ggd_channel, ggd_jdict, debug=False, prefix=None)
351350
conda_version, equals = get_required_conda_version()
352351

353352
## create install string
354-
conda_install_str = "{}conda{}{}{}".format("\"", equals, conda_version, "\"")
355-
353+
conda_install_str = "{}conda{}{}{}".format('"', equals, conda_version, '"')
356354

357355
try:
358356
## py3 *args. (Syntax error in py2)
@@ -529,11 +527,12 @@ def install_checksum(pkg_names, ggd_jdict, prefix=conda_root()):
529527
2) raises "ChecksumError" if fails
530528
"""
531529
import tarfile
530+
532531
from .utils import (
533-
get_conda_package_list,
534-
get_checksum_dict_from_tar,
535-
data_file_checksum,
536532
ChecksumError,
533+
data_file_checksum,
534+
get_checksum_dict_from_tar,
535+
get_conda_package_list,
537536
)
538537

539538
print("\n:ggd:install: Initiating data file content validation using checksum")
@@ -698,12 +697,12 @@ def install(parser, args):
698697

699698
## Check that the package is set up for installation into a different prefix if one is provided
700699
if diff_prefix and conda_prefix != conda_root():
701-
assert (
702-
"final-files" in ggd_jsonDict["packages"][pkg]["tags"]
703-
), ("\n\n:ggd:install: !!ERROR!! the --prefix flag was set but the '{}' data package is not set up"
700+
assert "final-files" in ggd_jsonDict["packages"][pkg]["tags"], (
701+
"\n\n:ggd:install: !!ERROR!! the --prefix flag was set but the '{}' data package is not set up"
704702
" to be installed into a different prefix. GGD is unable to fulfill the install request. Remove the"
705703
" --prefix flag to install this data package. Notify the ggd team if you would like this recipe"
706-
" to be updated for --prefix install compatibility").format(pkg)
704+
" to be updated for --prefix install compatibility"
705+
).format(pkg)
707706

708707
## Check if the recipe is already installed
709708
if check_if_installed(pkg, ggd_jsonDict, conda_prefix) == False:

ggd/list_files.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,7 @@ def add_list_files(p):
5555
default=None,
5656
help="(Optional) The name or the full directory path to an conda environment where a ggd recipe is stored. (Only needed if not getting file paths for files in the current conda environment)",
5757
)
58-
c.add_argument(
59-
"name",
60-
help="recipe name"
61-
)
58+
c.add_argument("name", help="recipe name")
6259
c.set_defaults(func=list_files)
6360

6461

@@ -117,7 +114,6 @@ def in_ggd_channel(ggd_recipe, ggd_channel):
117114
if len(json_dict["packages"].keys()) > 0:
118115
package_list = search_packages(json_dict, [ggd_recipe])
119116

120-
121117
if ggd_recipe in package_list:
122118
species = json_dict["packages"][ggd_recipe]["identifiers"]["species"]
123119
build = json_dict["packages"][ggd_recipe]["identifiers"]["genome-build"]
@@ -140,6 +136,7 @@ def list_files(parser, args):
140136
"""Main method. Method used to list files for an installed ggd-recipe"""
141137

142138
import glob
139+
143140
from .utils import (
144141
conda_root,
145142
get_conda_prefix_path,

ggd/list_installed_pkgs.py

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
## Argument Parser
1616
# -------------------------------------------------------------------------------------------------------------
1717
def add_list_installed_packages(p):
18-
18+
1919
import argparse
2020

2121
c = p.add_parser(
@@ -33,11 +33,7 @@ def add_list_installed_packages(p):
3333
default=None,
3434
help="(Optional) The name or the full directory path to a conda environment where a ggd recipe is stored. (Only needed if listing data files not in the current environment)",
3535
)
36-
c.add_argument(
37-
"--reset",
38-
action="store_true",
39-
help=argparse.SUPPRESS
40-
)
36+
c.add_argument("--reset", action="store_true", help=argparse.SUPPRESS)
4137
c.set_defaults(func=list_installed_packages)
4238

4339

@@ -123,7 +119,7 @@ def list_pkg_info(pkg_names, pkgs_dict, env_vars, conda_list, prefix, prefix_set
123119
]
124120

125121
missing_in_conda = False
126-
missing_message = " [WARNING: Present in GGD but missing from Conda]"
122+
missing_message = " [WARNING: Present in GGD but missing from Conda]"
127123
## Iterate over each package in pkg_names
128124
for pkg in pkg_names:
129125

@@ -141,7 +137,7 @@ def list_pkg_info(pkg_names, pkgs_dict, env_vars, conda_list, prefix, prefix_set
141137
missing_in_conda = True
142138
build = missing_message
143139
channel = ""
144-
140+
145141
## Get env_vars
146142
env_variables = []
147143
if (
@@ -202,11 +198,15 @@ def list_pkg_info(pkg_names, pkgs_dict, env_vars, conda_list, prefix, prefix_set
202198

203199
## Print message if a package is missing from conda metadata
204200
if missing_in_conda:
205-
print(("#\n# NOTE: Packages with the '{}' messages represent packages where the ggd"
206-
" packages is installed, but the package metadata has been removed from conda storage. This happens when"
207-
" the packages is uninstalled using conda rather then ggd. The package is still available for use and is"
208-
" in the same state as before the 'conda uninstall'. To fix the problem on conda's side, uninstall"
209-
" the package with 'ggd uninstall' and re-install with 'ggd install'.\n").format(missing_message))
201+
print(
202+
(
203+
"#\n# NOTE: Packages with the '{}' messages represent packages where the ggd"
204+
" packages is installed, but the package metadata has been removed from conda storage. This happens when"
205+
" the packages is uninstalled using conda rather then ggd. The package is still available for use and is"
206+
" in the same state as before the 'conda uninstall'. To fix the problem on conda's side, uninstall"
207+
" the package with 'ggd uninstall' and re-install with 'ggd install'.\n"
208+
).format(missing_message)
209+
)
210210

211211

212212
def list_installed_packages(parser, args):
@@ -221,8 +221,8 @@ def list_installed_packages(parser, args):
221221

222222
from .utils import (
223223
conda_root,
224-
get_conda_prefix_path,
225224
get_conda_package_list,
225+
get_conda_prefix_path,
226226
prefix_in_conda,
227227
update_installed_pkg_metadata,
228228
)
@@ -234,14 +234,18 @@ def list_installed_packages(parser, args):
234234
else conda_root()
235235
)
236236

237-
## If reset list
237+
## If reset list
238238
if args.reset:
239-
print("\n:ggd:list: The --reset flag was set. RESETTING ggd installed list metadata.")
239+
print(
240+
"\n:ggd:list: The --reset flag was set. RESETTING ggd installed list metadata."
241+
)
240242
update_installed_pkg_metadata(args.prefix)
241-
print("\n:ggd:list: Run 'ggd list' without --reset to see a list of installed ggd data packages")
243+
print(
244+
"\n:ggd:list: Run 'ggd list' without --reset to see a list of installed ggd data packages"
245+
)
242246
print("\nDONE\n")
243247
sys.exit(0)
244-
248+
245249
ggd_info_path = os.path.join(CONDA_ROOT, GGD_INFO)
246250

247251
## Check that the ggd info dir exists. If not, create it

ggd/list_pkg_info.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,20 @@ def get_meta_yaml_info(tarball_info_object, ggd_recipe, ggd_channel):
107107
108108
"""
109109
import glob
110+
110111
import yaml
111-
from .utils import literal_block, add_yaml_literal_block
112+
113+
from .utils import add_yaml_literal_block, literal_block
112114

113115
dash = " " + "-" * 100
114116
print("\n\n", dash)
115117

116118
yaml_dict = yaml.safe_load(tarball_info_object)
117119
## Add literal block if needed
118120
if "genome_file" in yaml_dict["extra"]:
119-
yaml_dict["extra"]["genome_file"]["commands"] = utils.literal_block(yaml_dict["extra"]["genome_file"]["commands"])
121+
yaml_dict["extra"]["genome_file"]["commands"] = utils.literal_block(
122+
yaml_dict["extra"]["genome_file"]["commands"]
123+
)
120124
utils.add_yaml_literal_block(yaml)
121125

122126
species = yaml_dict["about"]["identifiers"]["species"]
@@ -211,7 +215,15 @@ def get_meta_yaml_info(tarball_info_object, ggd_recipe, ggd_channel):
211215
+ "Approximate Data File Sizes:"
212216
+ "\033[0m"
213217
+ " {}".format(
214-
"\n\t\t" + "\n\t\t".join(["{}: {}".format(x,yaml_dict["about"]["tags"]["final-file-sizes"][x]) for x in yaml_dict["about"]["tags"]["final-file-sizes"]])
218+
"\n\t\t"
219+
+ "\n\t\t".join(
220+
[
221+
"{}: {}".format(
222+
x, yaml_dict["about"]["tags"]["final-file-sizes"][x]
223+
)
224+
for x in yaml_dict["about"]["tags"]["final-file-sizes"]
225+
]
226+
)
215227
)
216228
)
217229

@@ -285,6 +297,7 @@ def get_pkg_info(ggd_recipe, ggd_channel, show_recipe):
285297
3) show_recipe: A bool value, where if true will print the recipe.sh script
286298
"""
287299
import tarfile
300+
288301
from .utils import get_conda_package_list
289302

290303
## Get a list of installed ggd packages using conda list

ggd/make_bash.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def add_make_bash(p):
8080
c2.add_argument(
8181
"-dv",
8282
"--data-version",
83-
help="The version of the data (itself) being downloaded and processed (EX: dbsnp-127)" +
84-
" If there is no data version apparent we recommend you use the date associated with the files" +
85-
" or something else that can uniquely identify the 'version' of the data",
83+
help="The version of the data (itself) being downloaded and processed (EX: dbsnp-127)"
84+
+ " If there is no data version apparent we recommend you use the date associated with the files"
85+
+ " or something else that can uniquely identify the 'version' of the data",
8686
required=True,
8787
)
8888
c2.add_argument(
@@ -135,6 +135,7 @@ def make_bash(parser, args):
135135

136136
import shutil
137137
import sys
138+
138139
import yaml
139140

140141
name = (
@@ -163,7 +164,8 @@ def make_bash(parser, args):
163164
assert (
164165
args.summary.strip() != ""
165166
), "Please provide a thorough summary of the data package"
166-
print("\n:ggd:make-recipe: Name of recipe: {0}-{1}-{2}-v{3}\n".format(
167+
print(
168+
"\n:ggd:make-recipe: Name of recipe: {0}-{1}-{2}-v{3}\n".format(
167169
args.genome_build.lower(),
168170
args.name.lower(),
169171
data_provider.lower(),
@@ -237,22 +239,19 @@ def make_bash(parser, args):
237239
)
238240
)
239241

240-
241-
242242
from .search import load_json
243243
from .utils import get_channel_data
244244

245245
## Get a list of ggd packages
246246
ggd_packages = set()
247247
for channel in CHANNEL_LIST:
248-
channel = channel.decode("utf-8") if not isinstance(channel,str) else channel
248+
channel = channel.decode("utf-8") if not isinstance(channel, str) else channel
249249
json_dict = load_json(get_channel_data(channel))
250250
ggd_packages.update(json_dict["packages"].keys())
251251

252-
## Get non-ggd dependencies
252+
## Get non-ggd dependencies
253253
non_ggd_deps = [x for x in deps if x not in ggd_packages]
254254

255-
256255
extra_files = []
257256
for f in args.extra_file:
258257
flist = f.strip().split(".")
@@ -262,9 +261,7 @@ def make_bash(parser, args):
262261
## Check coordinates
263262
assert (
264263
args.coordinate_base in GENOMIC_COORDINATE_LIST
265-
), "{c} is not an acceptable genomic coordinate base".format(
266-
c=args.coordinate_base
267-
)
264+
), "{c} is not an acceptable genomic coordinate base".format(c=args.coordinate_base)
268265
# ("Please provide a genomic coordinate base from the follow list: {}".format(", ".join(GENOMIC_COORDINATE_LIST)))
269266

270267
## Check data version

ggd/predict_path.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ def get_ggd_metadata(ggd_channel):
6868
1) GGD metadata as a dictionary
6969
7070
"""
71-
from .utils import check_for_internet_connection, get_channeldata_url
7271
from .search import load_json_from_url
72+
from .utils import check_for_internet_connection, get_channeldata_url
7373

7474
json_dict = {"channeldata_version": 1, "packages": {}}
7575
if check_for_internet_connection(3):
@@ -88,6 +88,7 @@ def predict_path(parser, args):
8888
""" Main method. Method used to predict the installed data file path for a data file that has not bee installed yet"""
8989
import os
9090
import re
91+
9192
from .utils import conda_root, get_conda_prefix_path, prefix_in_conda
9293

9394
## get prefix
@@ -166,5 +167,3 @@ def predict_path(parser, args):
166167
file_name,
167168
)
168169
print(path)
169-
170-

0 commit comments

Comments
 (0)