Output Elements¶
Available output elements for OneCode projects:
csv_output¶
def csv_output(
key: str,
value: str,
label: Optional[str] = None,
tags: Optional[List[str]] = None
)
A CSV table with a label on top.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
ID of the element. It must be unique as it is the key used to story data in
Project(), otherwise it will lead to conflicts at runtime in both execution and
Streamlit modes. The key will be transformed into snake case and slugified to avoid
any special character or whitespace. Note that an ID cannot start with |
required |
value |
str
|
Path to the output CSV file which must have a |
required |
label |
Optional[str]
|
Typically to be used by Streamlit for display purpose only. If not defined, it
will default to the |
None
|
tags |
Optional[List[str]]
|
Optional meta-data information about the expected file. This information is only used when the JSON output attributes are written to the output manifest. |
None
|
**kwargs |
Any
|
Extra user meta-data to attach to the element. Argument names cannot overwrite
existing attributes or methods name such as |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
if the |
AttributeError
|
if one the |
Example
from onecode import csv_output, Mode, Project
Project().mode = Mode.CONSOLE
widget = csv_output(
key="CsvOutput",
value="/path/to/file.csv",
label="My CsvOutput",
tags=['CSV']
)
print(widget)
"/path/to/file.csv"
file_output¶
def file_output(
key: str,
value: str,
label: Optional[str] = None,
tags: Optional[List[str]] = None
)
Basic information about the file, such as size and file path.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
ID of the element. It must be unique as it is the key used to story data in
Project(), otherwise it will lead to conflicts at runtime in both execution and
Streamlit modes. The key will be transformed into snake case and slugified to avoid
any special character or whitespace. Note that an ID cannot start with |
required |
value |
str
|
Path to the output file. Unless absolute, a path is relative to the |
required |
label |
Optional[str]
|
Typically to be used by Streamlit for display purpose only. If not defined, it
will default to the |
None
|
tags |
Optional[List[str]]
|
Optional meta-data information about the expected file. This information is only used when the JSON output attributes are written to the output manifest. |
None
|
**kwargs |
Any
|
Extra user meta-data to attach to the element. Argument names cannot overwrite
existing attributes or methods name such as |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
if the |
AttributeError
|
if one the |
Example
from onecode import file_output, Mode, Project
Project().mode = Mode.CONSOLE
widget = file_output(
key="FileOutput",
value="/path/to/file.txt",
label="My FileOutput",
tags=['TXT']
)
print(widget)
"/path/to/file.txt"
image_output¶
def image_output(
key: str,
value: str,
label: Optional[str] = None,
tags: Optional[List[str]] = None
)
An image as part of the image carousel.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
ID of the element. It must be unique as it is the key used to story data in
Project(), otherwise it will lead to conflicts at runtime in both execution and
Streamlit modes. The key will be transformed into snake case and slugified to avoid
any special character or whitespace. Note that an ID cannot start with |
required |
value |
str
|
Path to the output image file which must have a |
required |
label |
Optional[str]
|
Typically to be used by Streamlit for display purpose only. If not defined, it
will default to the |
None
|
tags |
Optional[List[str]]
|
Optional meta-data information about the expected file. This information is only used when the JSON output attributes are written to the output manifest. |
None
|
**kwargs |
Any
|
Extra user meta-data to attach to the element. Argument names cannot overwrite
existing attributes or methods name such as |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
if the |
AttributeError
|
if one the |
Example
from onecode import image_output, Mode, Project
Project().mode = Mode.CONSOLE
widget = image_output(
key="ImageOutput",
value="/path/to/file.jpg",
label="My ImageOutput",
tags=['Image']
)
print(widget)
"/path/to/file.jpg"
plotly_output¶
def plotly_output(
key: str,
value: str,
label: Optional[str] = None,
tags: Optional[List[str]] = None
)
A Plotly chart with a label on top.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
ID of the element. It must be unique as it is the key used to story data in
Project(), otherwise it will lead to conflicts at runtime in both execution and
Streamlit modes. The key will be transformed into snake case and slugified to avoid
any special character or whitespace. Note that an ID cannot start with |
required |
value |
str
|
Path to the output Plotly JSON file which must have a |
required |
label |
Optional[str]
|
Typically to be used by Streamlit for display purpose only. If not defined, it
will default to the |
None
|
tags |
Optional[List[str]]
|
Optional meta-data information about the expected file. This information is only used when the JSON output attributes are written to the output manifest. |
None
|
**kwargs |
Any
|
Extra user meta-data to attach to the element. Argument names cannot overwrite
existing attributes or methods name such as |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
if the |
AttributeError
|
if one the |
Example
from onecode import csv_output, Mode, Project
Project().mode = Mode.CONSOLE
widget = plotly_output(
key="PlotlyOutput",
value="/path/to/file.json",
label="My PlotlyOutput",
tags=['Graph']
)
print(widget)
"/path/to/file.json"
text_output¶
def text_output(
key: str,
value: str,
label: Optional[str] = None,
tags: Optional[List[str]] = None,
truncate_at: int = 50000
)
A text file preview.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
ID of the element. It must be unique as it is the key used to story data in
Project(), otherwise it will lead to conflicts at runtime in both execution and
Streamlit modes. The key will be transformed into snake case and slugified to avoid
any special character or whitespace. Note that an ID cannot start with |
required |
value |
str
|
Path to the output CSV file which must have a |
required |
label |
Optional[str]
|
Typically to be used by Streamlit for display purpose only. If not defined, it
will default to the |
None
|
tags |
Optional[List[str]]
|
Optional meta-data information about the expected file. This information is only used when the JSON output attributes are written to the output manifest. |
None
|
truncate_at |
int
|
Truncate the preview at the specified number of characters. |
50000
|
**kwargs |
Any
|
Extra user meta-data to attach to the element. Argument names cannot overwrite
existing attributes or methods name such as |
{}
|
Raises:
Type | Description |
---|---|
ValueError
|
if the |
AttributeError
|
if one the |
Example
from onecode import text_output, Mode, Project
Project().mode = Mode.CONSOLE
widget = text_output(
key="TextOutput",
value="/path/to/file.txt",
label="My TextOutput",
tags=['Text'],
truncate_at=1000
)
print(widget)
"/path/to/file.txt"