[ENH] Add ability to rename xnat sessions#263
Conversation
still needs to be cleaned up and further tested for edge cases...)
|
Hello @DESm1th, Thank you for updating! Cheers! There are no style issues detected in this Pull Request. 🍻 To test for issues locally, Comment last updated at 2020-04-03 20:21:26 UTC |
|
Oh no, circleci is broken :( |
|
ahh its building off your configuration of circleci and failing, could you try pulling our circleci commits into your repo? |
|
Don't review yet, I need to fix some function references tomorrow :) |
Codecov Report
@@ Coverage Diff @@
## master #263 +/- ##
==========================================
- Coverage 31.15% 30.68% -0.47%
==========================================
Files 55 56 +1
Lines 8497 8645 +148
==========================================
+ Hits 2647 2653 +6
- Misses 5850 5992 +142
Continue to review full report at Codecov.
|
|
@jerdra, @gabiherman I'm done updating this one now, no rush, but it's now safe to review any time :) |
|
|
||
| def rename_session(self, project, old_name, new_name, rename_exp=True): | ||
| """ | ||
| Will rename an existing XNAT session (given as 'old_name') to |
There was a problem hiding this comment.
Do you think it would be excessive to give a warning that rename_exp is true by default? Might be a good idea, but I'm not 100% sure of the use case
There was a problem hiding this comment.
I think you're somehow viewing an outdated view of the PR. This is the current signature for this function (I had also changed the function name):
def rename_subject(self, project, old_name, new_name, rename_exp=False):
| names = read_sessions(name_path) | ||
| for entry in names: | ||
| try: | ||
| rename_xnat_session(xnat, entry[0], entry[1], project=project) |
There was a problem hiding this comment.
also nitpicky and probably not necessary, but would improve readability if this was a dict so you could index by entry.old_name, entry.new_name or whatever. (again please feel free to ignore)
There was a problem hiding this comment.
That's a good point! I updated the loop to just unpack the tuple properly. It is a lot more readable that way, thanks for catching that :)
| Sometimes XNAT renames only the subject or only the experiment when you | ||
| tell it to rename both. Sometimes it says it failed when it succeeded. |
There was a problem hiding this comment.
Clarify this statement to indicate that experiments being renamed w/o session also being renamed doesn't happen
There was a problem hiding this comment.
I think you got bit by the same outdated copy of dm_xnat_rename that gabi did. This function is completely gone in the most up to date copy
There was a problem hiding this comment.
ohhh, its cause i didn't submit my review until now haha, i put that up forever ago 😆
| headers = arguments['--headers'] and arguments['--headers'].split(',') or \ | ||
| default_headers[:] |
There was a problem hiding this comment.
| headers = arguments['--headers'] and arguments['--headers'].split(',') or \ | |
| default_headers[:] | |
| headers = (arguments['--headers'] and arguments['--headers'].split(',')) or \ | |
| default_headers[:] |
Is this the intended evaluation? Might be clearer with parentheses
| def get_xnat(server, user, password): | ||
| if not server: | ||
| config = datman.config.config() | ||
| server = datman.xnat.get_server(config) | ||
| if not user or not password: | ||
| user, password = datman.xnat.get_auth() | ||
| return datman.xnat.xnat(server, user, password) |
There was a problem hiding this comment.
why not use datman.xnat.get_connection instead?
Just curious!
There was a problem hiding this comment.
I added this before I updated datman.xnat to have get_connection and the copy of datman.xnat on this branch is out of date, ha.
| if not rename_exp: | ||
| return | ||
|
|
||
| self.rename_experiment(project, new_name, old_name, new_name) |
There was a problem hiding this comment.
| if not rename_exp: | |
| return | |
| self.rename_experiment(project, new_name, old_name, new_name) | |
| if rename_exp: | |
| self.rename_experiment(project, new_name, old_name, new_name) | |
| return |
|
looks good to me! |
This pull request: