-
Notifications
You must be signed in to change notification settings - Fork 5
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
CLI improvements #32
CLI improvements #32
Changes from 4 commits
d831215
c5afb3e
f174dec
4c9a315
9cf1b75
30c33fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,4 @@ mkdocs-material-extensions==1.0 | |
Pygments==2.6.1 | ||
pymdown-extensions==7.1 | ||
mkdocs-click | ||
rich |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,39 @@ | |
import types | ||
from pathlib import Path | ||
|
||
from rich import box | ||
from rich.console import Console | ||
from rich.table import Table | ||
|
||
# init console object to be used throught. | ||
console = Console() | ||
hhsecond marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
|
||
def new_columns_table(splits_added: dict) -> Table: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a better (distinguishable) name so that readers won't get confused this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wait what I meant is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Aah!! I was confused with |
||
""" | ||
Builds a Rich Table with the infor about the new columns created. | ||
|
||
Parameters | ||
---------- | ||
splits_added : dict containing the column_names and length of each split | ||
|
||
Returns | ||
------- | ||
Table | ||
The final generated table ready to be displayed | ||
|
||
""" | ||
table = Table(box=box.MINIMAL) | ||
|
||
table.add_column("Split [len]", no_wrap=True, justify="right", style="bold green") | ||
table.add_column("Column Names") | ||
|
||
for split in splits_added: | ||
column_names, num_samples = splits_added[split] | ||
table.add_row(split + f" [{num_samples}]", ", ".join(column_names)) | ||
|
||
return table | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Continuing the conversation from here, maybe we shouldn't return from here at all. Just print it (of course, rename the function so that it is understood). What do you think? Because I don't see any reason why the object return from this function is useful anywhere else apart from just printing it to the output There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes that a good point! |
||
|
||
|
||
def get_stock_root(path: Path) -> Path: | ||
""" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we do
instead of using console from
utils.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://rich.readthedocs.io/en/latest/console.html#console-api
Here its mentioned that we should put this in a console.py file but I thought utils was better. If we want we can put all of the rich functionalities in this file or use initiate console every time. which would be nice?