-
-
Notifications
You must be signed in to change notification settings - Fork 41
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
🎨 print
statements → log
statements
#2062
Conversation
fix: python 2 Function interfaces recompatibility
Revert "fix: python 2 Function interfaces recompatibility"
(some were `nibabel as nb`)
91bb731
to
43f5f46
Compare
Where reformatting changed things like > ("line 1" > " line 2") to like > "line 1" " line 2" , change to like > "line 1 line 2"
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.
Where I came upon the pattern:
print(error_message)
sys.exit(exitcode)
, I wasn't consistent. Mostly I updated to something like:
logger.error(error_message)
sys.exit(exitcode)
but sometimes I did like:
raise Exception(error_message)
(but with a more specific error class than Exception
). I think we generally want to convert all the sys.exit
s to raise Exception
s, but this PR's already uncomfortably large without doing so. I think that can be a subsequent PR if we care to.
CPAC/isc/isfc.py
Outdated
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.
This file and CPAC/isc/isc.py
are almost identical. Not for this PR, but we might want to DRY these files up.
@@ -175,6 +178,10 @@ def gather_nifti_globs(pipeline_output_folder, resource_list, pull_func=False): | |||
# remove any extra /'s |
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.
Not for this PR, but
C-PAC/CPAC/pipeline/cpac_group_runner.py
Lines 178 to 191 in 25ea215
# remove any extra /'s | |
pipeline_output_folder = pipeline_output_folder.rstrip("/") | |
logger.info( | |
"\n\nGathering the output file paths from %s...", pipeline_output_folder | |
) | |
# this is just to keep the fsl feat config file derivative_list entries | |
# nice and lean | |
dirs_to_grab = [] | |
for derivative_name in derivative_list: | |
for resource_name in resource_list: | |
if resource_name in derivative_name: | |
dirs_to_grab.append(derivative_name) |
C-PAC/CPAC/pipeline/cpac_group_runner.py
Lines 394 to 407 in 25ea215
# remove any extra /'s | |
pipeline_output_folder = pipeline_output_folder.rstrip("/") | |
logger.info( | |
"\n\nGathering the output file paths from %s...", pipeline_output_folder | |
) | |
# this is just to keep the fsl feat config file derivatives entries | |
# nice and lean | |
search_dirs = [] | |
for derivative_name in derivatives: | |
for resource_name in resource_list: | |
if resource_name in derivative_name: | |
search_dirs.append(derivative_name) |
CPAC/utils/extract_data_multiscan.py
Outdated
@@ -276,6 +301,7 @@ def print_scan_param(index): | |||
" parameters csv file" % (subject_map.get(sub), scan[0]) | |||
) | |||
|
|||
logger.info("site for sub %s -> %s", sub, subject_map.get(sub)) |
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.
This obviously hasn't been a problem functionally since it's been this way for a long time, but only the first of these many print
statements goes to stdout
; the rest go to a file.
C-PAC/CPAC/utils/extract_data_multiscan.py
Lines 256 to 267 in dd45308
print("site for sub", sub, "->", subject_map.get(sub)) | |
print(" scan_parameters: ", file=f) | |
print(" tr:", file=f) | |
print_scan_param(4) | |
print(" acquisition:", file=f) | |
print_scan_param(0) | |
print(" reference:", file=f) | |
print_scan_param(3) | |
print(" first_tr:", file=f) | |
print_scan_param(1) | |
print(" last_tr:", file=f) | |
print_scan_param(2) |
C-PAC/CPAC/utils/extract_data_multiscan.py
Line 304 in 25ea215
logger.info("site for sub %s -> %s", sub, subject_map.get(sub)) |
@@ -183,8 +189,9 @@ def cor_graph(self, timeseries, attr=None): | |||
""" | |||
import numpy as np | |||
|
|||
timeseries[0] | |||
ts = timeseries[0] # noqa: F841 |
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.
This ts
isn't used anywhere. Do we care to assign it just to annotate, or should we drop this line?
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.
It's fine for now. Your comments with idea stubs in this PR is a pretty nice list, so we can revisit this when we revisit the other ideas as well.
e460f7d
to
26ebd1e
Compare
Oh, I forgot to mention this in the PR message, but updating the Function nodes reminded me of something I wondered ages ago, then forgot about: Why don't we default
True (or even not make it an option, and just always have Function nodes "as module"s)?
I.e., when would we want a Function node not be "as module"? |
26ebd1e
to
56930df
Compare
56930df
to
85737a1
Compare
This is ancient; I don't remember right now but again, can add to the list of things to revisit in this PR. |
It's cool; as far as I can tell, it
But I don't know how much overhead this costs or saves, or what other considerations we should have about whether / when to use it |
Fixes
Related to #2048 by @nx10
Related to #2058 by @shnizzedy
Description
― https://docs.astral.sh/ruff/rules/print/
― https://docs.astral.sh/ruff/rules/p-print/
Technical details
C-PAC/.ruff.toml
Line 11 in 71c9e6f
import nibabel as nib
in 71c9e6f (in some places it wasimport nibabel as nb
), but ruff doesn't catch the nipype-style import strings likeC-PAC/CPAC/distortion_correction/distortion_correction.py
Line 500 in 71c9e6f
C-PAC/CPAC/utils/interfaces/function/function.py
Lines 65 to 66 in e460f7d
FMLOGGER
,IFLOGGER
,UTLOGGER
, andWFLOGGER
are always available in Function nodes as the"nipype.filemanip"
,"nipype.interface"
,"nipype.utils"
, and"nipype.workflow"
loggers, respectivelyTests
C-PAC/CPAC/utils/interfaces/tests/test_function.py
Lines 23 to 50 in e460f7d
Checklist
Update index.md
).lint/pep8-boolean-comparison
branch of the repository.Developer Certificate of Origin
Developer Certificate of Origin