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

Allow to supress output. #532

Open
sklimasz opened this issue Aug 9, 2024 · 1 comment
Open

Allow to supress output. #532

sklimasz opened this issue Aug 9, 2024 · 1 comment

Comments

@sklimasz
Copy link

sklimasz commented Aug 9, 2024

I propose we allow to supress output.

def Fire(component=None, command=None, name=None, serialize=None, supress_output=False):
...
  if not supress_output:
    _PrintResult(
        component_trace, verbose=component_trace.verbose, serialize=serialize)

Why?

Let's try to wrap a function that returns a pd.DataFrame with Fire:

import pandas as pd
from os import PathLike
from fire import Fire
from functools import wraps

def do_stuff_with_df(path: PathLike) -> pd.DataFrame:
    df = pd.read_csv(path)
    print("***Print inside func***")
    # Do stuff here, save .csv and such.
    ...
    # return for usage in other funcs
    return df

if __name__ == "__main__":
    Fire(do_stuff_with_df)

And this is the output.

python .\test.py --path dummy.csv
***Print inside func***
NAME
    test.py --path dummy.csv - Two-dimensional, size-mutable, potentially heterogeneous tabular data.

SYNOPSIS
    test.py --path dummy.csv GROUP | COMMAND | VALUE

DESCRIPTION
    Data structure also contains labeled axes (rows and columns).
    Arithmetic operations align on both row and column labels. Can be
    thought of as a dict-like container for Series objects. The primary
    pandas data structure.
(We can scroll down for more!)
...

We get a description of pd.DataFrame. And we have to press Q enter normal terminal again.
That's quite inconvenient. A user would have to create and apply wrapper to not get this description.

@xmdf
Copy link

xmdf commented Oct 24, 2024

I second this. It is very annoying when trying to return objects from a function called by Fire() and is an easy fix that does not change the default behavior at all.

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

2 participants