Shimoku docs
  • 🚀QuickStart
    • Installation & Setup
    • Minimal APP example
    • Extended Example
    • Templates & tutorials
  • 🤖Artificial Intelligence
    • Classification
      • Train Classification
        • Train Classification Outputs
      • Predict Classification
        • Predict Classification Outputs
    • Generate Insights
      • Generate Insights Outputs
  • 🛠️Building Web App
    • Environment
      • Overview
      • Environment Variables
    • Management
      • Managing Universes
      • Managing Workspaces
      • Managing Boards
    • Menu
      • Changing the Menu Path
      • Updating the Menu Path
      • Deleting the Menu Path
    • Grid
      • Using the Grid
    • Theming
      • Colors Usage
    • Actions
    • Modals
    • IO
  • 💡Elements
    • Summary
    • Charts
      • Table
        • Buttons Column
        • Filters
        • Search bars
        • Colored labels
      • HTML
        • Raw HTML
        • Beautiful Titles
        • Background Indicators
        • Click to New Tab
        • Box With Button
        • Panel
      • Indicators
        • Indicator
        • Grouped Indicators
        • Vertical Indicators
        • Color by Value
        • Gauge Indicator
        • Indicators with Header
      • Scatter Charts
        • Scatter
        • Scatter with Effect
      • Line Charts
        • Line
        • Predictive Line
        • Segmented Line
        • Marked Line
        • Line With Confidence Area
        • Top Bottom Line Charts
        • Summary Line
      • Area Charts
        • Area
        • Stacked Area
        • Segmented Area
        • Top Bottom Area Charts
      • Bar Charts
        • Bar
        • Stacked Bar
        • Horizontal Bar
        • Stacked Horizontal Bar
        • Zero Centered Bar
      • Pie Charts
        • Pie
        • Doughnut
        • Rose
      • Gauge Charts
        • Shimoku Gauge
        • Speed Gauge
      • Input forms
        • Group chained Inputs
        • List input search
        • Conditional inputs
        • Audio input
        • Drag & Drop
      • Line and Bar
      • Waterfall
      • Annotated Chart
      • Heatmap
      • Radar
      • Sunburst
      • Tree
      • Treemap
      • Sankey Diagram
      • Funnel chart
      • iFrame
    • Composite Template Charts
      • Infographics text bubble
      • Chart and Modal Button
      • Chart and Indicators
    • Data Sets
      • Data Set Filters
    • Create your own charts
      • Free Echarts
      • Bento box
    • Features & Navigation
      • Tabs
      • History navigation & Breadcrumb
  • 🔍Advanced usage
    • CLI
    • Workflow Triggers
    • Code Generation
  • 🌍Cloud & Community
    • Shimoku Cloud
    • Shared links
    • Handling Workspaces & Users
      • User authentication
      • Inviting users
      • Creating users
      • Users with multi-workspace access
  • 🌐Releases
    • 2024
      • v.2.6
      • v.2.5
      • v.2.4
      • v.2.3
        • v.2.3.1
      • v.2.2
        • v.2.2.3
        • v.2.2.2
        • v.2.2.1
      • v.2.1
        • v.2.1.2
        • v.2.1.1
      • v.2.0
        • v.2.0.(1..4)
      • v.1.6
        • v.1.6.1
      • v.1.5
    • 2023
      • v.1.4
        • v.1.4.1
        • v.1.4.2
      • v.1.3
      • v.1.2
        • v.1.2.1
      • v.1.1
        • v.1.1.1
      • v.1.0
        • v.1.0.2
        • v.1.0.1
      • v.0.20
      • v.0.19
      • v.0.18
      • v.0.17
        • v.0.17.1
      • v.0.16
        • v.0.16.3
        • v.0.16.2
        • v.0.16.1
      • v.0.15
      • v.0.14
    • 2022
      • v.0.13
        • v.0.13.3
      • v.0.12
      • v.0.11
      • v.0.10
        • v.0.10.4
        • v.0.10.3
        • v.0.10.1
      • v.0.9
      • v.0.8
      • v.0.7
        • v.0.7.1
      • v.0.6
      • v.0.5
      • v.0.4
      • v.0.3
        • v0.3.2
        • v0.3.1
      • v.0.2
Powered by GitBook
On this page

Was this helpful?

  1. Building Web App

IO

File IO

Shimoku users can store and retrieve files in Shimoku as part of our service. Every file is assigned to a workspace and a menu path.

The provided methods are (using s as the Shimoku client):

# To delete an existing file
s.io.delete_file(file_name: str)

# To post a file represented in bytes
s.io.post_object(file_name: str, obj: bytes, overwrite: bool = True)

# To get a file, it will be returned in bytes
s.io.get_object(file_name: str) -> bytes

# To post a dataframe as a file, it will convert it to csv encoding it in 'utf-8'
s.io.post_dataframe(file_name: str, df: pd.DataFrame, overwrite: bool = True)

# To get a file that will be interpreted as a dataframe decoding it using 'utf-8'
s.io.get_dataframe(file_name: str) -> pd.DataFrame

# To post a dataframe into multiple batched files
s.io.post_batched_dataframe(file_name: str, df: pd.DataFrame, batch_size: int = 10000, overwrite: bool = True)

# To get multiple files that joined they form a dataframe
s.io.get_batched_dataframe(file_name: str) -> pd.DataFrame

# To delete multiple files that joined they form a dataframe
s.io.delete_batched_dataframe(file_name: str)

# To post an ai model as a file, it will use the pickle serialization
s.io.post_ai_model(model_name: str, model: Callable)

# To get a file that will be deserialized by using pickle, normally representing an ai model
s.io.get_ai_model(model_name: str) -> Any

# To get all the files from a menu path
s.menu_paths.get_menu_path_files(
    self, uuid: Optional[str] = None, name: Optional[str] = None
) -> List[Dict]

# To delete all the files from a menu path
s.menu_paths.delete_all_menu_path_files(
    self, uuid: Optional[str] = None, name: Optional[str] = None
)

Example #1 You can store raw binary or string objects and retrieve them (they can be ML models or any other binary object)

file_name = 'helloworld'
s.set_menu_path('test')
object_data = b''

s.io.post_object(file_name, object_data)
object: binary = s.io.get_object(file_name=file_name)

Example #2 You can also store pandas dataframes (of any size) and retrieve them easily:

file_name: str = 'df-test'
d = {'a': [1, 2, 3], 'b': [1, 4, 9]}
s.io.post_dataframe(file_name, df=pd.DataFrame(d))
df: pd.DataFrame = s.io.get_dataframe(file_name=file_name)

Example #3 In case the dataframe is very big you can use the batched version that will create batches and store them in different files. It will append the string '_batch_{n}':

df = pd.read_csv('bigdata.csv').reset_index(inplace=True)
s.io.post_batched_dataframe(file_name='test-big-df', df=df)
df: pd.DataFrame = s.io.get_batched_dataframe(file_name='test-big-df')

IO methods for Machine Learning models:

from sklearn import svm
from sklearn import datasets

clf = svm.SVC()
X, y = datasets.load_iris(return_X_y=True)
clf.fit(X, y)

s.io.post_ai_model(model_name='model-test', model=clf)
model = s.io.get_ai_model(model_name='model-test')
PreviousModalsNextSummary

Last updated 1 year ago

Was this helpful?

🛠️