Skip to content

Commit 558f83a

Browse files
committed
Formatting
1 parent e0a587e commit 558f83a

8 files changed

Lines changed: 618 additions & 316 deletions

File tree

ggd/check_recipe.py

Lines changed: 129 additions & 71 deletions
Large diffs are not rendered by default.

ggd/install.py

Lines changed: 158 additions & 63 deletions
Large diffs are not rendered by default.

ggd/list_files.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
import os
77
import sys
88

9+
from .list_installed_pkgs import GGD_INFO, METADATA, get_metadata
910
from .utils import get_builds, get_ggd_channels, get_species
10-
from .list_installed_pkgs import get_metadata, GGD_INFO, METADATA
1111

1212
SPECIES_LIST = sorted(get_species())
1313
GENOME_BUILDS = sorted(get_builds("*"))
@@ -65,7 +65,9 @@ def add_list_files(p):
6565
# -------------------------------------------------------------------------------------------------------------
6666

6767

68-
def in_ggd_channel(ggd_recipes, ggd_channel, C_ROOT, reporting=True, return_pkg_list = False):
68+
def in_ggd_channel(
69+
ggd_recipes, ggd_channel, C_ROOT, reporting=True, return_pkg_list=False
70+
):
6971
"""Method to check if the desired ggd recipe is in the ggd channel
7072
7173
in_ggd_channel
@@ -111,7 +113,7 @@ def get_local_pkg_dict():
111113
==================
112114
Load the local install ggd packages from a json file into a dict.
113115
"""
114-
116+
115117
## Get local install list
116118
local_json_dict = get_metadata(C_ROOT, GGD_INFO, METADATA)
117119

@@ -121,11 +123,10 @@ def get_local_pkg_dict():
121123
if value["tags"]["ggd-channel"] != ggd_channel:
122124
rm_pkgs.append(pkg)
123125

124-
[local_json_dict["packages"].pop(key) for key in rm_pkgs]
126+
[local_json_dict["packages"].pop(key) for key in rm_pkgs]
125127

126128
return local_json_dict
127129

128-
129130
def get_package_list(j_dict):
130131
"""
131132
get_package_list
@@ -145,8 +146,7 @@ def get_package_list(j_dict):
145146
if len(json_dict["packages"].keys()) > 0:
146147
package_list = search_packages(j_dict, ggd_recipes)
147148

148-
return(package_list)
149-
149+
return package_list
150150

151151
json_dict = {"channeldata_version": 1, "packages": {}}
152152
if check_for_internet_connection(3):
@@ -169,11 +169,11 @@ def get_package_list(j_dict):
169169
package_list = get_package_list(json_dict)
170170

171171
## If no pkgs, check the local installed files
172-
if not all(True if recipe in package_list else False for recipe in ggd_recipes ):
172+
if not all(True if recipe in package_list else False for recipe in ggd_recipes):
173173
json_dict["packages"].update(get_local_pkg_dict()["packages"])
174174
package_list = get_package_list(json_dict)
175175

176-
if all(True if recipe in package_list else False for recipe in ggd_recipes ):
176+
if all(True if recipe in package_list else False for recipe in ggd_recipes):
177177
if return_pkg_list:
178178
return (package_list, json_dict)
179179
else:

ggd/list_installed_pkgs.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,18 +201,18 @@ def list_pkg_info(pkg_names, pkgs_dict, env_vars, conda_list, prefix, prefix_set
201201
print(
202202
(
203203
"#\n# NOTE: Packages with the '{}' messages represent packages where the ggd"
204-
" package(s) are installed, but the package metadata has been removed from conda storage. This"
204+
" package(s) are installed, but the package metadata has been removed from conda storage. This"
205205
" happens when one of the following happen: \n 1) The package represents an ID specific meta-"
206206
"recipe installed by GGD. \n 2) When the recipe is built locally using 'ggd check-recipe' and"
207-
" has not been uninstalled. (Commonly for private data packages).\n Or \n 3) The package is"
207+
" has not been uninstalled. (Commonly for private data packages).\n Or \n 3) The package is"
208208
" uninstalled using conda rather then ggd. The package is still available for use and is in"
209209
" the same state as before the 'conda uninstall'. To fix the problem on conda's side, uninstall"
210210
" the package with 'ggd uninstall' and re-install with 'ggd install'.\n"
211211
).format(missing_message.strip())
212212
)
213213

214214

215-
def get_metadata(C_ROOT,GGD_INFO_DIR, METADATA_FILE):
215+
def get_metadata(C_ROOT, GGD_INFO_DIR, METADATA_FILE):
216216
"""
217217
get_metadata
218218
=============
@@ -228,14 +228,14 @@ def get_metadata(C_ROOT,GGD_INFO_DIR, METADATA_FILE):
228228
++++++++
229229
1) (dict) Metadata json file loaded as a dictionary
230230
"""
231-
231+
232232
try:
233233
metadata_dict = load_json(os.path.join(C_ROOT, GGD_INFO_DIR, METADATA_FILE))
234234
except IOError as e:
235235
print(str(e))
236236
sys.exit("\n:ggd:list: !!ERROR!! Unable to load the local metadata")
237237

238-
return(metadata_dict)
238+
return metadata_dict
239239

240240

241241
def list_installed_packages(parser, args):
@@ -282,7 +282,7 @@ def list_installed_packages(parser, args):
282282
update_installed_pkg_metadata(prefix=CONDA_ROOT)
283283

284284
## Load json metadata data as dictionary
285-
#metadata = load_json(os.path.join(CONDA_ROOT, GGD_INFO, METADATA))
285+
# metadata = load_json(os.path.join(CONDA_ROOT, GGD_INFO, METADATA))
286286
metadata = get_metadata(CONDA_ROOT, GGD_INFO, METADATA)
287287

288288
## Get the environment variables

ggd/list_pkg_info.py

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def add_pkg_info(p):
4545
# -------------------------------------------------------------------------------------------------------------
4646

4747

48-
def check_if_ggd_recipe(ggd_recipe, ggd_channel, prefix = conda_root()):
48+
def check_if_ggd_recipe(ggd_recipe, ggd_channel, prefix=conda_root()):
4949
"""Method to check if a ggd recipe is in designated ggd channel or not
5050
5151
check_if_ggd_recipe
@@ -76,7 +76,9 @@ def check_if_ggd_recipe(ggd_recipe, ggd_channel, prefix = conda_root()):
7676
return False
7777

