Skip to content

Commit

Permalink
fix(functions): changed return of find_missing_datasets to always ret… (
Browse files Browse the repository at this point in the history
#76)

* fix(functions): changed return of find_missing_datasets to always return a consistent data type

* refactor(cli-ps-and-pull): simplify error message and standardise display method

Signed-off-by: Tarik Zegmott <[email protected]>

---------

Signed-off-by: Tarik Zegmott <[email protected]>
Co-authored-by: Mawson Sammons <[email protected]>
Co-authored-by: Tarik Zegmott <[email protected]>
  • Loading branch information
3 people authored May 10, 2024
1 parent 1d34e6f commit a8c0f3d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dtcli/ps.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def ps(
try:
files, policies = functions.ps(scope, dataset, verbose, quiet)
except Exception as e:
logger.error(e)
error_console.print(e)
return None

if show_files and files:
Expand Down
5 changes: 4 additions & 1 deletion dtcli/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ def pull(
# Find files missing from localhost.
console.print(f"\nSearching for files for {dataset} {scope}...\n")
files = find_missing_dataset_files(scope, dataset, directory, verbose)
if len(files["missing"]) == 0 and len(files["existing"]) == 0:
if files.get("error"):
error_console.print(files["error"])
return None
elif len(files["missing"]) == 0 and len(files["existing"]) == 0:
console.print("No files found at minoc.", style="bold red")
return None
files_paths = [f.replace("cadc:CHIMEFRB", "") for f in files["missing"]]
Expand Down
3 changes: 1 addition & 2 deletions dtcli/src/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@ def find_missing_dataset_files(
# find dataset
dataset_locations = get_dataset_file_info(scope, dataset, verbose=verbose)
if "error" in dataset_locations:
print(dataset_locations["error"])
return {}
return {"error": dataset_locations["error"]}

# check for local copy of the data.
logger.info("Checking for local copies of files.")
Expand Down

0 comments on commit a8c0f3d

Please sign in to comment.