Comment on page
Playground (Local Server)
Developing data apps fast with a local server
To initialize a local server with the Shimoku SDK, developers just have to initialize the client without credentials (
api_token
, universe_id
). This action signals the SDK to prepare a local server environment. The SDK also launches the associated front-end interface in the system's default browser.import shimoku_api_python as Shimoku
# Client initialization with playground mode
s = Shimoku.Client()

Playground initialized
We recommend the following parameters for a better development experience:
s = Shimoku.Client(
async_execution=True, # Grouped plotting
verbosity='INFO', # Insight in the execution
)
If a local server session in a specific port is already active, the SDK will connect to the existing session. There is no need to reinitialize a new server, allowing for continuous work without interruption.
In case the default port (
8000
) is already in use, it is necessary to change it in the client initialization, for example the port 8080
could be used:s = Shimoku.Client(
local_port=8080
async_execution=True,
verbosity='INFO',
)
It is not recommended to have more than one local server running, as the front-end application can only access one at a time (even in different tabs).
To terminate the server the following function has to be used, it will only close the server connected to the clients specified port:
s = Shimoku.Client(
local_port=8080
async_execution=True,
verbosity='INFO',
)
# Close the server in the port 8080
s.terminate_local_server()
When changes are made locally using the
s.run()
command, the SDK provides immediate feedback to the front-end. This live update system ensures developers can see the impact of their changes in real-time:# Necessary for compatibility with cloud execution
s.set_workspace()
# Set the grouper of the menu
s.set_board('Custom Board')
# Set the menu path 'catalog' with the sub-path 'bar-example'
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'],
)
# Necessary for notifying the front-end even if not using async execution
s.run()

Immediate feedback
The deployment with the Shimoku platform is very straight forward, just set your credentials in the client initialization and execute the same code you've been developing:
import shimoku_api_python as Shimoku
access_token: str = getenv('API_TOKEN') # Environment variable
universe_id: str = getenv('UNIVERSE_ID') # Environment variable
workspace_id: str = getenv('WORKSPACE_ID') # Environment variable
s = Shimoku.Client(
access_token=access_token,
universe_id=universe_id,
async_execution=True,
verbosity='INFO'
)
s.set_workspace(workspace_id)
. . .
- If you don't have these credentials you will need to create an account here, consult the Quickstart for further information.
- It is advisable to make sure that the contents of the playground can be replicated by the code before deploying.
The Shimoku Playground is an integral feature of the Shimoku platform, designed to facilitate local development.
- Local Server Utilization: Instead of connecting to the cloud-based Shimoku API, the Playground operates via a local server. This setup is initialized through the SDK, offering a more immediate and responsive development environment.
- Consistent API Compatibility: Code developed within the Playground is fully compatible with the Shimoku API. This ensures a smooth transition from local to cloud-based environments, allowing developers to switch between local and cloud deployments without needing to modify their code.
- No Token Consumption: The Playground runs on the developer's local machine, bypassing the need for token usage associated with cloud-based operations on the Shimoku platform. This is particularly beneficial for extensive testing and development, as it reduces the overhead costs typically incurred during the development process.
Last modified 25d ago