Shimoku Cloud

Persist your data with us

Summary

Step 1 - Create an account

Step 2 - Start Client, Plotting and Menu Handling

from os import getenv
from shimoku import Client

access_token = getenv('SHIMOKU_TOKEN')
universe_id: str = getenv('UNIVERSE_ID')
workspace_id: str = getenv('WORKSPACE_ID')

s = Client(
    access_token=access_token,
    universe_id=universe_id,
)
s.set_workspace(uuid=workspace_id)

s.set_board('Custom Board')

s.set_menu_path('catalog', 'bar-example')

language_expressiveness = [
    {'Language': 'C', 'Statements ratio': 1.0, 'Lines ratio': 1.0},
    {'Language': 'C++', 'Statements ratio': 2.5, 'Lines ratio': 1.0},
    {'Language': 'Fortran', 'Statements ratio': 2.0, 'Lines ratio': 0.8},
    {'Language': 'Java', 'Statements ratio': 2.5, 'Lines ratio': 1.5},
    {'Language': 'Perl', 'Statements ratio': 6.0, 'Lines ratio': 6.0},
    {'Language': 'Smalltalk', 'Statements ratio': 6.0, 'Lines ratio': 6.25},
    {'Language': 'Python', 'Statements ratio': 6.0, 'Lines ratio': 6.5},
]

s.plt.bar(
    order=0, title='Language expressiveness',
    data=language_expressiveness, x='Language',
    y=['Statements ratio', 'Lines ratio'],
)

Once you execute this piece of code you can see the following plot in your shimoku.io page:

Step 3 - Board

As it can be seen in the previous image the first element in the menu is called 'Custom Board', this element is a board. The boards are necessary for the contents of a menu path to be seen, if a menu path is not included in a board it will not appear in the page. For this reason the SDK always attaches the menu paths to a board when creating content, ideally the user should define which name to use for the board, but when it is not specified it will use the name 'Default Name'.

The method to specify the board's name that the SDK should use is:

                             s.set_board(name: str)

This will ensure that all the menu paths used after that point are included in name.

Multiple boards Issue

There is a possible issue that can arise from executing code multiple times with different board names, as it can be seen in the result two boards have been created with the same menu path attached.

In case this wasn't the expected result, it can be solved very easily using the CLI command:

> shimoku cloud delete board --force

This will ask for a specific board and delete it, but first it will delete all of it's links to it's menu paths, so it will always be able to delete an existing board without having to touch the menu paths. In this case the execution of the command would be as follows:

> shimoku cloud delete board --force
> board: Default Board
> dateTime | INFO | Starting execution: force_delete_board
> dateTime | INFO | Retrieved board Custom Board with id ...
> dateTime | INFO | Retrieved board Custom Board with id ...
> dateTime | INFO | Finished execution: force_delete_board, elapsed time: 7129.70 ms

Then there will only exist the 'Custom Board' linking to the 'catalog' menu path.

For more detailed information see Menu

Step 4 - Productivity boost

Verbosity

There is now the option to monitor the SDK flow of execution, with three levels of verbosity. This will help to know where the error occurred, so it will make bug-fixing a lot easier, It also outputs how much time the function call has taken to quickly profile code. To enable it you just have to set the parameter verbosity from the client to INFO or DEBUG.

s = Shimoku.Client(
    access_token=access_token,
    universe_id=universe_id,
    verbosity='INFO',
)

The INFO keyword will be the most useful for visualizing the execution while DEBUG is made so it outputs as much information as possible.

You can also set it to WARNING but this is the default behavior and will have no effect, it will output only warnings and errors.

The logging level of the Shimoku SDK can be configured dynamically during execution by calling the s.configure_logging function with the desired verbosity level (either 'DEBUG', 'INFO', or 'WARNING') and an optional channel to write the log output to. This allows for fine-grained control over the logging behavior and output, making it easier to debug and profile the SDK's execution.

Asynchronous execution

When the SDK is set to execute asynchronously it does not stop for each request to finish before making a new one, speeding up a lot the execution (mostly in the plotting layer). To enable it, simply set the async_execution parameter to True when creating the client object:

s = Shimoku.Client(
    access_token=access_token,
    universe_id=universe_id,
    verbosity='INFO',
    async_execution=True,
)

By default, execution is set to sequential. You can toggle between sequential and asynchronous execution using the following functions:

s.activate_async_execution()
s.activate_sequential_execution()

When asynchronous execution is enabled, tasks are added to a task pool and executed once a strictly sequential task is reached. A function has been added to allow users to trigger the execution of tasks, which is s.run().

Be sure to call s.run() at the end of your code to ensure all tasks are executed before the program terminates.

from os import getenv
from shimoku import Client

access_token = getenv('SHIMOKU_TOKEN')
universe_id: str = getenv('UNIVERSE_ID')
workspace_id: str = getenv('WORKSPACE_ID')

s = Client(
    access_token=access_token,
    universe_id=universe_id,
    verbosity='INFO',
    async_execution=True,
)
s.set_workspace(workspace_id)

s.set_board('Custom Dashboard')

s.set_menu_path('catalog', 'bar-example')

language_expressiveness = pd.read_html(
    'https://en.wikipedia.org/wiki/Comparison_of_programming_languages')[2]

s.plt.bar(
    order=0, title='Language expressiveness',
    data=language_expressiveness, x='Language',
    y=['Statements ratio[48]', 'Lines ratio[49]'],
)

s.run()

Overview PAW

With an unlimited number of users

More on creating new users on Creating users.

Last updated