> For the complete documentation index, see [llms.txt](https://medomicslab.gitbook.io/mediml-app-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://medomicslab.gitbook.io/mediml-app-docs/code-generation.md).

# 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="/files/aKaLmyO8OqCIbZT0aaVi" alt=""><figcaption></figcaption></figure>

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

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

* Select the pipelines

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

* Click generation:

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

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

<figure><img src="/files/uXQ1xNMPnLMzjcgJrVXo" 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="/files/snFwtuRNuiLaVnkOuq8m" 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](/mediml-app-docs/forms/contact-us.md) if you need any further assistance :innocent:.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://medomicslab.gitbook.io/mediml-app-docs/code-generation.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
