Streamlit dashboard app
Resource that contains a streamlit dashboard. See Streamlite agent to see how to generate it.
Views
Attributes
name: str
style: TypingStyle
tags: TagList
technical_info: TechnicalInfoDict
uid: str
Functions
Constructor, please do not overwrite this method, use the init method instead Leave the constructor without parameters.
Name | Type | Default value | Description |
---|---|---|---|
streamlit_app_code | str | ||
app_type | Literal | NORMAL | |
env_code | str |
Name | Type | Default value | Description |
---|---|---|---|
resources | List | _description_ [resource] | |
message_dispatcher | MessageDispatcher |
Add a resource to the StreamlitResource.
:raises Exception: description
Name | Type | Default value | Description |
---|---|---|---|
resource | Any | _description_ _type_ | |
create_new_resource | bool | True | _description_, defaults to true , optional |
Add technical information on the resource. Technical info are useful to set additional information on the resource.
Name | Type | Default value | Description |
---|---|---|---|
technical_info | TechnicalInfo | Technical information to add (key, value) |
You can redefine this method to define custom logic to check this resource. If there is a problem with the resource, return a string that define the error, otherwise return None This method is called on output resources of a task. If there is an error returned, the task will be set to error and next proceses will not be run. It is also call when uploading a resource (usually for files or folder), if there is an error returned, the resource will not be uploaded
Optional |
Clone the resource to create a new instance with a new id. It copies the RFields.
ResourceType |
Name | Type | Default value | Description |
---|---|---|---|
item | Any |
int |
Get the type of the streamlit app.
Literal |
You can redefine this method to set a name of the resource. When saving the resource the name will be saved automatically This can be useful to distinguish this resource from another one or to search for the resource
str |
Get the default style of the resource
TypingStyle |
Get the id of the resource model in the database. It is provided by the system for input resources of a task.
str |
Get the name of the resource or the default name if the name is None
str |
Get the parameters that will be passed to the streamlit app.
dict |
Return the first resource with the given name
Name | Type | Default value | Description |
---|---|---|---|
name | str | Name of the resource |
gws_core.resource.resource.Resource | None |
Return the resource model ids of the sub resources
Set |
Return the resource models of the sub resources list
List[ResourceModel] |
Return the sub resources as a list
List |
Return the sub resources as a set
Set |
Get the streamlit code.
str |
Get the technical information of the resource
Name | Type | Default value | Description |
---|---|---|---|
key | str | Key of the technical information |
TechnicalInfo |
Return true if the resource with the given id is in the resource list
Name | Type | Default value | Description |
---|---|---|---|
resource_model_id | str | Id of the resourcemodel |
bool |
Name | Type | Default value | Description |
---|---|---|---|
item | Any |
int |
This can be overwritten to perform custom initialization of the resource. This method is called after the init (constructor) of the resource. The values of RFields are set when this method is called.
Return true if the resource list is empty
bool |
Return True if the streamlit app is executed in a virtual environment.
bool |
Replace current resources by the resources in the dict
Name | Type | Default value | Description |
---|---|---|---|
resources | Dict | Dict where key is the resource model id and value is the resource [str, resource] |
Name | Type | Default value | Description |
---|---|---|---|
resource_origin | ResourceOrigin | ||
scenario | Scenario | ||
task_model | TaskModel | ||
port_name | str |
List[ResourceModel] |
Set the dashboard that will be used to generate the streamlit app. The Streamlit resource stores the dashboard typing name to find the dahsboard code. As long as the dashboard typing name does not change, the dashboard will be working.
If the dashboard code is updated, the SteamlitResource will automatically use the updated the dashboard code.
Name | Type | Default value | Description |
---|---|---|---|
dashboard | Dashboard | Dashboard object annotated with @dashboard_decorator and with get_folder_path method |
Set the code that will be executed in the streamlit environment. This code is executed before the streamlit app is loaded and can be used to load environment variables.
Name | Type | Default value | Description |
---|---|---|---|
env_code | str | Code that will be executed |
Set a parameter that will be passed to the streamlit app into the 'params' variable.
Name | Type | Default value | Description |
---|---|---|---|
key | str | Key of the parameter | |
value | Any | Value of the parameter (must be serializable to json) |
Set the parameters that will be passed to the streamlit app into the 'params' variable.
Name | Type | Default value | Description |
---|---|---|---|
params | dict | Parameters |
Set the streamlit code dynamically. The code is stored as a string, the dashboard need to be re-generated to update the code.
Name | Type | Default value | Description |
---|---|---|---|
streamlit_code | str | Eamlit code str |
Set the streamlit code from a file path. The file will be read and the content will be set as the streamlit code. Don't use this if you have multiple files for the streamlit app. In this case, use the set_streamlit_folder method. The code is stored as a string, the dashboard need to be re-generated to update the code.
:raises Exception: if the file does not exist
Name | Type | Default value | Description |
---|---|---|---|
streamlit_app_code_path | str | Path to the eamlit code str |
Set the folder that contains the streamlit code. The folder must contain a main.py file.
This is only recommended if you want to force the version of the dashboard in this Resource and avoid automatic updates. Otherwise use the set_dashboard method. The folder is copied and stored as a sub resource of the StreamlitResource. The dashboard need to be re-generated to update the code.
Name | Type | Default value | Description |
---|---|---|---|
streamlit_app_folder_path | str |
Name | Type | Default value | Description |
---|---|---|---|
key | Any | ||
reverse | bool | False |
Return the resources as a list
List |
Returns the name of the class
Name | Type | Default value | Description |
---|---|---|---|
slugify | bool | False | True to slugify the class name if true, defaults to false , optional |
snakefy | bool | False | True to snakefy the class name if true, defaults to false , optional |
replace_uppercase | bool | False | Replace upper cases by "-" if true, defaults to false , optional |
str |
Copy the style of the resource with the possibility to override some properties. Useful when settings the style for a task based on the resource style.
Name | Type | Default value | Description |
---|---|---|---|
icon_technical_name | str | Technical name of the icon if provided, the icon_type must also be provided, defaults to none , optional | |
icon_type | TypingIconType | Type of the icon if provided, the icon_technical_name must also be provided, defaults to none , optional | |
background_color | str | Background color, defaults to none , optional | |
icon_color | TypingIconColor | Icon color, defaults to none , optional |
TypingStyle |
Name | Type | Default value | Description |
---|---|---|---|
decorator_name | Any |
Returns the full name of the class
Name | Type | Default value | Description |
---|---|---|---|
slugify | bool | False | Slugify the returned class name if true, defaults to false , optional |
snakefy | bool | False | Snakefy the returned class name if true, defaults to false `` |
str |
Get the human name of the resource
str |
Get the short description of the resource
str |
Get the style of the resource
TypingStyle |
Get the typing name of the resource
str |
Get all the classes that inherit this class
List |
Returns the list of the methods
List |
method to migrate streamlit resources to use the dashboard class
Args: task_typing_name (str): typing name of the task that generated the SteamlitResource
Name | Type | Default value | Description |
---|---|---|---|
task_typing_name | str | ||
dashboard_typing_name | str |
Returns the module name of the class
str |
Retrieves the property names
Name | Type | Default value | Description |
---|---|---|---|
instance | type | The s of the properties to retrieve. set `none` to retrieve all. `type` or `union[type]` | |
exclude | type |
List |
Create a StreamlitResource from a file path. The file will be read and the content will be set as the streamlit code. Don't use this if you have multiple files for the streamlit app. In this case, use the set_streamlit_folder method.
Name | Type | Default value | Description |
---|---|---|---|
streamlit_app_code_path | str | _description_ |
StreamlitResource |