Skip to content

Suggest next subject or session has confusing stacktrace #610

@JoeZiminski

Description

@JoeZiminski

To reproduce, run the below script (change paths as required). See stacktrace below.

The error at the very bottom is correct, however there are multiple failures which makes reading the stacktrace very confusing.

from datashuttle import DataShuttle

project = DataShuttle("my_second_project")

project.make_config_file(
   local_path=r"C:\Users\Joe\my_projects\local\my_first_project\.datashuttle\logs\local",
   connection_method="local_filesystem",
   central_path=r"C:\Users\Joe\my_projects\local\my_first_project\.datashuttle\logs\central"
)

project.create_folders(
   top_level_folder="rawdata",
   sub_names="sub-abc",
   ses_names="ses-a",
   datatype="behav",
   bypass_validation=True
)


next_sub = project.get_next_sub("rawdata")

C:\Users\Joe\miniconda3\envs\datashuttle11\python.exe C:\Users\Joe\PycharmProjects\datashuttle11\main.py 
C:\Users\Joe\work\git-repos\datashuttle\datashuttle\configs\load_configs.py:45: UserWarning: Configuration file has not been initialized. Use make_config_file() to setup before continuing.
  warnings.warn(
Making project folder at: C:\Users\Joe\my_projects\local\my_first_project\.datashuttle\logs\local\my_second_project
Configuration file has been saved and options loaded into datashuttle.
Finished making folders.
For log of all created folders, please see C:\Users\Joe\my_projects\local\my_first_project\.datashuttle\logs\local\my_second_project\.datashuttle\logs
Traceback (most recent call last):
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\utils.py", line 277, in sub_or_ses_value_to_int
    int_value = int(value)
ValueError: invalid literal for int() with base 10: 'abc'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\getters.py", line 204, in get_max_sub_or_ses_num_and_value_length
    int_value = utils.sub_or_ses_value_to_int(value)
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\utils.py", line 279, in sub_or_ses_value_to_int
    raise NeuroBlueprintError(
datashuttle.utils.custom_exceptions.NeuroBlueprintError: Invalid character in subject or session value: abc

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Joe\PycharmProjects\datashuttle11\main.py", line 21, in <module>
    next_sub = project.get_next_sub("rawdata")
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\decorators.py", line 66, in wrapper
    return func(*args, **kwargs)
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\datashuttle_class.py", line 1177, in get_next_sub
    return getters.get_next_sub_or_ses(
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\getters.py", line 108, in get_next_sub_or_ses
    ) = get_max_sub_or_ses_num_and_value_length(
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\getters.py", line 208, in get_max_sub_or_ses_num_and_value_length
    utils.log_and_raise_error(
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\utils.py", line 54, in log_and_raise_error
    raise_error(message, exception)
  File "C:\Users\Joe\work\git-repos\datashuttle\datashuttle\utils\utils.py", line 82, in raise_error
    raise exception(message)
datashuttle.utils.custom_exceptions.NeuroBlueprintError: Cannot suggest next sub because not all sub labels in the project are integer. e.g. sub-abc

Process finished with exit code 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions