-
Notifications
You must be signed in to change notification settings - Fork 535
AddCSVRow interface #829
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
AddCSVRow interface #829
Conversation
please do a |
Very much improved version using pandas. Now the fields are not checked manually (pandas DataFrames are created for this). Additionally, now the columns can be named in a DataSink style: using custom input traits, the values are directly associated to the header. Finally, it allows for saving lists, expanding the header to the number of elements in the list. |
|
||
class AddCSVRow(BaseInterface): | ||
""" | ||
Short interface to add an extra row to a text file |
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.
could you please add here that pandas is required for this interface?
Dear @satra, I based my code on the DataSink interface to get auto-generated names for columns. The interface seems to work fine isolated, but when I insert it into a workflow, I get errors like What else should I write to get the interface working with workflows? Thanks! |
Ok, I see that for DataSink and DataGrabber the check is skipped: nipype/nipype/pipeline/engine.py Line 352 in d5aeeaa
and so it should be for the new approach to AddCSVRow. Should this interface be under io? Or we could add some indicator to allow dynamic traits? |
I'm playing around this dynamically traited version of AddCSVRow, and it seems to me that this interface should be considered to be under IO:
and:
|
Methods _outputs and _add_output_traits were missing to provide a fully IOBase-like interface.
I've found that the source of the problem was not the interface, but the inputs I was supplying (numpy masked arrays). Remaining decisions:
|
@satra, @chrisfilo what do you think about my last suggestions? Other than that, I'm currently using the new interface without any problems |
Sorry for the delay I'm happy to merge it as long as we give a warning that it is not thread safe (and and it into description). |
one quick semantic note: should we call it |
@satra Well GetCSVRow is more like reading a row, right?. This is the counterpart to the existing AddCSVColumn. With some improvements as using pandas is a great advantage to code features safely (managing columns, missing values, etc). In any case, I will write the name you prefer because I have no concerns about that. @chrisfilo Regarding the file-lock, I'll add the warning and a note in the description. Regarding the dynamic-traited interfaces I think that the piece of code I suggested is necessary for this interface to work. Alternatively, we can include AddCSVRow as a DataSink that already accept dynamic traits. |
@oesteban - my bad - this is actually adding a row - no need to change names. |
Travis is reporting a failure for python 2.6 but it was successful for 2.7. I guess it's a problem on the configuration of tests for 2.6. |
Now, the interface is thread-safe using lockfile. It is included in documentation, and also a warning is issued when the module is not available or could not be imported.
@satra, @chrisfilo: I think this interface is in a pretty mature status. But there's still something to get decided: how to allow dynamic-traited inputs in a I proposed modifying these lines as follows:
This is the most simplistic way to get it, but we could also add one more meta info to the traits indicating if it is dynamic (instead of checking for a special name). |
Why not:
instead? |
You're right, much more elegant 👍 |
... dynamic input traits
Could you test if it works and add it to this PR? On Thu, Jul 24, 2014 at 12:30 PM, Oscar Esteban notifications@github.com
|
As soon as I test it I let you know :) |
Conflicts: CHANGES nipype/algorithms/misc.py Merge after updating master to upstream
Conflicts: CHANGES
This is working OK for me 👍 |
A complementary interface to AddCSVColumn