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

issue #113, create markdown with jinja template in status view #163

Merged
merged 58 commits into from Feb 20, 2020

Conversation

zhou-pj
Copy link
Contributor

@zhou-pj zhou-pj commented Sep 14, 2019

Description

Motivation and Context

see issue #113

Types of Changes

  • Documentation update
  • Bug fix
  • New feature
  • Breaking change1

1The change breaks (or has the potential to break) existing functionality.

Checklist:

If necessary:

  • I have updated the API documentation as part of the package doc-strings.
  • I have created a separate pull request to update the framework documentation on signac-docs and linked it here.
  • I have updated the changelog.

@zhou-pj zhou-pj requested a review from a team September 14, 2019 19:55
@ghost ghost requested review from b-butler and removed request for a team September 14, 2019 19:55
@zhou-pj zhou-pj requested a review from vyasr September 14, 2019 19:56
@zhou-pj zhou-pj self-assigned this Sep 14, 2019
@zhou-pj
Copy link
Contributor Author

zhou-pj commented Sep 14, 2019

NOT ready for review yet, but would like to discuss the proper markdown rendering package and how to proceed at some point. I have modified all the template to create roughly the needed markdown syntax, will need further improvements upon figuring out the rendering method.

@vyasr
Copy link
Contributor

vyasr commented Sep 16, 2019

@zhou-pj just for future reference, Github supports Draft PRs that allow you to make a pull request and ask for feedback while indicating that it's not yet ready for a thorough review and merge. Next time when you open a PR, click the arrow next to the green button for creating the PR and you'll see that one of the options is creating a draft PR.

Copy link
Member

@b-butler b-butler left a comment

Choose a reason for hiding this comment

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

I really like the new terminal markdown render's view. I also think the raw view is now sufficient ugly that we should require mdv by default. However, the html output could be better. Having the detailed status have the fields more separated, would be easier to parse. In addition, using markdown headers for detailed and overview and things like that would help guide the eye more. One more thing job operation submission status is aligned in the terminal but not the html. I think them both being aligned would be best.

flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
@vyasr
Copy link
Contributor

vyasr commented Sep 25, 2019

@zhou-pj what was the final result of the various renderers we discussed? Were you able to get HTML to render in the terminal, or was the markdown viewer package the best option? I agree with @b-butler that we definitely need something to prettify the default markdown output for the terminal. Can you summarize the conclusions you/we came to on the various package options for this rendering (mistune, misteletoe, mdv, markdown, html2text, etc)?

@zhou-pj
Copy link
Contributor Author

zhou-pj commented Sep 27, 2019

Sorry for the delay... @vyasr @b-butler To summarize, I think the first step: using jinjia template to generate markdown status output looks pretty good to me now. For second step rendering on terminal, I get terminal_markdown_viewer to work if we generate terminal view directly from markdown (but I need to avoid using any '|' in output as this is used for markdown table formatting). I tried the html2text to see if html to terminal works but it looks like this package basically convert html back to markdown, not for terminal rendering. And as for providing html version for user, I think mistune works well to create html. I'll push a cleaned commit later today using mistune and terminal_markdown_viewer.

@zhou-pj zhou-pj requested review from csadorf and a team as code owners September 27, 2019 14:54
@ghost ghost removed their request for review September 27, 2019 14:54
@csadorf csadorf removed their request for review September 27, 2019 14:55
@vyasr
Copy link
Contributor

vyasr commented Oct 1, 2019

I'm currently a bit swamped trying to finalize the 2.0 release of freud as well as get some data collection done for a project. I'll look back into this as soon as possible, but it'll probably be another week or so. Sorry for the delay @zhou-pj, I'll get to this as soon as possible.

@bdice
Copy link
Member

bdice commented Feb 14, 2020

@zhou-pj Here's a potentially helpful method for removing the ANSI escape sequences use re.sub. The regex is taken from: https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python

>>> ansi_string = '\033[1mbold\033[0m text'
>>> print(len(ansi_string))
17
>>> ansi_escape = r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])'
>>> plain_string = re.sub(ansi_escape, '', ansi_string)
>>> print(len(plain_string))
9

Copy link
Member

@bdice bdice left a comment

