> For the complete documentation index, see [llms.txt](https://cleyrop.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cleyrop.gitbook.io/docs/documentation-fr-en/data-and-ai-project/cleyrop-codelab.md).

# Cleyrop Codelab

Codelab allows you to open a **Jupyter notebook** directly linked to a **Cleyrop Git project** : you version control your notebooks and scripts, work by **branches**, and propose **change requests** (approval/merge). Jupyter sessions are **ephemeral** (16 h) but can be restarted with the **power** you want.

***

## Open a session

1. Select a project in My Projects.
2. Click on Notebooks, choose your power configuration
3. Create and save the file (clear name, e.g. exploration\_clients.ipynb).

{% hint style="warning" %}
Each user has their own Jupyter session, which has a **2 GB storage space; it is recommended not to store large files in the session** but in Work Data

It is not **possible to create a Dataset** from Codelab
{% endhint %}

### Reconnecting an inactive session

* Jupyter sessions expire after 16 h.
* When reconnecting, choose the image (software environment) and the power (CPU/RAM/GPU if available).
* Restart your kernel if necessary; your versioned files remain in the project repo.

## Use Cleyrop resources from Codelab

### **Use Work Data**

You can use the project's Work Data files and folders from a notebook or script by following the guide [access the **Work Data**](/docs/documentation-fr-en/data-and-ai-project/donnees-de-travail-fichiers/utiliser-les-donnees-dans-un-script.md#utiliser-dans-le-codelab)**.**

### Use the PyAi library

You can use the [**PyAi library**](/docs/documentation-fr-en/the-factory/deployer-des-apps-et-des-tools.md#utiliser-la-librairie-de-composants-cleyrop) by following the guide.

### Use Datasets

You can use the library **`cleyrop_datasets`.** You can use it directly without importing it.

* `cleyrop_datasets` : list of datasets
* `cleyrop_datasets["ID_unique_dataset"]` : dataset dataframe

<figure><img src="/files/3b8f485b3b0fec9a5a3d8414645a08d8bf6d2778" alt=""><figcaption></figcaption></figure>

## Collaborate and version control with Git

Each Cleyrop project has a shared Git repository to **version control** the exploration notebooks and scripts (Notebooks tab).

In the project, click Codelab, you can:

* tab **Scripts** : browse scripts by branch, create a branch, or propose a change
* tab **Branch** : list and delete branches
* tab **Change requests** : list change proposals and view their content

{% hint style="info" %}

* `main` cannot be deleted.
* If a linked change request is open, it is deleted.
  {% endhint %}

### Write to a Git repository in The Factory from Notebooks

It is possible, from the Jupyter session, to push content to a repo hosted in **The Factory** by adding it as a Git remote.

**Add The Factory repo as a remote**

1. In The Factory, open the target repository and copy its **Link** (format `git@cleyrop:mon-depot.git`).

<figure><img src="/files/f958a4afcdaafa1d4357afd845408412e463f227" alt="" width="563"><figcaption></figcaption></figure>

2. Go to the desired project and start a Jupyter session from the tab **Notebooks**.
3. In the JupyterLab menu bar, open **Git** > **Manage Remote Repositories**.

<figure><img src="/files/4e1f687ba33a3e09e3f38ee0a4585f7c585d4bb5" alt=""><figcaption></figcaption></figure>

4. Enter a name (e.g. `internal`) and paste the copied URL.

<figure><img src="/files/c5545ea914c5191b636e7f5752064bbbcb1a8548" alt=""><figcaption></figcaption></figure>

5. Click **Add**. After refreshing, the remote appears in the list of branches in the Git panel (e.g. `internal/main`).

{% hint style="info" %}
**Best practice** : avoid naming the new repository "origin" to prevent confusion.
{% endhint %}

<figure><img src="/files/5aae7ed8ad783b8b5e24e1502e486bc051aa41df" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/16aecb34381d417cf4046c9c34569238af3def69" alt=""><figcaption></figcaption></figure>

**Push files to the repo**

1. Create new branches, create or edit your files in the session via the interface or through command lines in the terminal.
2. In the side Git panel (tab **Untracked**), click the `+` next to each file to include to move it to **Staged**.

<figure><img src="/files/a6ca1549775e87cea6fd6da699857d6cf6b205d4" alt=""><figcaption></figcaption></figure>

3. Enter a summary in the **Summary** and click **COMMIT**.
4. In the menu **Git**, select **Push to Remote (Advanced)**, choose the target remote and branch, then confirm.

<figure><img src="/files/c128e22cb89c7f6beb56815e58e3d14d9e6ce3fb" alt=""><figcaption></figcaption></figure>

<figure><img src="/files/dcf7df02db8e34e5f229de9eaf519250fbd7d551" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
**Push to Remote (Advanced)** is also necessary to push a new branch for the first time, even to the project's origin remote..
{% endhint %}

### Propose a change

A change proposal (merge request) lets you merge your changes into a target branch.

It must be **validated by an approver** (who can approve or reject with a comment)

Possible statuses:

* **Pending validation** : created, under review.
* **Conflict** : a conflict must be resolved before review.
* **Approved** : validated by the approver.
* **Rejected** : rejected by the approver.

To **create a proposal**

1. From the Change requests tab, click `+ Propose a change`.
2. Fill in: name, source branch, delete source after merge (optional), description, approver.
3. Click Add.

### List, view, and approve

* Click on a change request (name, author, date, status).
* View the diffs.
* Approve / Reject (**only by the approver**) : action from the request row.

{% hint style="info" %}
Best practices: one branch per topic, clear messages, cleaned notebooks (heavy outputs removed) before proposing a change.
{% endhint %}
