Skip to content

Commit 49f186a

Browse files
authored
Merge pull request #116 from CHIMEFRB/115-feature-downloading-specific-files
feat(pull): allows specific files to be pulled by designating names o…
2 parents 094f353 + fed9342 commit 49f186a

2 files changed

Lines changed: 22 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])

tests/test_cli.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ def test_cli_pull_help(runner: CliRunner) -> None:
141141
142142
Options:
143143
-d, --directory DIRECTORY Directory to pull data to.
144+
-s, --specific FILE Specific files to pull
144145
-c, --cores INTEGER RANGE Number of parallel fetch processes to use.
145146
[1<=x<={cpu_count()}]
146147
-v, --verbose Verbosity: v=INFO, vv=DEBUG.

0 commit comments

Comments
 (0)