Skip to content

[BUG] Empty custom_atlases.conf file leads to crash #668

@IgorTatarnikov

Description

@IgorTatarnikov

If the custom_atlases.conf file is present in the BrainGlobe directory but empty brainglobe list results in a crash.

Traceback below:

Traceback (most recent call last):
  File "/home/igor/miniforge3/envs/brainglobe-atlasapi/bin/brainglobe", line 8, in <module>
    sys.exit(bg_cli())
             ^^^^^^^^
  File "/home/igor/miniforge3/envs/brainglobe-atlasapi/lib/python3.12/site-packages/click/core.py", line 1442, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/igor/miniforge3/envs/brainglobe-atlasapi/lib/python3.12/site-packages/click/core.py", line 1363, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/home/igor/miniforge3/envs/brainglobe-atlasapi/lib/python3.12/site-packages/click/core.py", line 1226, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/igor/miniforge3/envs/brainglobe-atlasapi/lib/python3.12/site-packages/click/core.py", line 794, in invoke
    return callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/igor/NIU-dev/bg-atlasapi/brainglobe_atlasapi/cli.py", line 43, in bg_cli
    return show_atlases(show_local_path=show)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/igor/NIU-dev/bg-atlasapi/brainglobe_atlasapi/list_atlases.py", line 124, in show_atlases
    available_atlases = get_all_atlases_lastversions()
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/igor/NIU-dev/bg-atlasapi/brainglobe_atlasapi/list_atlases.py", line 76, in get_all_atlases_lastversions
    return {**official_atlases["atlases"], **custom_atlases["atlases"]}
                                             ~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/igor/miniforge3/envs/brainglobe-atlasapi/lib/python3.12/configparser.py", line 941, in __getitem__
    raise KeyError(key)
KeyError: 'atlases'

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions