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

CLI improvements #32

Merged
merged 6 commits into from
Aug 21, 2020
Merged

CLI improvements #32

merged 6 commits into from
Aug 21, 2020

Conversation

jjmachan
Copy link
Contributor

Description

Why is this change required? What problem does it solve? Describe your changes in detail:

This incorporates the Rich library for better CLI UI
sample2

Rich will now be used through the CLI to create a more consistent theme.

If it fixes an open issue, please link to the issue here:

Screenshots (if appropriate):

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Documentation update
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2020

Codecov Report

Merging #32 into master will decrease coverage by 0.37%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #32      +/-   ##
==========================================
- Coverage   40.80%   40.42%   -0.38%     
==========================================
  Files          21       21              
  Lines         647      653       +6     
  Branches       48       48              
==========================================
  Hits          264      264              
- Misses        383      389       +6     
Impacted Files Coverage Δ
stockroom/cli.py 0.00% <0.00%> (ø)
...ockroom/external/importer/torchvision_importers.py 0.00% <0.00%> (ø)

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 2189342...30c33fd. Read the comment docs.

@jjmachan
Copy link
Contributor Author

there is an issue apparently with isort <5.1.4 and setuptools v=49.2 more here
so I specified a version of isort.

@jjmachan
Copy link
Contributor Author

it seems to be due to the fact that pylint doesn't support isort>5

Collecting isort>=5.1.4
  Downloading isort-5.4.2-py3-none-any.whl (94 kB)
     |████████████████████████████████| 94 kB 2.8 MB/s
ERROR: pylint 2.5.3 has requirement isort<5,>=4.2.5, but you'll have isort 5.4.2 which is incompatible.
Installing collected packages: isort
Successfully installed isort-5.4.2

Copy link
Member

@hhsecond hhsecond left a comment

Choose a reason for hiding this comment

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

This looks good apart from some minor changes

console = Console()


def new_columns_table(splits_added: dict) -> Table:
Copy link
Member

Choose a reason for hiding this comment

The 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 column with hangar column

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wait what I meant is new_hangar_column_table. so column is hangar column is that how its suppose to be should I change it?

Copy link
Member

Choose a reason for hiding this comment

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

Aah!! I was confused with table.add_column method. Maybe we could rename it as make_console_table or build_rich_table or tabularize_column_info or something similar?

stockroom/cli.py Outdated
stock_obj.commit(f"Data from {dataset_name} added through stock import")
stock_obj.close()
click.echo(f"The {dataset_name} dataset has been added to StockRoom")
click.echo(f"The {dataset_name} dataset has been added to StockRoom.")
console.print(new_columns_table(splits_added))
Copy link
Member

Choose a reason for hiding this comment

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

can't we do

console = Console()
console.print(new_columns_table(splits_added))

instead of using console from utils.py

Copy link
Contributor Author

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?

@hhsecond
Copy link
Member

Also, make sure your branch is rebased with the latest master

column_names, num_samples = splits_added[split]
table.add_row(split + f" [{num_samples}]", ", ".join(column_names))

return table
Copy link
Member

Choose a reason for hiding this comment

The 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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes that a good point!
I'll change it to that 👍

@jjmachan
Copy link
Contributor Author

extra_texts

one more thing
as you see the current UI is cluttered due to the prints from the torchdatasets downloading the file . should I suppress it to clean up the UI?
It does make it seamless but will error handling become harder?

@hhsecond hhsecond merged commit f643d83 into tensorwerk:master Aug 21, 2020
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

3 participants