Skip to content
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

initial stab at exception handling around file operations #333

Merged
merged 56 commits into from
May 30, 2014

Conversation

ctb
Copy link
Member

@ctb ctb commented Mar 19, 2014

No description provided.

@ged-jenkins
Copy link

Test PASSed.
Refer to this link for build results: http://ci.ged.msu.edu/job/khmer-multi-pullrequest/295/

@RamRS
Copy link
Contributor

RamRS commented Mar 19, 2014

Are there other file IO operations in the C++ code that need wrapping?

@ctb
Copy link
Member Author

ctb commented Mar 19, 2014

On Wed, Mar 19, 2014 at 06:23:44AM -0700, Ram RS wrote:

Are there other file IO operations that need wrapping?

Yes, of course, but I want to get the approach worked out first.

@RamRS
Copy link
Contributor

RamRS commented Mar 19, 2014

Hmmm, so you have given a demo on how to handle file input on wholesale
consumption as well as streaming input. I'll take a look and see if I can
find spots that we can apply these constructs to.

Would you be willing to go over a list I prepare of candidate spots? I'd
rather not mess up the C++ code without adult supervision.

Ram

On Wed, Mar 19, 2014 at 9:25 AM, C. Titus Brown notifications@github.comwrote:

On Wed, Mar 19, 2014 at 06:23:44AM -0700, Ram RS wrote:

Are there other file IO operations that need wrapping?

Yes, of course, but I want to get the approach worked out first.

Reply to this email directly or view it on GitHubhttps://github.com//pull/333#issuecomment-38049681
.

@ctb
Copy link
Member Author

ctb commented Mar 19, 2014

On Wed, Mar 19, 2014 at 07:01:32AM -0700, Ram RS wrote:

Hmmm, so you have given a demo on how to handle file input on wholesale
consumption as well as streaming input. I'll take a look and see if I can
find spots that we can apply these constructs to.

Would you be willing to go over a list I prepare of candidate spots? I'd
rather not mess up the C++ code without adult supervision.

Please feel free to prepare such a list, but I might ignore it :)

@mr-c mr-c added this to the 1.0 release milestone Mar 19, 2014
@RamRS
Copy link
Contributor

RamRS commented Mar 19, 2014

I'm gonna go out on a limb and wrap most (if not all) c_str(file,ios::X) operations.

Quick question: would it not be easier to wrap the open() lines in the underlying read_parsers.cc and other source files?

@ctb
Copy link
Member Author

ctb commented Mar 19, 2014

On Wed, Mar 19, 2014 at 11:12:28AM -0700, Ram RS wrote:

I'm gonna go out on a limb and wrap most (if not all) c_str(file,ios::X) operations.

Quick question: would it not be easier to wrap the open() lines in the underlying read_parsers.cc and other source files?

Ram, please don't step on my work; it's preliminary. Thanks.

@RamRS
Copy link
Contributor

RamRS commented Mar 19, 2014

I wasn't planning to actually start working on this, just figured we could discuss. I apologize.

I think if we could assign issues (at least those opened by repo collaborators for themselves), that would avoid this confusion.

@mr-c
Copy link
Contributor

mr-c commented Mar 19, 2014

@RamRS We use pull requests as a way of sharing on-going development, mostly between @ctb and those people he supervises.

I change the assignment of an issue when someone has claimed it. One could even use the Assignee field of a pull request to signal their readiness for code review.

@RamRS
Copy link
Contributor

RamRS commented Mar 19, 2014

Ah, I understand now. I apologize for this oversight. It was foolish of me to assume that this PR was a pilot/demo to a branch of work and not an ongoing piece in and of itself.

@ged-jenkins
Copy link

Test FAILed.
Refer to this link for build results: http://ci.ged.msu.edu/job/khmer-multi-pullrequest/442/

@mr-c mr-c modified the milestones: 1.1+ Release, 1.0 release Apr 2, 2014
@ged-jenkins
Copy link

Test FAILed.
Refer to this link for build results: http://ci.ged.msu.edu/job/khmer-multi-pullrequest/458/

@ctb
Copy link
Member Author

ctb commented May 18, 2014

Also see #411.

@ctb
Copy link
Member Author

ctb commented May 18, 2014

Here is a brief description of the strategy, implemented (for now) in counting.cc, CountingHashFileReader constructor:

  1. use ifstream::exceptions() to configure ifstream to throw an exception for eof or failure;
  2. catch the resulting exception in C++ code and raise a custom C++ exception with our own message;
  3. catch this custom exception in _khmermodule and pass it along to Python as an IOError with the appropriate message;
  4. write tests that involve reading in truncated hashtables;

@mr-c and I talked about why we shouldn't just catch the ifstream exceptions in _khmermodule. The reason I did it this way is so that we can add in more specific error messages in the function that is actually doing the loading: _khmermodule will have no real context for why an exception is being thrown, while the code in counting.cc may be able to figure it out and provide a more useful error message to the Python level. (See last link in extra reading -- there are no special format conventions for figuring out what an exception means here.)

Extra reading:

