-
Notifications
You must be signed in to change notification settings - Fork 6
138 feature citation reminder #143
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
Changes from all commits
8e8085b
be957bd
a04b757
7cf0044
9349944
052988e
1769994
ea83647
062be13
56cfd1e
3201785
50e7ac6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,41 @@ | ||||||||||||
| import functools | ||||||||||||
| import os | ||||||||||||
|
|
||||||||||||
| from rich.console import Console | ||||||||||||
|
|
||||||||||||
| CITATION_LINK = "https://github.com/BrainLesion/preprocessing#citation" | ||||||||||||
|
|
||||||||||||
|
|
||||||||||||
| def citation_reminder(func): | ||||||||||||
| """ | ||||||||||||
| Decorator to remind users to cite brainles-preprocessing. | ||||||||||||
|
|
||||||||||||
| The reminder is shown when the environment variable | ||||||||||||
| `BRAINLES_PREPROCESSING_CITATION_REMINDER` is set to "true" (default). | ||||||||||||
| To disable the reminder, set the environment variable to "false". | ||||||||||||
|
|
||||||||||||
| Environment variable used: | ||||||||||||
| - BRAINLES_PREPROCESSING_CITATION_REMINDER: Controls whether the reminder is shown. | ||||||||||||
| """ | ||||||||||||
|
|
||||||||||||
| @functools.wraps(func) | ||||||||||||
| def wrapper(*args, **kwargs): | ||||||||||||
| if ( | ||||||||||||
| os.environ.get("BRAINLES_PREPROCESSING_CITATION_REMINDER", "true").lower() | ||||||||||||
|
||||||||||||
| os.environ.get("BRAINLES_PREPROCESSING_CITATION_REMINDER", "true").lower() | |
| os.environ.get("BRAINLES_CITE_REMINDER", "true").lower() |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The environment variable is checked on every function call. Consider caching this value at module level or checking it only once to avoid repeated environment variable lookups.
| if ( | |
| os.environ.get("BRAINLES_PREPROCESSING_CITATION_REMINDER", "true").lower() | |
| == "true" | |
| ): | |
| if CITATION_REMINDER_ENABLED: |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a new Console instance on every function call is inefficient. Consider creating a module-level Console instance to reuse across calls.
| console = Console() |
Copilot
AI
Jul 17, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The console.line() call adds unnecessary whitespace. Consider removing it or making it conditional based on user preference, as it may clutter the output when the reminder is shown frequently.
| console.line() | |
| if os.environ.get("BRAINLES_PREPROCESSING_EXTRA_LINE", "false").lower() == "true": | |
| console.line() |
Uh oh!
There was an error while loading. Please reload this page.