You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I used the GitHub search to find a similar issue and didn't find it.
I searched the Typer documentation, with the integrated search.
I already searched in Google "How to X in Typer" and didn't find any information.
I already read and followed all the tutorial in the docs and didn't find an answer.
I already checked if it is not related to Typer but to Click.
Commit to Help
I commit to help with one of those options 👆
Example Code
defserialize_dfs(func):
"""Decorator function to automatically (de)-serialize input and output dataframes for the function. It leverages the `df_path` and `df_output_path` kwargs to serialize input and output dataframes respectively. Args: func: function to decorate Returns: List of deduplicated column names """defwrapper(
*args,
dataframe: Optional[pd.DataFrame] =None,
df_path: Optional[str] =None,
df_output_path: Optional[str] =None,
**kwargs
):
# When df path specified, load it and pass it into the functionifdf_path:
dataframe=pd.read_csv(df_path)
# Invoke original functionresult: pd.DataFrame=func(*args, dataframe=dataframe, **kwargs)
# When output path specified, serialize it into outputifdf_output_path:
result.to_csv(df_output_path, index=False)
returnresultreturnwrapper@app.command()@serialize_dfsdefexpand_columns(
dataframe: pd.DataFrame=typer.Argument(lazy=True, default=None, formats=[""], hidden=True, expose_value=False),
keys_col: str="metadata_name",
values_col: str="metadata_value",
col_format: str="{column_name}{num}",
) ->pd.DataFrame:
# ... logic here
Description
I have a few functions that I want to type that handle dataframes (both as input and output). I do have a decorator that allows for specifying the dataframes as paths (as opposed to the objects).
Out of this decorator, I now wish to construct a Typer command. Though I keep getting the following error:
RuntimeError: Type not yet supported.
Is there an option to completely ignore an argument to the Typer CLI? I tried:
Hidden=True
Default=None
Expose_value=False
Lazy=True
Operating System
macOS
Operating System Details
No response
Typer Version
typer==0.6.1
Python Version
3.9
Additional Context
No response
The text was updated successfully, but these errors were encountered:
Have a look at my little package sitk-cli . I do something very similar, just for images. The function make_cli replaces arguments of type image with pathlib.Path and does loading/saving.
I use this concept with typer to create command lines from library code.
First Check
Commit to Help
Example Code
Description
I have a few functions that I want to type that handle dataframes (both as input and output). I do have a decorator that allows for specifying the dataframes as paths (as opposed to the objects).
Out of this decorator, I now wish to construct a Typer command. Though I keep getting the following error:
Is there an option to completely ignore an argument to the Typer CLI? I tried:
Operating System
macOS
Operating System Details
No response
Typer Version
typer==0.6.1
Python Version
3.9
Additional Context
No response
The text was updated successfully, but these errors were encountered: