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

Prettify output #466

Open
Zethson opened this issue Mar 30, 2023 · 2 comments
Open

Prettify output #466

Zethson opened this issue Mar 30, 2023 · 2 comments
Assignees

Comments

@Zethson
Copy link
Member

Zethson commented Mar 30, 2023

lamin info

gives

Current user: zethson
- handle: zethson
- email: [email protected]
- id: I5DPZdiE
Current instance: zethson/lukas-bionty-test
- owner: zethson
- name: lukas-bionty-test
- storage root: s3://lukas-bionty-test/
- storage region: eu-central-1
- db: sqlite:////home/zeth/.cache/lamindb/lukas-bionty-test/lukas-bionty-test.lndb
- schema: {'bionty'}

without any colors. Think we can do better.

>>> import lamindb as ln
>>> ln.view()
****************
* module: core *
****************
Storage
                            root type        region          created_at updated_at
id                                                                                
Zg0KqiDx  s3://lukas-bionty-test   s3  eu-central-1 2023-03-30 14:36:29       None
User
                            email   handle  name          created_at updated_at
id                                                                             
I5DPZdiE  [email protected]  zethson  None 2023-03-30 14:36:28       None
******************
* module: bionty *
******************

isn't really pretty. We could prettify this with a Rich table

@Zethson Zethson self-assigned this Mar 30, 2023
@Zethson
Copy link
Member Author

Zethson commented Aug 13, 2023

Could be done with rich like this:

from rich.console import Console

console = Console()

user_info = {
    "Handle": "zethson",
    "Email": "[email protected]",
    "ID": "I5DPZdiE"
}

instance_info = {
    "Owner": "zethson",
    "Name": "lukas-bionty-test",
    "Storage Root": "s3://lukas-bionty-test/",
    "Storage Region": "eu-central-1",
    "Database": "sqlite:////home/zeth/.cache/lamindb/lukas-bionty-test/lukas-bionty-test.lndb",
    "Schema": "{'bionty'}"
}

console.rule("User Information", style="blue")
for key, value in user_info.items():
    console.print(f"- [cyan]{key}[/cyan]: {value}")

console.rule("Current Instance", style="blue")
for key, value in instance_info.items():
    console.print(f"- [cyan]{key}[/cyan]: {value}")

@Zethson
Copy link
Member Author

Zethson commented Aug 13, 2023

The function

from ._settings import settings


def info():
    """Log information about current instance & user."""
    # Accessing cached settings is faster than accessing the hub
    print(settings.user)
    if settings._instance_exists:
        print(settings.instance)
    else:
        print("No instance loaded: lamin load <instance>")

already returns the "current user" bla so it's annoying to format it

@Zethson Zethson transferred this issue from laminlabs/lamindb Aug 13, 2023
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

No branches or pull requests

1 participant