Choose a reason for hiding this comment

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

I left some comments. I haven't closed followed this PR yet so I wanted to familiarize myself with it. It looks good overall! Thanks @zhou-pj for the good work.

flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/render_status.py Outdated Show resolved Hide resolved
flow/render_status.py Outdated Show resolved Hide resolved
flow/render_status.py Outdated Show resolved Hide resolved
flow/render_status.py Outdated Show resolved Hide resolved
flow/render_status.py Outdated Show resolved Hide resolved
@csadorf
Copy link
Contributor

csadorf commented Feb 14, 2020

There are currently 4 reviewers on this PR, that seems a bit overkill. I'm happy to look at this, but maybe we can reduce that a bit?

@bdice
Copy link
Member

bdice commented Feb 14, 2020

There are currently 4 reviewers on this PR, that seems a bit overkill. I'm happy to look at this, but maybe we can reduce that a bit?

I only read over this PR because I wanted to know how the new system worked. I am going to step back and let other reviewers help finalize this PR, I just wanted a bit of familiarity with what's being done and suggested changes while I was reading through it.

@csadorf
Copy link
Contributor

csadorf commented Feb 15, 2020

There are currently 4 reviewers on this PR, that seems a bit overkill. I'm happy to look at this, but maybe we can reduce that a bit?

I only read over this PR because I wanted to know how the new system worked. I am going to step back and let other reviewers help finalize this PR, I just wanted a bit of familiarity with what's being done and suggested changes while I was reading through it.

That's totally fine and makes a lot of sense. I just wanted to make sure that we don't "burden" too many folks with the review requests.

@b-butler I'll remove the request for you for now, but please feel free to review this PR if you feel so inclined.

@csadorf csadorf requested review from bdice and removed request for b-butler and bdice February 15, 2020 10:22
zhou-pj and others added 2 commits February 15, 2020 12:24
Co-Authored-By: Bradley Dice <bdice@bradleydice.com>
@zhou-pj
Copy link
Contributor Author

zhou-pj commented Feb 15, 2020

@zhou-pj Here's a potentially helpful method for removing the ANSI escape sequences use re.sub. The regex is taken from: https://stackoverflow.com/questions/14693701/how-can-i-remove-the-ansi-escape-sequences-from-a-string-in-python

>>> ansi_string = '\033[1mbold\033[0m text'
>>> print(len(ansi_string))
17
>>> ansi_escape = r'\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])'
>>> plain_string = re.sub(ansi_escape, '', ansi_string)
>>> print(len(plain_string))
9

Thanks for the suggestions! It turn out the tabulate.py has this implemented and the real issue was the way I add terminal support to mistune make used tabulate.py before the bold markup(\033[1m) is applied, so it cased that problem. I modified in mistune to fix it.

Copy link
Contributor

@csadorf csadorf left a comment

Choose a reason for hiding this comment

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

This is fantastic! I only have a comments and questions.

flow/render_status.py Show resolved Hide resolved
flow/util/mistune/plugins/tabulate.py Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
flow/project.py Outdated Show resolved Hide resolved
@csadorf
Copy link
Contributor

csadorf commented Feb 18, 2020

@vyasr LGTM, please merge at your discretion.

@zhou-pj Great work!!

Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

I have a few small inline comments. In addition, please update the API documentation to include the new Renderer class, and the return type of print_status. You'll also need to update the Changelog. Also, we'll probably want to include a small update to signac-docs about the existence of the Renderer in the Topic Guides section on status printing. We can merge this PR without that one being created, but it would be good to have on your radar (maybe make an issue if you don't have time to start on that immediately so that it's at least recorded that we want to add the documentation).

flow/render_status.py Outdated Show resolved Hide resolved
flow/project.py Show resolved Hide resolved
flow/render_status.py Show resolved Hide resolved
flow/render_status.py Outdated Show resolved Hide resolved
setup.py Show resolved Hide resolved
@vyasr vyasr self-requested a review February 20, 2020 20:14
Copy link
Contributor

@vyasr vyasr left a comment

Choose a reason for hiding this comment

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

Thanks for pushing this through! Sorry it took so long.

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

Successfully merging this pull request may close these issues.

None yet

5 participants