Skip to content

Commit b0c8d36

Browse files
author
Issam Kadar
committed
chore/security : migrate csv_parser from pip to uv
1 parent f46991a commit b0c8d36

8 files changed

Lines changed: 694 additions & 24 deletions

File tree

.github/workflows/generate-model.yaml

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,21 @@ jobs:
4242
if: steps.filter.outputs.parsing_required == 'true'
4343
uses: ts-graphviz/setup-graphviz@v1
4444

45-
- name: Setup Python
46-
uses: actions/setup-python@v5
45+
- name: Install uv
46+
if: steps.filter.outputs.parsing_required == 'true' || steps.filter.outputs.test_case_parsing_required == 'true'
47+
uses: astral-sh/setup-uv@v7
4748
with:
4849
python-version: '3.11'
50+
enable-cache: true
51+
52+
- name: Install Python
53+
if: steps.filter.outputs.parsing_required == 'true' || steps.filter.outputs.test_case_parsing_required == 'true'
54+
run: uv python install 3.11
4955

5056
- name: Install python requirements
5157
working-directory: ./csv_parser
5258
if: steps.filter.outputs.parsing_required == 'true' || steps.filter.outputs.test_case_parsing_required == 'true'
53-
run: pip install -r ./requirements.txt
59+
run: uv sync
5460

5561
- name: Clean up old generated schemas
5662
working-directory: ./src/main/resources
@@ -66,19 +72,19 @@ jobs:
6672
- name: Run csv_parser to generate schemas.yaml
6773
working-directory: ./csv_parser
6874
if: steps.filter.outputs.parsing_required == 'true'
69-
run: python workflow.py --stage output_schemas_yaml
75+
run: uv run python workflow.py --stage output_schemas_yaml
7076

7177
- name: Run csv_parser and collect OpenAPI & JSON Schemas
7278
working-directory: ./csv_parser
7379
if: steps.filter.outputs.parsing_required == 'true'
74-
run: python workflow.py --stage parser_and_mv
80+
run: uv run python workflow.py --stage parser_and_mv
7581

7682
- name: Run test_case_generator
7783
working-directory: ./csv_parser
7884
if: steps.filter.outputs.test_case_parsing_required == 'true'
7985
run: |
8086
rm -r ./out/test-cases || true
81-
python workflow.py --stage test_case_parser
87+
uv run python workflow.py --stage test_case_parser
8288
8389
- name: Collect schemas.yaml and copy it to json_schema2xsd
8490
working-directory: ./csv_parser

csv_parser/.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ out/**/*.schema.json
1818
out/**/*.openapi.yaml
1919

2020
# virtual env
21-
env/
21+
env/
22+
.venv/

csv_parser/.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.11

csv_parser/README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
# Installation
22
```bash
3-
pip install -r requirements.txt
3+
uv sync
44
```
5-
For the UML generator (run automatically within the CSV parser), in addition to the `requirements.txt`, you need to install graphviz on your execution environment https://graphviz.org/
5+
For the UML generator (run automatically within the CSV parser), in addition to the Python dependencies, you need to install graphviz on your execution environment https://graphviz.org/
66

77
# Usage
88
## CSV Parser
99
```bash
1010
# Params to specify the sheet and version
1111
# by default, integrate uml generation process
12-
python csv_parser.py -s RC-DE -v 0.5
13-
python csv_parser.py --sheet RC-DE --version 0.5
12+
uv run python csv_parser.py -s RC-DE -v 0.5
13+
uv run python csv_parser.py --sheet RC-DE --version 0.5
1414
# Defaults to RC-EDA and today (YY.MM.DD)
15-
python csv_parser.py
15+
uv run python csv_parser.py
1616
```
1717

1818
## Full pipeline
@@ -28,8 +28,8 @@ act -s GITHUB_TOKEN="$(gh auth token)"
2828
UML generator is called by default in the `csv_parser.py` but you may want to run it directly.
2929
```bash
3030
# Params to specify model and version
31-
python uml_generator.py -m RC-EDA -o cisu -v 1.12
32-
python uml_generator.py --model RC-EDA --obj cisu --version 1.12
31+
uv run python uml_generator.py -m RC-EDA -o cisu -v 1.12
32+
uv run python uml_generator.py --model RC-EDA --obj cisu --version 1.12
3333
```
3434

3535
# Automatic nomenclature & model push

csv_parser/auto.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ TECHNICAL_MODELS_FILE="models/model-technical.xlsx"
1111
TRACKING_BRANCH_NAME="auto/model_tracker"
1212
DATE=$(date +'%y.%m.%d %H:%M')
1313
LOG_FILE="cron.log"
14-
PYTHON_CMD="/Users/romainfouilland/code/envs/all/bin/python"
14+
PYTHON_CMD="uv run python"
1515

1616
# Enable printing of each command
1717
set -x
@@ -33,7 +33,7 @@ update_nomenclatures() {
3333
else
3434
echo "Changes detected in $NOMENCLATURE_FOLDER, running nomenclatures generation..."
3535
cd ../nomenclature_parser
36-
${PYTHON_CMD[@]} nomenclature_parser.py || (git stash && exit 1)
36+
${PYTHON_CMD} nomenclature_parser.py || (git stash && exit 1)
3737
git add .
3838
fi
3939
}
@@ -44,7 +44,7 @@ update_test_cases() {
4444
echo "No changes in $TEST_CASE_SOURCES_FOLDER, skipping test cases generation..."
4545
else
4646
echo "Changes detected in $TEST_CASE_SOURCES_FOLDER, running test cases generation..."
47-
${PYTHON_CMD[@]} workflow.py --stage test_case_parser || (git stash && exit 1)
47+
${PYTHON_CMD} workflow.py --stage test_case_parser || (git stash && exit 1)
4848
git add .
4949
fi
5050
}

csv_parser/pyproject.toml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[project]
2+
name = "csv-parser"
3+
version = "0.1.0"
4+
description = "CSV Parser service for SAMU-Hub-Modeles"
5+
readme = "README.md"
6+
requires-python = ">=3.9"
7+
dependencies = [
8+
"pandas>=2.0.0",
9+
"openpyxl>=3.0.0",
10+
"pyyaml>=6.0.2",
11+
"jsonpath-ng>=1.7.0",
12+
"python-docx>=1.0.0",
13+
"argparse>=1.4.0",
14+
"graphviz>=0.20.0",
15+
]
16+
17+
[tool.pytest.ini_options]
18+
testpaths = ["tests"]
19+
python_files = ["test_*.py"]
20+
python_classes = ["Test*"]
21+
python_functions = ["test_*"]
22+
addopts = "-v"
23+
24+
[build-system]
25+
requires = ["hatchling"]
26+
build-backend = "hatchling.build"

csv_parser/requirements.txt

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)