7878

79-
def get_meta_yaml_info(tarball_info_object, ggd_recipe, ggd_channel, prefix = conda_root()):
79+
def get_meta_yaml_info(
80+
tarball_info_object, ggd_recipe, ggd_channel, prefix=conda_root()
81+
):
8082
"""Method to get information from the meta.yaml file of an installed ggd package
8183
8284
get_meta_yaml_info
@@ -111,11 +113,19 @@ def get_meta_yaml_info(tarball_info_object, ggd_recipe, ggd_channel, prefix = co
111113
)
112114
utils.add_yaml_literal_block(yaml)
113115

114-
species = yaml_dict["about"]["identifiers"]["species"]
115-
genome_build = yaml_dict["about"]["identifiers"]["genome-build"]
116+
species = yaml_dict["about"]["identifiers"]["species"]
117+
genome_build = yaml_dict["about"]["identifiers"]["genome-build"]
116118

117-
report_species = yaml_dict["about"]["identifiers"]["species"] if "updated-species" not in yaml_dict["about"]["identifiers"] else "(Updated) " + yaml_dict["about"]["identifiers"]["updated-species"]
118-
report_genome_build = yaml_dict["about"]["identifiers"]["genome-build"] if "updated-genome-build" not in yaml_dict["about"]["identifiers"] else "(Updated) " + yaml_dict["about"]["identifiers"]["updated-genome-build"]
119+
report_species = (
120+
yaml_dict["about"]["identifiers"]["species"]
121+
if "updated-species" not in yaml_dict["about"]["identifiers"]
122+
else "(Updated) " + yaml_dict["about"]["identifiers"]["updated-species"]
123+
)
124+
report_genome_build = (
125+
yaml_dict["about"]["identifiers"]["genome-build"]
126+
if "updated-genome-build" not in yaml_dict["about"]["identifiers"]
127+
else "(Updated) " + yaml_dict["about"]["identifiers"]["updated-genome-build"]
128+
)
119129

120130
version = yaml_dict["package"]["version"]
121131

@@ -125,7 +135,11 @@ def get_meta_yaml_info(tarball_info_object, ggd_recipe, ggd_channel, prefix = co
125135
)
126136
if "parent-meta-recipe" in yaml_dict["about"]["identifiers"]:
127137
results.append(
128-
"\t" + "\033[1m" + "GGD Parent Meta-Recipe:" + "\033[0m" + " {}".format(yaml_dict["about"]["identifiers"]["parent-meta-recipe"])
138+
"\t"
139+
+ "\033[1m"
140+
+ "GGD Parent Meta-Recipe:"
141+
+ "\033[0m"
142+
+ " {}".format(yaml_dict["about"]["identifiers"]["parent-meta-recipe"])
129143
)
130144
results.append(
131145
"\t" + "\033[1m" + "GGD-Channel:" + "\033[0m" + " ggd-{}".format(ggd_channel)
@@ -140,9 +154,15 @@ def get_meta_yaml_info(tarball_info_object, ggd_recipe, ggd_channel, prefix = co
140154
+ "\033[0m"
141155
+ " {}".format(yaml_dict["about"]["summary"])
142156
)
143-
results.append("\t" + "\033[1m" + "Species:" + "\033[0m" + " {}".format(report_species))
144157
results.append(
145-
"\t" + "\033[1m" + "Genome Build:" + "\033[0m" + " {}".format(report_genome_build)
158+
"\t" + "\033[1m" + "Species:" + "\033[0m" + " {}".format(report_species)
159+
)
160+
results.append(
161+
"\t"
162+
+ "\033[1m"
163+
+ "Genome Build:"
164+
+ "\033[0m"
165+
+ " {}".format(report_genome_build)
146166
)
147167
if "keywords" in yaml_dict["about"] and yaml_dict["about"]["keywords"]:
148168
results.append(
@@ -278,7 +298,7 @@ def print_recipe(tarball_info_object, ggd_recipe):
278298
return True
279299

280300

281-
def get_pkg_info(ggd_recipe, ggd_channel, show_recipe, prefix = conda_root()):
301+
def get_pkg_info(ggd_recipe, ggd_channel, show_recipe, prefix=conda_root()):
282302
"""Method to get the package info from an installed package
283303
284304
get_pkg_info
@@ -298,7 +318,7 @@ def get_pkg_info(ggd_recipe, ggd_channel, show_recipe, prefix = conda_root()):
298318
from .utils import get_conda_package_list
299319

