Skip to content

Commit d3cfb59

Browse files
Mawson SammonsMawson Sammons
authored andcommitted
feat(pull): allows specific files to be pulled by designating names or paths in a local config file
1 parent 999497d commit d3cfb59

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

dtcli/pull.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@
3131
default=None,
3232
help="Directory to pull data to.",
3333
)
34+
@click.option(
35+
"--specific",
36+
"-s",
37+
type=click.Path(
38+
exists=True, file_okay=True, dir_okay=False, writable=True, resolve_path=True
39+
),
40+
default=None,
41+
help="Specific files to pull",
42+
)
3443
@click.option(
3544
"--cores",
3645
"-c",
@@ -47,6 +56,7 @@ def pull( # noqa: C901
4756
scope: str,
4857
dataset: str,
4958
directory: str,
59+
specific: str,
5060
cores: int,
5161
verbose: int,
5262
quiet: bool,
@@ -59,6 +69,7 @@ def pull( # noqa: C901
5969
scope (str): Scope of dataset.
6070
dataset (str): Name of dataset.
6171
directory (str): Directory to pull data to.
72+
specific (str): Path to file of specific files to pull.
6273
cores(int): Number of parallel fetch processes to use.
6374
verbose (int): Verbosity: v=INFO, vv=DUBUG.
6475
quiet (bool): Minimal logging.
@@ -117,6 +128,16 @@ def pull( # noqa: C901
117128
elif len(files["missing"]) == 0 and len(files["existing"]) == 0:
118129
console.print("No files found at minoc.", style="bold red")
119130
return None
131+
if specific:
132+
console.print(f"\nConsidering only specific files list in {specific}")
133+
with open(specific) as sf:
134+
specific_paths = [line.strip() for line in sf if line.strip()]
135+
files["missing"] = [
136+
path
137+
for path in files["missing"]
138+
if any(spec_path in path for spec_path in specific_paths)
139+
]
140+
console.print(f"\nFound {len(files['missing'])} to download")
120141
files_paths = [f.replace("cadc:CHIMEFRB", "") for f in files["missing"]]
121142
if len(files_paths) > 0 and luskan_up:
122143
common_path = path.commonpath(["/" + f for f in files_paths])

0 commit comments

Comments
 (0)