@mr-c, @camillescott, @luizirber - any comments on this strategy? I can apply it to all input streams easily enough.

@ctb
Copy link
Member Author

ctb commented May 18, 2014

Probably addresses #178, #247 and #95. Also see #246 and #411.

@mr-c
Copy link
Contributor

mr-c commented May 20, 2014

The approach and the code looks good to me.

@mr-c
Copy link
Contributor

mr-c commented May 30, 2014

On Thu, May 29, 2014 at 7:39 PM, C. Titus Brown notifications@github.com
wrote:

I am still confused about the coverage report.

The cobertura report doesn't show me individual lines that are or aren't
covered. How can I generate that? Is there a good reason not to generate
that for each commit?

If you log in to Jenkins the cobertura report will show the source for the
most recent build**.

** Yes, this causes problems when multiple pull requests are being updated
in a short time

Am I supposed to run the 'make' commands, above, locally on my laptop, as
#251 #251 implies?

Developers can also use git-coverage or diff-cover to show the same
information.

I've added a Makefile target in this branch that automates the diff-cover
approach; use either diff-cover or diff-cover.html

@mr-c
Copy link
Contributor

mr-c commented May 30, 2014

The HTML diff-cover report is available at http://athyra.ged.msu.edu/~mcrusoe/diff-cover.html if you have problems running it locally.

@ctb
Copy link
Member Author

ctb commented May 30, 2014

OK, I see, so yes, I need run the coverage on my own. We'll have to document all of this for the hackathon, I think.

@ctb
Copy link
Member Author

ctb commented May 30, 2014

(I've forgotten how to log into Jenkins, if I ever knew; but it seems like the coverage report should be publicly available, no?)

@ctb
Copy link
Member Author

ctb commented May 30, 2014

Hallelujah!! Quick, @mr-c, merge it before it breaks again :)

except IOError, e:
print str(e)

def test_hashbits_file_type_check():
Copy link
Contributor

Choose a reason for hiding this comment

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

tests/test_hashbits.py:682:1: E302 expected 2 blank lines, found 1

@mr-c
Copy link
Contributor

mr-c commented May 30, 2014

On Fri, May 30, 2014 at 3:32 AM, C. Titus Brown notifications@github.com
wrote:

OK, I see, so yes, I need run the coverage on my own. We'll have to
document all of this for the hackathon, I think.

Yep! I've make a checklist of issues to target for a mid-July release:
#440


Reply to this email directly or view it on GitHub
#333 (comment).

@mr-c
Copy link
Contributor

mr-c commented May 30, 2014

On Fri, May 30, 2014 at 3:34 AM, C. Titus Brown notifications@github.com
wrote:

(I've forgotten how to log into Jenkins, if I ever knew; but it seems like
the coverage report should be publicly available, no?)

There's a link in the upper right corner that uses your GitHub credentials.
I agree it should be publicly available. I'll file a ticket.


Reply to this email directly or view it on GitHub
#333 (comment).

@mr-c
Copy link
Contributor

mr-c commented May 30, 2014

I'm going to fix the spacing error & squash this down to a handful of commits instead of 55

@mr-c
Copy link
Contributor

mr-c commented May 30, 2014

I switched to a matrix-based authorization scheme and now non-logged-in
users can see the coverage reports with code highlighting. Tested by
loading
http://ci.ged.msu.edu/job/khmer-pullrequest/107/label=linux/cobertura/khmer/_khmermodule_cc/
into a incognito browser window.

Jenkins issue is at https://issues.jenkins-ci.org/browse/JENKINS-23254

On Fri, May 30, 2014 at 11:34 AM, Michael Crusoe michael.crusoe@gmail.com
wrote:

On Fri, May 30, 2014 at 3:34 AM, C. Titus Brown notifications@github.com
wrote:

(I've forgotten how to log into Jenkins, if I ever knew; but it seems
like the coverage report should be publicly available, no?)

There's a link in the upper right corner that uses your GitHub credentials.
I agree it should be publicly available. I'll file a ticket.


Reply to this email directly or view it on GitHub
#333 (comment).

@mr-c mr-c deleted the feature/missing_file_exceptions branch May 30, 2014 17:03
@ctb
Copy link
Member Author

ctb commented May 31, 2014

Thanks, @mr-c, for all your work on this! Question -- should the squashing be part of our standard dev workflow? I'm -0 on it as a general thing (because I'm scared of git rebase) but +0 on it being your call. Either way it should be mentioned as an option in our dev docs (perhaps added as part of #440).

@mr-c
Copy link
Contributor

mr-c commented May 31, 2014

Personally I git fetch && git rebase origin/master instead of git merging. That makes a later commit squash via git rebase -i origin/master easy.

For this PR it was too messy for me to clean up. shrug It is a strong preference but I haven't come up with a sure-fire way to use it. I'm going to punt on this for now.

ht.add_tag('A' * 32)
ht.add_tag('G' * 32)
ht.save_tagset(outfile)
ht.save_tagset('/tmp/goodversion-k32.tagset')
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm.. I don't think this line should be in the test.

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.

None yet

4 participants