# Shimoku Cloud

## Summary

{% embed url="<https://www.youtube.com/embed/Aj3uchOv5l8?si=OaA2MrpuldxMeAuS>" %}

## Step 1 - Create an account

|                                                                                                                                         1                                                                                                                                         |                                                                                                                                        2                                                                                                                                        |
| :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|                                                                                                    **Go** to [shimoku.io](https://shimoku.io/sign-up) to **create an account**                                                                                                    |                                                                                                                  **Review** your inbox and **confirm** account                                                                                                                  |
| <p></p><p></p><p><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FDd5DGLP9XmAEjvCVmM6m%2Fsign-up.png?alt=media&#x26;token=a7a231a7-08ff-4161-b4e7-a6db2add8266" alt="" data-size="original"></p> | <p></p><p></p><p><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FEYAYtVOmKPMJWXaeIPrj%2Fimage.png?alt=media&#x26;token=80b1e962-97cb-48bd-bca4-5767d0dc9f23" alt="" data-size="original"></p> |

|                                                                                                                                            3                                                                                                                                           |                                                                                                                                            4                                                                                                                                           |
| :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: |
|                                                                                                       Click on "**Return to Sign In section"** and sign in with your credentials                                                                                                       |      Click your **Profile button** on the top right and go to **"Settings"**. Inside **"Information for developers"** click on "**Create"** to generate your API Token and save this information, the **"Universe ID"** and the **"Business ID"** also known as **Workspace ID.**      |
| <p></p><p></p><p></p><p><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FyI0DKtYpBCW98QiBdL2O%2Fimage.png?alt=media&#x26;token=4fe0bc0f-e73c-4c30-bb43-25dce3b7d380" alt="" data-size="original"></p> | <p></p><p></p><p></p><p><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FlyWlkp41bohT78JKpRaZ%2Fimage.png?alt=media&#x26;token=1932af00-da7f-4828-ab83-49ee23dd55fb" alt="" data-size="original"></p> |

## Step 2 - Start Client, Plotting and Menu Handling

Go ahead and copy paste to see  :magic\_wand:

```python
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:

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2Fky9vOhfdElnDkFISlXQd%2FQuickstart.png?alt=media&#x26;token=ffa3b660-2e5b-4af0-9d84-4d15a632f9c8" alt=""><figcaption><p>Language expressiveness ratio in comparison to C</p></figcaption></figure>

## 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'.&#x20;

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

```python
                             s.set_board(name: str)
```

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

<details>

<summary>Multiple boards Issue</summary>

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:

```bash
> 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:

```bash
> 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.

</details>

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FJD6vrKBmJkLrRhUlTkmM%2FQuickstart%20Multiple%20Boards.png?alt=media&#x26;token=f0c5a63c-b5b4-430f-9315-62406189f0de" alt=""><figcaption><p>Two boards with the same menu path</p></figcaption></figure>

{% hint style="info" %}
For more detailed information see [menu](https://docs.shimoku.com/dev/building-web-app/menu "mention")
{% endhint %}

## 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`*.*&#x20;

<pre class="language-python"><code class="lang-python">s = Shimoku.Client(
    access_token=access_token,
    universe_id=universe_id,
<strong>    verbosity='INFO',
</strong>)
</code></pre>

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

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:

<pre class="language-python"><code class="lang-python">s = Shimoku.Client(
    access_token=access_token,
<strong>    universe_id=universe_id,
</strong>    verbosity='INFO',
    async_execution=True,
)
</code></pre>

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

```python
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()`.

{% hint style="warning" %}
Be sure to call *`s.run()`* at the end of your code to ensure all tasks are executed before the program terminates.
{% endhint %}

```python
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

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2Fm73NmFpPLHEIWCDO9i4A%2FCaptura%20de%20Pantalla%202023-05-16%20a%20las%2016.53.13.png?alt=media&#x26;token=8750b62d-feb0-4c56-9617-cc44cb2410af" alt=""><figcaption><p>Sign in</p></figcaption></figure>

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FCuQHYvuwMpFbYN2LSK8K%2Fimage.png?alt=media&#x26;token=1ca48996-295a-4a0d-86d4-09ce9f96b1ea" alt=""><figcaption><p>Dashboard</p></figcaption></figure>

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FBWx2n654dIeN3bE1O3Bu%2Fimage.png?alt=media&#x26;token=75fc26c2-46f4-4885-a50d-36831447fe6b" alt=""><figcaption><p>Theme custom</p></figcaption></figure>

<figure><img src="https://3782181538-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUlHTfmIZY46Z1EDfyGMz%2Fuploads%2FLrXixIho18pw0n48OY0Q%2Fimage.png?alt=media&#x26;token=2131a95b-de34-426e-958d-b2974218bf79" alt=""><figcaption><p>Invitation users view</p></figcaption></figure>

{% hint style="success" %}
**With an unlimited number of users**
{% endhint %}

More on creating new users on [creating-users](https://docs.shimoku.com/dev/cloud-and-community/handling-workspaces-and-users/creating-users "mention").
