Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Uncaught exception in pull command #73

Closed
MWSammons opened this issue May 9, 2024 · 0 comments · Fixed by #74
Closed

[BUG] Uncaught exception in pull command #73

MWSammons opened this issue May 9, 2024 · 0 comments · Fixed by #74
Assignees

Comments

@MWSammons
Copy link
Contributor

@curtina ran into the following bug trying to pull down the following event

datatrail pull chime.event.intensity.raw 60011290 -vv
[12:46:16] DEBUG    `pull` called with:                                                      pull.py:69
           DEBUG    scope: chime.event.intensity.raw [<class 'str'>]                         pull.py:70
           DEBUG    dataset: 60011290 [<class 'str'>]                                        pull.py:71
           DEBUG    verbose: 2 [<class 'int'>]                                               pull.py:72
           DEBUG    quiet: False [<class 'bool'>]                                            pull.py:73
           DEBUG    Loading config.                                                          pull.py:77
           DEBUG    Site set to: local.                                                      pull.py:80
           INFO     No directory, setting to: ./.                                            pull.py:83

Searching for files for 60011290 chime.event.intensity.raw...

[12:46:17] INFO     Finding files for 60011290 in chime.event.intensity.raw.           functions.py:186
           DEBUG    Payload: {'scope': 'chime.event.intensity.raw', 'name':            functions.py:188
                    '60011290'}                                                                        
           DEBUG    URL: https://frb.chimenet.ca/datatrail/query/dataset/find          functions.py:190
           DEBUG    Status: 500.                                                       functions.py:192
           DEBUG    Decoding response.                                                 functions.py:193
           INFO     Checking for local copies of files.                                functions.py:227
╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮
│ /Users/mawsonsammons/Documents/McGill/.venv/bin/datatrail:8 in <module>                          │
│                                                                                                  │
│   5 from dtcli.cli import cli                                                                    │
│   6 if __name__ == '__main__':                                                                   │
│   7 │   sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])                         │
│ ❱ 8 │   sys.exit(cli())                                                                          │
│   9                                                                                              │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/click/core.py:1157 in   │
│ __call__                                                                                         │
│                                                                                                  │
│   1154 │                                                                                         │
│   1155 │   def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Any:                           │
│   1156 │   │   """Alias for :meth:`main`."""                                                     │
│ ❱ 1157 │   │   return self.main(*args, **kwargs)                                                 │
│   1158                                                                                           │
│   1159                                                                                           │
│   1160 class Command(BaseCommand):                                                               │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/click/core.py:1078 in   │
│ main                                                                                             │
│                                                                                                  │
│   1075 │   │   try:                                                                              │
│   1076 │   │   │   try:                                                                          │
│   1077 │   │   │   │   with self.make_context(prog_name, args, **extra) as ctx:                  │
│ ❱ 1078 │   │   │   │   │   rv = self.invoke(ctx)                                                 │
│   1079 │   │   │   │   │   if not standalone_mode:                                               │
│   1080 │   │   │   │   │   │   return rv                                                         │
│   1081 │   │   │   │   │   # it's not safe to `ctx.exit(rv)` here!                               │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/click/core.py:1688 in   │
│ invoke                                                                                           │
│                                                                                                  │
│   1685 │   │   │   │   super().invoke(ctx)                                                       │
│   1686 │   │   │   │   sub_ctx = cmd.make_context(cmd_name, args, parent=ctx)                    │
│   1687 │   │   │   │   with sub_ctx:                                                             │
│ ❱ 1688 │   │   │   │   │   return _process_result(sub_ctx.command.invoke(sub_ctx))               │
│   1689 │   │                                                                                     │
│   1690 │   │   # In chain mode we create the contexts step by step, but after the                │
│   1691 │   │   # base command has been invoked.  Because at that point we do not                 │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/click/core.py:1434 in   │
│ invoke                                                                                           │
│                                                                                                  │
│   1431 │   │   │   echo(style(message, fg="red"), err=True)                                      │
│   1432 │   │                                                                                     │
│   1433 │   │   if self.callback is not None:                                                     │
│ ❱ 1434 │   │   │   return ctx.invoke(self.callback, **ctx.params)                                │
│   1435 │                                                                                         │
│   1436 │   def shell_complete(self, ctx: Context, incomplete: str) -> t.List["CompletionItem"]:  │
│   1437 │   │   """Return a list of completions for the incomplete value. Looks                   │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/click/core.py:783 in    │
│ invoke                                                                                           │
│                                                                                                  │
│    780 │   │                                                                                     │
│    781 │   │   with augment_usage_errors(__self):                                                │
│    782 │   │   │   with ctx:                                                                     │
│ ❱  783 │   │   │   │   return __callback(*args, **kwargs)                                        │
│    784 │                                                                                         │
│    785 │   def forward(                                                                          │
│    786 │   │   __self, __cmd: "Command", *args: t.Any, **kwargs: t.Any  # noqa: B902             │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/click/decorators.py:33  │
│ in new_func                                                                                      │
│                                                                                                  │
│    30 │   """                                                                                    │
│    31 │                                                                                          │
│    32 │   def new_func(*args: "P.args", **kwargs: "P.kwargs") -> "R":                            │
│ ❱  33 │   │   return f(get_current_context(), *args, **kwargs)                                   │
│    34 │                                                                                          │
│    35 │   return update_wrapper(new_func, f)                                                     │
│    36                                                                                            │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/dtcli/pull.py:98 in     │
│ pull                                                                                             │
│                                                                                                  │
│    95 │                                                                                          │
│    96 │   # Find files missing from localhost.                                                   │
│    97 │   console.print(f"\nSearching for files for {dataset} {scope}...\n")                     │
│ ❱  98 │   files = find_missing_dataset_files(scope, dataset, directory, verbose)                 │
│    99 │   if len(files["missing"]) == 0 and len(files["existing"]) == 0:                         │
│   100 │   │   console.print("No files found at minoc.", style="bold red")                        │
│   101 │   │   return None                                                                        │
│                                                                                                  │
│ /Users/mawsonsammons/Documents/McGill/.venv/lib/python3.11/site-packages/dtcli/src/functions.py: │
│ 228 in find_missing_dataset_files                                                                │
│                                                                                                  │
│   225 │                                                                                          │
│   226 │   # check for local copy of the data.                                                    │
│   227 │   logger.info("Checking for local copies of files.")                                     │
│ ❱ 228 │   if dataset_locations["file_replica_locations"].get("minoc"):                           │
│   229 │   │   file_uris = dataset_locations["file_replica_locations"]["minoc"]                   │
│   230 │   │   file_paths = []                                                                    │
│   231 │   │   # Clean up file paths                                                              │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯
KeyError: 'file_replica_locations'

This occurs because the function get_dataset_file_info returns a dictionary {"error": f"Could not find {dataset} {scope} in Datatrail."} but the error checking line in 'find_missing_datasets' is expecting a string upon error :

221     dataset_locations = get_dataset_file_info(scope, dataset, verbose=verbose)
222     if isinstance(dataset_locations, str):
223         print(f"Could not find the dataset: {scope}, {dataset}")
224         return {}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant