Skip to content

Fixed issue with automated transcript generation via "history -t" #261

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

Merged
merged 3 commits into from
Feb 1, 2018

Conversation

tleonhardt
Copy link
Member

There is now a post-processing step which escapes all "/" characters which transcript testing treats as a regex escape if there isn't a "" to escape it.

This closes #259.

There is now a post-processing step which escapes all "/" characters which transcript testing treats as a regex escape if there isn't a "\" to esape it.
@tleonhardt tleonhardt added the bug label Jan 30, 2018
@tleonhardt tleonhardt added this to the 0.8.0 milestone Jan 30, 2018
@tleonhardt tleonhardt requested a review from kotfu January 30, 2018 01:31
@tleonhardt
Copy link
Member Author

@kotfu Since you wrote or modified most of the regex processing code within the transcript testing code, you may have a better idea of how to fix this corner case. But this PR does appear to fix it in a relatively simple and straightforward manner.

@codecov
Copy link

codecov bot commented Jan 30, 2018

Codecov Report

Merging #261 into master will decrease coverage by 0.28%.
The diff coverage is 0%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #261      +/-   ##
==========================================
- Coverage   95.19%   94.91%   -0.29%     
==========================================
  Files           1        1              
  Lines        1312     1317       +5     
==========================================
+ Hits         1249     1250       +1     
- Misses         63       67       +4
Impacted Files Coverage Δ
cmd2.py 94.91% <0%> (-0.29%) ⬇️

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 ddfd3d9...beadd89. Read the comment docs.

@tleonhardt tleonhardt merged commit 160bb74 into master Feb 1, 2018
@tleonhardt tleonhardt deleted the automated_transcripts branch February 1, 2018 01:45
@kotfu
Copy link
Member

kotfu commented Feb 1, 2018

Just missed adding this note before you merged.

Looked at the post processing in the history transcript code. I'd like to pose a question for consideration: Do we think the transcript output would ever be too big for memory? Or to state it in another way, should we optimize for reduced memory usage or reduced i/o usage?

If we think the answer to that question is no (or reduced i/o usage), then we could perhaps be more efficient in the post processing if instead of opening the transcript file and setting it to self.stdout, we created a StringIO file (a file in memory) and set that to self.stdout. We then do the replacement on the contents of the StringIO file, and then write it all out to the specified transcript file. This would save us a read and a write of the entire transcript. Let's call this alternative 1.

If we think the answer to the question is yes (or reduced memory usage), then maybe we modify the post processing to open a temporary file and set it to self.stdout. We then open the temporary file for read, and the real transcript file for write, and read the lines one at a time, do the replacement, and write them to the real transcript file. Thereby never having to have the entire transcript in memory. Let's call this alternative 2.

Reality is likely that nobody would notice whether we leave it as is, or do one of these other two options. One benefit I like of the current implementation is that there is no reliance on a temporary file, which I think is a drawback of alternative 2. Alternative 1 depends on the six library for compatibility between python 2 and 3, because the StringIO library is different.

@tleonhardt
Copy link
Member Author

Personally I have never envisioned a situation where a transcript would be too big to fit in memory. But you bring up a good point. If that situation were ever possible, then we would have a problem. Can you envision a situation where you think that would be likely?

If we call the current implementation "alternative 0", then do you have any preference as to alternatives 0, 1, or 2? They all seem like viable options with their own distinct advantages and disadvantages. I would be happy with any of them.

I wouldn't be concerned about using the six library for StringIO compatibility between Python 2 and 3 since we are using it for so many other compatibility issues.

@tleonhardt
Copy link
Member Author

@kotfu Are there any outstanding issues other than the possible resolution here between alternatives 0, 1, and 2 that you would like to see addressed prior to putting out a 0.8.0 release?

I was thinking of putting out a release within the next few days since we have made a lot of significant changes recently.

@kotfu
Copy link
Member

kotfu commented Feb 1, 2018

In a time when most computers have gigabytes of memory, and our transcripts are likely plain text, I can't even think of a scenario where the transcript would be too big to fit into memory. I have no other concerns, and don't think there is any compelling reason to make a change to the current implementation of the history transcript generator feature. I say we leave it.

I agree we have made a lot of changes, and I think it's a good time to put out a 0.8.0 release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Explore issue with automated transcript generation
2 participants