Skip to content

Commit

Permalink
uv run commands
Browse files Browse the repository at this point in the history
  • Loading branch information
FloSch62 committed Jan 12, 2025
1 parent 5667e8d commit cdbdb86
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 27 deletions.
49 changes: 33 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,45 @@ actual file names in your environment.
## Running locally
> [!IMPORTANT]
> Python 3.6+ is required if you prefer running these tools locally.
> Python 3.11+ is required if you prefer running these tools locally.
### Installation
#### Virtual Environment Setup
> [!TIP]
> Using a virtual environment is recommended to avoid version conflicts
> with global Python packages.
> **Why uv?**
> [uv](https://docs.astral.sh/uv) is a single, ultra-fast tool that can replace `pip`, `pipx`, `virtualenv`, `pip-tools`, `poetry`, and more. It automatically manages Python versions, handles ephemeral or persistent virtual environments (`uv venv`), lockfiles, and often runs **10–100× faster** than pip installs.
```bash
python3 -m venv venv
source venv/bin/activate
```
1. **Install uv** (no Python or Rust needed):
```
# On macOS and Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
```
#### Installing Dependencies
2. **Run the tool** (uv automatically installs dependencies in a venv from `pyproject.toml`):
```
uv run python clab2drawio.py --help
```
After activating the virtual environment, install the required packages from the requirements.txt file:
## Alternative: Using pip
If you’d rather use pip or can’t install uv:
1. **(Optional) Create & Activate a Virtual Environment**:
```
python -m venv venv
source venv/bin/activate
```
2. **Installing Dependencies**
After activating the virtual environment, install the required packages from the requirements.txt file:
```bash
pip install -r requirements.txt
```
> [!NOTE]
> If you installed dependencies using pip instead of uv, simply run the commands using `python` directly instead of `uv run python`
```bash
pip install -r requirements.txt
```
# Usage
Expand All @@ -105,7 +122,7 @@ Detailed Usages: [drawio2clab.md](docs/drawio2clab.md#usage) and [clab2drawio.md
## drawio2clab
```bash
python drawio2clab.py -i <input_file.drawio>
uv run python drawio2clab.py -i <input_file.drawio>
```
- `-i, --input`: path to your `.drawio` file.
Expand All @@ -119,7 +136,7 @@ python drawio2clab.py -i <input_file.drawio>
## clab2drawio
```bash
python clab2drawio.py -i <input_file.yaml>
uv run python clab2drawio.py -i <input_file.yaml>
```
- `-i, --input`: path to your Containerlab YAML file.
Expand Down
16 changes: 8 additions & 8 deletions docs/clab2drawio.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ for real-time network monitoring.
To generate a network topology diagram from a containerlab YAML file, run the following command:

```bash
python clab2drawio.py -i <path_to_your_yaml_file>
uv run python clab2drawio.py -i <path_to_your_yaml_file>
```
> [!NOTE]
> By default, the `.drawio` file is saved in the same folder as the input YAML.
Expand Down Expand Up @@ -72,23 +72,23 @@ spine1:
- `-i, --input`: Specifies the filename of the input file. This file should be a containerlab YAML for diagram generation. This argument is required.

```bash
python clab2drawio.py -i <path_to_your_yaml_file>
uv run python clab2drawio.py -i <path_to_your_yaml_file>
```

- `-o, --output`: Specifies the output file path for the generated diagram in draw.io format.

```bash
python clab2drawio.py -i <path_to_your_yaml_file> -o <path_to_output_file>
uv run python clab2drawio.py -i <path_to_your_yaml_file> -o <path_to_output_file>
```
- `-g, --gf_dashboard`: Generates a Grafana dashboard in Grafana style.

```bash
python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana
uv run python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana
```
- `--grafana-config`: Path to a Grafana YAML config file. If omitted, defaults are used.

```bash
python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana --grafana-config <path_to_your_cfg_file>
uv run python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana --grafana-config <path_to_your_cfg_file>
```

For more detailed information about this feature, including compatibility, usage guidelines, and future enhancements, please see the [Grafana Dashboard Documentation](./grafana.md).
Expand All @@ -102,13 +102,13 @@ spine1:
- `--theme`: Specifies the theme for the diagram (`nokia`, `nokia_modern`, or ... ) or the path to a custom style config file. By default, the `nokia` theme is used. Users can also create their own style file and place it in any directory, specifying its path with this option. Feel free to contribute your own styles.

```bash
python clab2drawio.py --theme nokia_dark -i <path_to_your_yaml_file>
uv run python clab2drawio.py --theme nokia_dark -i <path_to_your_yaml_file>
```

Or using a custom style file:

```bash
python clab2drawio.py --theme <path_to_custom_style_file> -i <path_to_your_yaml_file>
uv run python clab2drawio.py --theme <path_to_custom_style_file> -i <path_to_your_yaml_file>
```

- `-I`, `--interactive`: Define graph-levels and graph-icons in interactive mode
Expand All @@ -123,7 +123,7 @@ spine1:
You can apply different style themes such as `nokia`, `nokia_modern` or `grafana`:

```bash
python clab2drawio.py --theme nokia_modern -i <path_to_yaml>
uv run python clab2drawio.py --theme nokia_modern -i <path_to_yaml>
```

> [!TIP]
Expand Down
2 changes: 1 addition & 1 deletion docs/drawio2clab.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ The above image demonstrates how to correctly label nodes and links and add addi
Convert a .drawio file to YAML:

```bash
python drawio2clab.py -i input_file.drawio
uv run python drawio2clab.py -i input_file.drawio
```

> [!TIP]
Expand Down
4 changes: 2 additions & 2 deletions docs/grafana.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ The `-g, --gf_dashboard` command line option is designed to automate the generat
### Usage
To generate a dashboard, execute the following command:
```bash
python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana
uv run python clab2drawio.py -i <path_to_your_yaml_file> -g --theme grafana
```
> [!TIP]
> Use a Grafana-compatible theme like `grafana_dark` for a more cohesive look.
Expand Down Expand Up @@ -51,7 +51,7 @@ The `--grafana-config` option lets you customize Grafana Flow Panel settings. If
To use a custom configuration:
```bash
python clab2drawio.py -i <path_to_yaml> -g --theme grafana --grafana-config <path_to_config>
uv run python clab2drawio.py -i <path_to_yaml> -g --theme grafana --grafana-config <path_to_config>
```

> [!TIP]
Expand Down

0 comments on commit cdbdb86

Please sign in to comment.