300320
## Get a list of installed ggd packages using conda list
301-
conda_package_list = get_conda_package_list(prefix, include_local = True)
321+
conda_package_list = get_conda_package_list(prefix, include_local=True)
302322

303323
## Check if ggd recipe in the list
304324
if ggd_recipe in conda_package_list.keys():
@@ -334,10 +354,7 @@ def get_pkg_info(ggd_recipe, ggd_channel, show_recipe, prefix = conda_root()):
334354
def info(parser, args):
335355
"""Main method to run list_pkg_info"""
336356

337-
from .utils import (
338-
get_conda_prefix_path,
339-
prefix_in_conda,
340-
)
357+
from .utils import get_conda_prefix_path, prefix_in_conda
341358

342359
## Check prefix
343360
CONDA_ROOT = (

ggd/make_meta_recipe.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
from __future__ import print_function
22

33
import os
4-
54
from shutil import copyfile
65

7-
from .utils import get_builds, get_ggd_channels, get_species
6+
from .utils import get_builds, get_ggd_channels, get_species
87

98
SPECIES_LIST = sorted(get_species())
109
GENOME_BUILDS = sorted(get_builds("*"))
@@ -25,7 +24,6 @@ def add_make_metarecipe(p):
2524
description="Make a ggd data meta-recipe",
2625
)
2726

28-
2927
c.add_argument(
3028
"-c",
3129
"--channel",
@@ -55,36 +53,36 @@ def add_make_metarecipe(p):
5553
"-s",
5654
"--species",
5755
help="The species recipe is for. Use 'meta-recipe` for a metarecipe file",
58-
default = "meta-recipe"
56+
default="meta-recipe",
5957
)
6058

6159
c.add_argument(
6260
"-g",
6361
"--genome-build",
6462
help="The genome build the recipe is for. Use 'metarecipe' for a metarecipe file",
65-
default = "meta-recipe"
63+
default="meta-recipe",
6664
)
6765

6866
c.add_argument(
6967
"-dv",
7068
"--data-version",
7169
help="The version of the data (itself) being downloaded and processed (EX: dbsnp-127). Use 'metarecipe' for a metarecipe",
72-
default = "meta-recipe"
70+
default="meta-recipe",
7371
)
7472

7573
c.add_argument(
7674
"-cb",
7775
"--coordinate-base",
7876
choices=GENOMIC_COORDINATE_LIST,
7977
help="The genomic coordinate basing for the file(s) in the recipe. Use 'NA' for a metarecipe",
80-
default = "NA"
78+
default="NA",
8179
)
8280

8381
c.add_argument(
8482
"--extra-scripts",
85-
metavar = "Extra Scripts",
86-
nargs = "*",
87-
help = "Any additional scripts used for the metarecipe that are not the main bash script"
83+
metavar="Extra Scripts",
84+
nargs="*",
85+
help="Any additional scripts used for the metarecipe that are not the main bash script",
8886
)
8987

