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 work for issue 399: add --force flag #647

Merged
merged 8 commits into from
Dec 19, 2014

Conversation

jessicalumian
Copy link

See #399.

@ged-jenkins
Copy link

Can one of the admins verify this patch?

1 similar comment
@ged-jenkins
Copy link

Can one of the admins verify this patch?

@@ -102,7 +104,8 @@ def main():
if num_samples > 1:
sys.stderr.write(
"Error: cannot specify -o with more than one sample.")
sys.exit(-1)
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep, this should be "1" not "-1"

@mr-c
Copy link
Contributor

mr-c commented Nov 4, 2014

okay to test

@ctb
Copy link
Member

ctb commented Nov 4, 2014

Note, there seem to be some spacing/indentation issues - the indentation is not always consistent with your added lines.

@jessicalumian
Copy link
Author

@ctb well aren't you fast. Fixed.

@SensibleSalmon
Copy link
Contributor

there appear to be some idle time issues with the @ctb process....

@mr-c
Copy link
Contributor

mr-c commented Nov 5, 2014

okay to test

@mr-c
Copy link
Contributor

mr-c commented Nov 5, 2014

please test this

@@ -98,6 +98,8 @@ def get_parser():
parser.add_argument('graphbase', help="base name for output files")
parser.add_argument('input_filenames', metavar='input_sequence_filename',
nargs='+', help='input FAST[AQ] sequence filenames')
parser.add_argument('-f', '-force', default=False, action='store_true',
Copy link
Member

Choose a reason for hiding this comment

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

Long form arguments should use --, ie --force.

@jessicalumian
Copy link
Author

Fixed more errors, including what @camillescott pointed out, but I want to look at it one more time to make sure everything looks good. Did I successfully push the new changes through?

@ctb
Copy link
Member

ctb commented Nov 6, 2014

On Thu, Nov 06, 2014 at 07:40:48AM -0800, jessicamizzi wrote:

Fixed more errors, including what @camillescott pointed out, but I want to look at it one more time to make sure everything looks good. Did I successfully push the new changes through?

Can you see them in the diff view?

--titus

C. Titus Brown, ctb@msu.edu

@@ -130,7 +132,8 @@ def main():
print >> sys.stderr, ("** ERROR: the k-mer counting table is too small"
" this data set. Increase tablesize/# tables.")
print >> sys.stderr, "**"
sys.exit(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

This particular use of force won't have any effect on script execution as it is at the last stage. Lines 72-75 need addressing. We probably need to add a force parameter to the check_file_status(), check_space(), and check_space_for_hashtable() functions.

@mr-c
Copy link
Contributor

mr-c commented Nov 14, 2014

Tagging the source issue: #399

@mr-c
Copy link
Contributor

mr-c commented Nov 14, 2014

Testing may be a bit tricky. To trigger code paths that a --force command line flag would enable may require slight refactoring of the scripts. Monkeypatching may be required to avoid system crashes by replacing functionality with empty functions. @ctb, @luizirber is there an easier way to Mock, or a better testing approach?

@@ -23,7 +23,7 @@ def load_pe(screed_handle):

screed_iter = iter(screed_handle)

while 1:
while True:
Copy link
Member

Choose a reason for hiding this comment

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

Why this change? 'while 1' is perfectly idiomatic in Python...?

Copy link
Contributor

Choose a reason for hiding this comment

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

This may be an 'autopep8'-ism

@ctb
Copy link
Member

ctb commented Nov 15, 2014

@mr-c what specifically are you thinking of re crashes? On a quick skim I didn't see anything that would be tough to test.

@mr-c
Copy link
Contributor

mr-c commented Nov 16, 2014

@ctb The force argument needs to be passed to check_file_status(), check_space(), and check_space_for_hashtable() (see #647 (comment))

As far as I can see these will require Mocking to test.

@ctb
Copy link
Member

ctb commented Nov 16, 2014

Ahh, OK. There are several ways to go about this --

  • we can make a special 'testing' flag that lets us test the behavior. Ugly.
  • we can test it by importing the script, monkeypatching check_file_status, setting up sys.args, etc. - eschewing the execfile approach to script testing in this case

...and I think those are the best of the options. The latter is the way to do it, I think, and it fits with our long term plans (of moving most script code out of scripts/ into an importable place).

We don't have any example code in khmer that already does this, but the basic routine is

module = __import__('script-name')
module.main()

and then place the monkeypatching in a try/finally, e.g.

 module = __import__(...)
 try:
   saved_fn = khmer.check_args.check_file_status
   khmer.check_args.check_file_status = new_fn

   # run test code
 finally:
     khmer.check_args.check_file_status = saved_fn

@mr-c
Copy link
Contributor

mr-c commented Nov 16, 2014

@jessicamizzi Once again a "simple" issue has turned out to be more complex. Sorry! I am happy to write the tests for you if you want.

@jessicalumian
Copy link
Author

@mr-c if there are any simple ones, I can do them. Otherwise, it might be best if you do them. I will make the other changes you talked about earlier on this page, but I will tomorrow.

@ctb ctb changed the title initial work for issue 399 initial work for issue 399: add --force flag Nov 22, 2014
@mr-c mr-c added this to the 1.2+ milestone Dec 1, 2014
@jessicalumian
Copy link
Author

Can two people review these changes?

  • Is it mergable
  • Did it pass the tests?
  • If it introduces new functionality in scripts/ is it tested?
    Check for code coverage.
  • Is it well formatted? Look at pep8/pylint, cppcheck, and
    make doc output. Use autopep8 and astyle -A10 --max-code-length=80
    if needed.
  • Is it documented in the Changelog?
  • Was spellcheck run on the source code and documentation after changes
    were made?


* Doxyfile.in: add links to the stdc++ docs
2014-12-05 Jessica Mizzi <mizzijes@msu.edu>
* khmer/file.py,sandbox/sweep-reads.py,scripts/{abundance-dist-single,abundance-dist,annotate-partitions,count-median,count-overlap,do-partition,extract-paired-reads,extract-partitions,filter-abund-single,filter-abund,filter-stoptags,interleave-reads,load-graph,load-into-counting,make-initial-stoptags,merge-partitions,normalize-by-median,partition-graph,sample-reads-randomly,split-paired-reads}.py,setup.cfg,tests/{test_script_arguments,test_scripts}.py: Added force option to all scripts to script IO sanity checks and updated tests to match.
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be broken up so it doesn't run over the 80 char line.

Copy link
Member

Choose a reason for hiding this comment

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

Also, don't remove @mr-c entry.

@SensibleSalmon
Copy link
Contributor

Jenkins, test this please

@SensibleSalmon
Copy link
Contributor

Jenkins is failing (unstable) but it wasn't test related. I'm guessing pep8?

@luizirber
Copy link
Member

mr-c added a commit that referenced this pull request Dec 19, 2014
initial work for issue 399: add --force flag
@mr-c mr-c merged commit ffd0691 into dib-lab:master Dec 19, 2014
@mr-c
Copy link
Contributor

mr-c commented Dec 19, 2014

@jessicamizzi, Congratulations on your first commit to the khmer project! Your name will be included in the release notes for the next version and you'll be listed amongst our other contributors in the next software release paper.

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.

7 participants