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

[ENH] Avoid hidden modification of variables within find_sub_ses_pattern_path / remove Parallel processing #1309

Open
AliceJoubert opened this issue Oct 1, 2024 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@AliceJoubert
Copy link
Contributor

As noticed in PR #1285, the function find_sub_ses_pattern_path (renamed as find_images_path) from utils/inputs.py currently returns nothing because it modifies its input :

def find_sub_ses_pattern_path(
input_directory: os.PathLike,
subject: str,
session: str,
error_encountered: list,
results: list,
is_bids: bool,
pattern: str,
) -> None:

The lists results and error_encountered are incremented within the function. It would be better to have it copy the input and return the modified version of the copy rather than modifying the input sneakily.

This function is only used twice, including in a Parallel processing :

manager = Manager()
shared_results = manager.list()
shared_errors_encountered = manager.list()
Parallel(n_jobs=n_procs)(
delayed(find_sub_ses_pattern_path)(
input_directory,
sub,
ses,
shared_errors_encountered,
shared_results,
is_bids,
pattern,
)
for sub, ses in zip(subjects, sessions)
)

That Parallel processing may not be efficient for the task it is used for, and could be replaced (to investigate).

@AliceJoubert AliceJoubert added the enhancement New feature or request label Oct 1, 2024
@AliceJoubert AliceJoubert self-assigned this Oct 1, 2024
Copy link

This issue is considered stale because it has not received further activity for the last 14 days. You may remove the inactive label or add a comment, otherwise it will be closed after the next 14 days.

@github-actions github-actions bot added the inactive Issue or request has gone stale label Dec 31, 2024
@AliceJoubert AliceJoubert removed the inactive Issue or request has gone stale label Dec 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant