# Code generation

The code generation feature in the learning module allows users to generate Python code for their experiments with a simple click. This feature enables users to make in-depth changes to the experiment code, share it with other computer scientists, and navigate seamlessly between the user interface and the code base.&#x20;

After running one or multiple experiment pipelines, follow the instructions below to generate the code for a given pipeline.

* Open the results panel:

<figure><img src="https://314741292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWC0t7nEhhoOT73GRY714%2Fuploads%2FL6dwaCyqYjMmGDQN6ZVh%2FCodeGeneration1.png?alt=media&#x26;token=eb734d5f-9b13-4f89-8523-04eb440b16a9" alt=""><figcaption></figcaption></figure>

* Click the *Generate* button to select your pipelines for code generation:

<figure><img src="https://314741292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWC0t7nEhhoOT73GRY714%2Fuploads%2FslKEY0dGAsAF1XPLqwNl%2FCodeGeneration2.png?alt=media&#x26;token=7078dea5-10bf-49e1-a964-8333d7a163cc" alt=""><figcaption></figcaption></figure>

* Select the pipelines

<figure><img src="https://314741292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWC0t7nEhhoOT73GRY714%2Fuploads%2FMYRkctXN4vCWw5lflVd9%2FCodeGeneration3.png?alt=media&#x26;token=5507e808-775e-444a-9888-aaa91412ffbd" alt=""><figcaption></figcaption></figure>

* Click generation:

<figure><img src="https://314741292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWC0t7nEhhoOT73GRY714%2Fuploads%2F3i8soCsjBMYxnB7FT7Bu%2FCodeGeneration4.png?alt=media&#x26;token=a4afe228-8535-4be7-b03f-d52ae5d1dde4" alt=""><figcaption></figcaption></figure>

Consequently, a[ *juypter notebook*](https://jupyter.org/) will automatically open with the generated code:

<figure><img src="https://314741292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWC0t7nEhhoOT73GRY714%2Fuploads%2F1GGVlDjRF6kF2tInnfiA%2Fimage.png?alt=media&#x26;token=24e3d421-9d8f-44b4-bdf1-977b62e489af" alt=""><figcaption></figcaption></figure>

{% hint style="danger" %}
In most cases, you need to select the appropriate kernel before running the Jupyter notebook. Follow the instructions below to do so.
{% endhint %}

### Selecting the kernel for your generated code

* Click kernel
* Change kernel
* Select: *med\_conda\_env*
* The selected kernel's name must appear on the top right

<figure><img src="https://314741292-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWC0t7nEhhoOT73GRY714%2Fuploads%2FUJk57am6OImjFM3mhzrH%2FJupyterNotebookKernel.png?alt=media&#x26;token=83ca9d09-4777-4a77-b123-33f8d43a2d77" alt=""><figcaption></figcaption></figure>

{% hint style="warning" %}
If *med\_conda\_env* kernel is missing from your kernel's list.  Follow the instructions below to add it.
{% endhint %}

Add your *med\_conda\_env* to your kernel's list by running the following two commands:

```
conda activate med_conda_env
python -m ipykernel install --user --name=med_conda_env
```

Please feel free to [contact us](https://medomicslab.gitbook.io/mediml-app-docs/forms/contact-us) if you need any further assistance :innocent:.
