Skip to content

[ENH] Add ability to rename xnat sessions#263

Merged
DESm1th merged 25 commits intoTIGRLab:masterfrom
DESm1th:pha_renaming
Apr 3, 2020
Merged

[ENH] Add ability to rename xnat sessions#263
DESm1th merged 25 commits intoTIGRLab:masterfrom
DESm1th:pha_renaming

Conversation

@DESm1th
Copy link
Copy Markdown
Contributor

@DESm1th DESm1th commented Feb 20, 2020

This pull request:

  1. Adds functions to datman.xnat.xnat to allow experiments and sessions to be renamed
  2. Adds the ability to get rid of those stupid stuck AutoRun.xml pipelines
  3. Adds a bin script (dm_xnat_rename.py) to rename from the command line and in bulk if given a csv of names.
  4. Fixes a minor bug with archive_manifest.py

@auto-assign auto-assign bot requested review from gabiherman and jerdra February 20, 2020 18:34
@pep8speaks
Copy link
Copy Markdown

pep8speaks commented Feb 20, 2020

Hello @DESm1th, Thank you for updating!

Cheers! There are no style issues detected in this Pull Request. 🍻 To test for issues locally, pip install flake8 and then run flake8 datman.

Comment last updated at 2020-04-03 20:21:26 UTC

@DESm1th
Copy link
Copy Markdown
Contributor Author

DESm1th commented Feb 21, 2020

Oh no, circleci is broken :(

@jerdra
Copy link
Copy Markdown
Contributor

jerdra commented Feb 21, 2020

ahh its building off your configuration of circleci and failing, could you try pulling our circleci commits into your repo?

@DESm1th
Copy link
Copy Markdown
Contributor Author

DESm1th commented Mar 12, 2020

Don't review yet, I need to fix some function references tomorrow :)

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 25, 2020

Codecov Report

Merging #263 into master will decrease coverage by 0.46%.
The diff coverage is 3.87%.

Impacted file tree graph

@@            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     
Flag Coverage Δ
#unittests 30.68% <3.87%> (-0.47%) ⬇️
Impacted Files Coverage Δ
bin/archive_manifest.py 0.00% <0.00%> (ø)
bin/dm_xnat_rename.py 0.00% <0.00%> (ø)
datman/xnat.py 26.92% <8.95%> (-1.43%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8708908...9a50b22. Read the comment docs.

@DESm1th
Copy link
Copy Markdown
Contributor Author

DESm1th commented Mar 25, 2020

@jerdra, @gabiherman I'm done updating this one now, no rush, but it's now safe to review any time :)

Comment thread datman/xnat.py Outdated

def rename_session(self, project, old_name, new_name, rename_exp=True):
"""
Will rename an existing XNAT session (given as 'old_name') to
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops nvm!

Comment thread bin/dm_xnat_rename.py Outdated
names = read_sessions(name_path)
for entry in names:
try:
rename_xnat_session(xnat, entry[0], entry[1], project=project)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 :)

gabiherman
gabiherman previously approved these changes Mar 27, 2020
Comment thread bin/dm_xnat_rename.py Outdated
Comment on lines +169 to +170
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.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clarify this statement to indicate that experiments being renamed w/o session also being renamed doesn't happen

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ohhh, its cause i didn't submit my review until now haha, i put that up forever ago 😆

Comment thread bin/archive_manifest.py Outdated
Comment on lines +43 to +44
headers = arguments['--headers'] and arguments['--headers'].split(',') or \
default_headers[:]
Copy link
Copy Markdown
Contributor

@jerdra jerdra Apr 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

Comment thread bin/dm_xnat_rename.py Outdated
Comment on lines +95 to +101
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)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not use datman.xnat.get_connection instead?
Just curious!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread datman/xnat.py Outdated
Comment on lines +856 to +859
if not rename_exp:
return

self.rename_experiment(project, new_name, old_name, new_name)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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

@jerdra
Copy link
Copy Markdown
Contributor

jerdra commented Apr 3, 2020

looks good to me!

@DESm1th DESm1th merged commit b87170f into TIGRLab:master Apr 3, 2020
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.

4 participants