Skip to content

Add preference file support for Brian2CUDA (issue #281)#322

Open
nishantraghuvanshi wants to merge 1 commit intobrian-team:masterfrom
nishantraghuvanshi:fix/issue-281-preference-files
Open

Add preference file support for Brian2CUDA (issue #281)#322
nishantraghuvanshi wants to merge 1 commit intobrian-team:masterfrom
nishantraghuvanshi:fix/issue-281-preference-files

Conversation

@nishantraghuvanshi
Copy link
Copy Markdown

Implemented automatic loading of Brian2CUDA-specific preferences from dedicated preference files, avoiding validation errors that occur when external package preferences are added to Brian2's main preference file.

Changes:

  • Added _load_preference_files() function to brian2cuda/init.py
  • Checks ~/.brian2cuda_preferences (user-wide preferences)
  • Checks ./brian2cuda_preferences (project-specific preferences)
  • Silently ignores missing files, warns on invalid files
  • Added 3 unit tests to brian2cuda/tests/test_gpu_detection.py

Based on approach suggested by @mstimberg in brian-team/brian2#1340

Please do tell me if there are any problems with this or any changes required.
@denisalevi
Fixes #281

Implement automatic loading of Brian2CUDA-specific preferences from
dedicated preference files, avoiding validation errors that occur when
external package preferences are added to Brian2's main preference file.

Changes:
- Added _load_preference_files() function to brian2cuda/__init__.py
- Checks ~/.brian2cuda_preferences (user-wide preferences)
- Checks ./brian2cuda_preferences (project-specific preferences)
- Silently ignores missing files, warns on invalid files
- Added 3 unit tests to brian2cuda/tests/test_gpu_detection.py

Based on approach suggested by @mstimberg in brian-team/brian2#1340

Fixes brian-team#281
@mstimberg
Copy link
Copy Markdown
Member

Hi @nishantraghuvanshi, thanks for the PR and apologies for taking so long to coming back to it. This looks generally good, but note that in brian-team/brian2#1340 I proposed this as a temporary solution, since we'd have to add basically identical code to brian2cuda, brian2genn, and any other Brian extension package that wants to use preferences. Ideally, we'd come up with a more general solution – either, having some "deferred validation" mechanism, or having code similar to what you propose in a function that is included in brian2 itself, which can be called from within the extension package (e.g. brian2cuda would call brian2.load_preference_file("brian2cuda"), or maybe something that also checks that this file only defines brian2cuda-specific preferences).

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 this pull request may close these issues.

Impelement brian2cuda preference file support

2 participants