9088
c2 = c.add_argument_group("required arguments")
@@ -127,7 +125,6 @@ def add_make_metarecipe(p):
127125
required=True,
128126
)
129127

130-
131128
c2.add_argument(
132129
"-n",
133130
"--name",
@@ -137,8 +134,7 @@ def add_make_metarecipe(p):
137134
)
138135

139136
c2.add_argument(
140-
"script",
141-
help="bash script that contains the commands for the metarecipe.",
137+
"script", help="bash script that contains the commands for the metarecipe.",
142138
)
143139

144140
c.set_defaults(func=make_bash)
@@ -224,8 +220,7 @@ def make_bash(parser, args):
224220

225221
from .check_recipe import _check_build
226222

227-
228-
# if args.genome_build != "meta-recipe":
223+
# if args.genome_build != "meta-recipe":
229224
print(":ggd:make-recipe: checking", args.genome_build)
230225
_check_build(args.species, args.genome_build)
231226

@@ -300,8 +295,8 @@ def make_bash(parser, args):
300295
}
301296
yml2 = {"extra": {"authors": args.authors}}
302297
yml3 = {"package": {"name": name, "version": args.package_version}}
303-
#yml3 = {"package": {"name": "{{ GGD_NAME_ID }}-" + args.data_provider.lower() + "-v" + args.package_version , "version": args.package_version}}
304-
#yml3 = {"package": {"name": """{{ environ.get("GGD_NAME_ID") }}-""" + args.data_provider.lower() + "-v" + args.package_version , "version": args.package_version}}
298+
# yml3 = {"package": {"name": "{{ GGD_NAME_ID }}-" + args.data_provider.lower() + "-v" + args.package_version , "version": args.package_version}}
299+
# yml3 = {"package": {"name": """{{ environ.get("GGD_NAME_ID") }}-""" + args.data_provider.lower() + "-v" + args.package_version , "version": args.package_version}}
305300
yml4 = {"requirements": {"build": non_ggd_deps[:], "run": deps[:]}}
306301
yml5 = {"source": {"path": "."}}
307302
yml6 = {
@@ -429,7 +424,7 @@ def make_bash(parser, args):
429424
fh.write("#!/bin/sh\nset -eo pipefail -o nounset\n")
430425
fh.write(open(args.script).read())
431426

432-
## create empty recipe.sh script
427+
## create empty recipe.sh script
433428
open(os.path.join(name, "recipe.sh"), "a").close()
434429

435430
## Create empty checksum file
@@ -441,10 +436,8 @@ def make_bash(parser, args):
441436
% name
442437
)
443438

444-
445439
## Copy all extra scripts to the meta recipe directory
446440
for f in args.extra_scripts:
447441
copyfile(f, os.path.join(os.getcwd(), name, os.path.basename(f)))
448-
449442

450443
return True

ggd/uninstall.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,19 @@ def get_channeldata(ggd_recipes, ggd_channel):
5050
check_for_installation() method if it is found within the channeldata.json file
5151
5252
"""
53-
53+
5454
from .list_files import in_ggd_channel
5555

5656
## Check if recipe is in the ggd channel
5757
package_list = []
5858
try:
59-
package_list, jdict = in_ggd_channel(ggd_recipes, ggd_channel, conda_root(), reporting = False, return_pkg_list = True)
59+
package_list, jdict = in_ggd_channel(
60+
ggd_recipes,
61+
ggd_channel,
62+
conda_root(),
63+
reporting=False,
64+
return_pkg_list=True,
65+
)
6066
except SystemExit:
6167
pass
6268

@@ -70,7 +76,11 @@ def get_channeldata(ggd_recipes, ggd_channel):
7076
% (recipe, ggd_channel)
7177
)
7278
else:
73-
print("\n:ggd:uninstall: The '{}' channel is not a ggd conda channel".format(ggd_channel))
79+
print(
80+
"\n:ggd:uninstall: The '{}' channel is not a ggd conda channel".format(
81+
ggd_channel
82+
)
83+
)
7484

7585
similar_pkgs = get_similar_pkg_installed_by_conda(recipe)
7686
if len(similar_pkgs) > 0:
@@ -291,7 +301,7 @@ def uninstall(parser, args):
291301
sys.exit()
292302

293303
## Get the installed ggd data package names
294-
installed_ggd_packages = get_conda_package_list(conda_root(), include_local = True)
304+
installed_ggd_packages = get_conda_package_list(conda_root(), include_local=True)
295305

296306
## Check for GGD package as run deps
297307
### Add them to the uninstall list

0 commit comments

Comments
 (0)