---
gitea: none
include_toc: true
---

 # PerfSPEC Learning Phase  INSTALLATION

 By follwing thesed steps you can easy run **PerfSPEC notebooks**

## Python

> [!CAUTION]
> Due to [TensorFlow requiremens](https://www.tensorflow.org/install/pip) **Python 3.12** is the latest compatible


For Linux

I end up by downloading **Python soruce** and compile

For MacOS 

Use [Homebrew](https://brew.sh/)
```
brew install python@3.12 python3-pip
```

> [!WARNING]  
> After install Python with **pip** and **virtualenv** <br>
> Install [TensorFlow requiremens](https://www.tensorflow.org/install/pip)

```
pip install tensorflow
```

### Package manager 

Use [uv](https://docs.astral.sh/uv/) 

> An extremely fast Python package and project manager, written in Rust.

MacOS and Linux

```
sudo curl -LsSf https://astral.sh/uv/install.sh | sh
```

To add $HOME/.local/bin to your PATH, either restart your shell or run:

    source $HOME/.local/bin/env (sh, bash, zsh)
    source $HOME/.local/bin/env.fish (fish)

## Notebook tool

Rather than use [Jupyter](https://jupyter.org/) this project use [Marimo](https://marimo.io/) for a lot of good reasons !

#### Marimo 

```
python -m venv marimo-env
source marimo-env/bin/activate
uv pip install marimo
```

Check with `marimo tutorial intro --no-token`

A web server should be run at `http://localhost:2718` with a token if not use **--no-token** option for a non secure session

[Marimo](https://marimo.io/) configuration is in `$HOME/.config/marimo.toml` 

## PerfSPEC Learning Phase  

#### 1 - `git clone this repository` 

```
git clone https://repo.jesusperez.pro/jesus/perfSPEC-learning.git
cd perfspec-learning
```

#### 2 - Make structures
   
For **data**  use [data_sample.tar.xc](https://repo.jesusperez.pro/jesus/perfspec-learning/src/branch/main/data_sample.tar.xz)

```
tar xvJf data_sample.tar.xz 
```

For trained models use [models_sample.tar.xz](https://repo.jesusperez.pro/jesus/perfspec-learning/src/branch/main/models_sample.tar.xz)

```
tar xvJf models_sample.tar.xz 
```

Raw log file [raw-audit-logs.log.xz](https://repo.jesusperez.pro/jesus/perfspec-learning/src/branch/main/raw-audit-logs.log.xz) is included in **data** directory
 

#### 3 - Run notebook tool like this

Inside `perfspec-learning` path 

```
cd  learning/python 
uvx marimo edit   --no-token   --watch
```
Connect with a browser to **http://localhost:2718** 

Start with [run_perfspec.py](https://repo.jesusperez.pro/jesus/perfspec-learning/src/branch/main/learning/python/run_perfspec.py)

>[!IMPORTANT]  
> A red box will appear at top left corner prompting to install required packages for the loaded notebook, in console where localhost:2718 appers listening [uv](https://docs.astral.sh/uv/) will do the magic by installing them using **pip** 

Note each notebook can import some extra packages like [train_perfspec.py](https://repo.jesusperez.pro/jesus/perfspec-learning/src/branch/main/learning/python/train_perfspec.py)

In any case some notebook import content from others.

> [!Tip]
> When all notebooks have being loaded it will be posible also to use them as a Python script by run it in a terminal o console like this:

```
python model_perfspec.py -- --help 
```

There is also an static html mode to be used, more info: [script mode](https://docs.marimo.io/guides/scripts/)

Some Python packages could be not detected and will require manual installation via command-line, simply for example, use: 

```
uv pip install scikit-learn
uv pip install prettytable
```
