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

Show message if number of arguments mismatch between the doc string and the run method. #1533

Merged
merged 8 commits into from Jul 9, 2018

Conversation

Projects
None yet
5 participants
@parichit
Copy link
Contributor

parichit commented May 24, 2018

A simple check is implemented in the base.py script to display a message if the number of arguments in the doc string and the run method mismatches.

Parichit Sharma added some commits May 24, 2018

Parichit Sharma
Display a helpful message when,
1) There is a mismatch between the number of arguments in the doc string and
the run method.

@skoudoro skoudoro added the gsoc2018 label May 25, 2018

@parichit

This comment has been minimized.

Copy link
Contributor

parichit commented May 31, 2018

Closing this pull request due to the usage of exit() statement.
Will create a new pull request by replacing the exit with an error

@parichit parichit closed this May 31, 2018

@skoudoro

This comment has been minimized.

Copy link
Member

skoudoro commented May 31, 2018

you do not need to close this PR @parichit. You just have to commit on this branch and it will be ok

Parichit Sharma
Replaced the exit statement with the a proper error.
1) An error is raised when the number of parameters mismatch between the
doc string and the run method.
2) Tetsed the change with dipy_info and a manual workflow and the error is
raised properly.

@parichit parichit reopened this May 31, 2018

@pep8speaks

This comment has been minimized.

Copy link

pep8speaks commented May 31, 2018

Hello @parichit, Thank you for updating !

Cheers ! There are no PEP8 issues in this Pull Request. 🍻

Comment last updated on July 02, 2018 at 21:00 Hours UTC
@parichit

This comment has been minimized.

Copy link
Contributor

parichit commented May 31, 2018

@skoudoro : Thanks for the update. I have committed to the branch and re-opened the PR.

@@ -101,19 +101,33 @@ def add_workflow(self, workflow):
ref_text = [text if text else "\n" for text in npds['References']]
ref_idx = self.epilog.find('References: \n') + len('References: \n')
self.epilog = "{0}{1}\n{2}".format(self.epilog[:ref_idx],
''.join([text for text in ref_text]),
''.join([text for text in ref_text]),

This comment has been minimized.

@nilgoyette

nilgoyette Jun 5, 2018

Contributor

Can't you write ''.join(ref_text),?

This comment has been minimized.

@parichit

parichit Jun 5, 2018

Contributor

Hi,
Thanks for the update. I have updated it to ''.join(ref_text).

self.epilog[ref_idx:])

self.outputs = [param for param in npds['Parameters'] if
'out_' in param[0]]

args, defaults = get_args_default(workflow.run)

output_args = \
self.add_argument_group('output arguments(optional)')

This comment has been minimized.

@nilgoyette

nilgoyette Jun 5, 2018

Contributor

This fits on one line (col 76)

This comment has been minimized.

@parichit

parichit Jun 5, 2018

Contributor

Hey,
Thanks for the update. I updated the code to adjust in a single line.

": Number of parameters in the "
"doc string and run method does not match. "
"Please ensure that the number of parameters "
"in the run method is same as the doc string.")

This comment has been minimized.

@nilgoyette

nilgoyette Jun 5, 2018

Contributor

Comments above and this text agree, which is good, but what's the point of the comment then? We usually add comments to explain something more clearly. IMO, it's not required here.

Also, your indentation is weird here.

This comment has been minimized.

@parichit

parichit Jun 5, 2018

Contributor

Hey,

I updated the indentation.

Thanks.

Parichit Sharma added some commits Jun 5, 2018

Parichit Sharma
@codecov-io

This comment has been minimized.

Copy link

codecov-io commented Jul 2, 2018

Codecov Report

Merging #1533 into master will decrease coverage by 0.3%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1533      +/-   ##
==========================================
- Coverage   87.55%   87.25%   -0.31%     
==========================================
  Files         246      246              
  Lines       31370    31268     -102     
  Branches     3434     3223     -211     
==========================================
- Hits        27467    27283     -184     
- Misses       3085     3150      +65     
- Partials      818      835      +17
Impacted Files Coverage Δ
dipy/workflows/base.py 74.82% <33.33%> (-4.75%) ⬇️
dipy/utils/six.py 44.89% <0%> (-20.41%) ⬇️
dipy/utils/optpkg.py 64.28% <0%> (-7.15%) ⬇️
dipy/workflows/flow_runner.py 91.89% <0%> (-5.41%) ⬇️
dipy/viz/window.py 60.56% <0%> (-3.67%) ⬇️
dipy/io/dpy.py 96.42% <0%> (-3.58%) ⬇️
dipy/tests/scriptrunner.py 21.31% <0%> (-3.28%) ⬇️
dipy/data/__init__.py 89.54% <0%> (-2.62%) ⬇️
dipy/io/vtk.py 19.23% <0%> (-1.93%) ⬇️
... and 13 more

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 0bdce0d...357a792. Read the comment docs.

@skoudoro

This comment has been minimized.

Copy link
Member

skoudoro commented Jul 3, 2018

ok, LGTM, I will merge tomorrow if there is no other comment

@skoudoro skoudoro merged commit 3ef405c into nipy:master Jul 9, 2018

1 check failed

continuous-integration/travis-ci/pr The Travis CI build failed
Details

ShreyasFadnavis pushed a commit to ShreyasFadnavis/dipy that referenced this pull request Sep 20, 2018

Merge pull request nipy#1533 from parichit/docstring_param_mismatch_m…
…essage

Show message if number of arguments mismatch between the doc string and the run method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment