AzizMiladi commited on
Commit
bbc5f0a
Β·
1 Parent(s): 01211a2

chore: scaffold src/guichetoi package, pyproject.toml, CI, PR/issue templates

Browse files

- pyproject.toml: installable package with src/ layout, dev/ui extras
- src/guichetoi/__init__.py + src/guichetoi/api/__init__.py: namespace
- .github/workflows/ci.yml: ruff + mypy + pytest on PR and push to main
- .github/PULL_REQUEST_TEMPLATE.md: focused PR template with test plan
- .github/ISSUE_TEMPLATE/{bug_report,feature_request}.md
- CONTRIBUTING.md: layout, setup, branch strategy, sensitive-data rules

No file moves yet β€” that comes in the next two commits to keep blame
history easy to follow.

.github/ISSUE_TEMPLATE/bug_report.md ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Bug report
3
+ about: Something is broken or behaves incorrectly
4
+ title: "[bug] "
5
+ labels: bug
6
+ ---
7
+
8
+ ## What happened
9
+
10
+ <!-- One short paragraph. -->
11
+
12
+ ## How to reproduce
13
+
14
+ ```
15
+ # minimal commands / inputs
16
+ ```
17
+
18
+ ## Expected vs actual
19
+
20
+ - Expected:
21
+ - Actual:
22
+
23
+ ## Environment
24
+
25
+ - OS:
26
+ - Python version:
27
+ - Branch / commit:
28
+ - Running via: [ ] CLI [ ] Streamlit demo [ ] FastAPI [ ] Docker
29
+
30
+ ## Logs / traceback
31
+
32
+ <details>
33
+ <summary>traceback</summary>
34
+
35
+ ```
36
+ paste here
37
+ ```
38
+
39
+ </details>
.github/ISSUE_TEMPLATE/feature_request.md ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ name: Feature request
3
+ about: Propose a new capability or improvement
4
+ title: "[feat] "
5
+ labels: enhancement
6
+ ---
7
+
8
+ ## Problem
9
+
10
+ <!-- What user need or workflow gap motivates this? -->
11
+
12
+ ## Proposed solution
13
+
14
+ <!-- One paragraph. -->
15
+
16
+ ## Alternatives considered
17
+
18
+ <!-- Optional. -->
19
+
20
+ ## Impact
21
+
22
+ - Who benefits:
23
+ - What changes for existing users:
.github/PULL_REQUEST_TEMPLATE.md ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!-- Keep PRs focused: one logical change per PR. Branch off `main`. -->
2
+
3
+ ## Summary
4
+
5
+ <!-- 1-3 sentences. What does this PR do and why. -->
6
+
7
+ ## Changes
8
+
9
+ <!-- Bullet list of the key changes. File paths welcome. -->
10
+ -
11
+
12
+ ## Test plan
13
+
14
+ <!-- How did you verify it works? Tick what applies. -->
15
+ - [ ] `pytest -q` passes locally
16
+ - [ ] Streamlit demo still loads (`make demo`)
17
+ - [ ] FastAPI service starts and `/health` returns `pipeline_loaded: true`
18
+ - [ ] Docker image builds (`docker build -t guichetoi-ml .`)
19
+ - [ ] No new files contain customer PII
20
+
21
+ ## Risk
22
+
23
+ <!-- Anything reviewers should look at extra carefully? -->
24
+ -
.github/workflows/ci.yml ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: CI
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ push:
7
+ branches: [main]
8
+
9
+ # Cancel an in-flight run on the same branch when a newer push lands
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref }}
12
+ cancel-in-progress: true
13
+
14
+ jobs:
15
+ lint:
16
+ name: Lint (ruff + mypy)
17
+ runs-on: ubuntu-latest
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+ - uses: actions/setup-python@v5
21
+ with:
22
+ python-version: '3.12'
23
+ cache: pip
24
+ - name: Install lint tools
25
+ run: |
26
+ python -m pip install --upgrade pip
27
+ pip install ruff mypy
28
+ - name: Ruff
29
+ run: ruff check src/ tests/
30
+ - name: Mypy (library only)
31
+ run: mypy --config-file mypy.ini src/guichetoi/cms.py src/guichetoi/recommendation.py
32
+
33
+ test:
34
+ name: Tests (pytest)
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: actions/setup-python@v5
39
+ with:
40
+ python-version: '3.12'
41
+ cache: pip
42
+ - name: System deps (tesseract-fra)
43
+ run: |
44
+ sudo apt-get update
45
+ sudo apt-get install -y --no-install-recommends \
46
+ tesseract-ocr tesseract-ocr-fra libgl1 libglib2.0-0
47
+ - name: Install package
48
+ # `-e .` installs the package; `requirements.txt` pins exact versions
49
+ run: |
50
+ python -m pip install --upgrade pip
51
+ pip install -e ".[dev]"
52
+ - name: Pytest
53
+ run: pytest -q
CONTRIBUTING.md ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Contributing
2
+
3
+ ## Repo layout
4
+
5
+ ```
6
+ src/guichetoi/ Library (importable as `guichetoi.…`)
7
+ inference.py LayoutLMv3 classifier + extractor pipeline
8
+ recommendation.py Rule engine that verdicts demande complΓ©tude
9
+ cms.py Pre-fill CMS IMMO 9 BANBOU xlsx from a Verdict
10
+ api/main.py FastAPI service wrapping all of the above
11
+
12
+ scripts/ Training pipeline + batch utilities (CLIs)
13
+ apps/ UI applications (Streamlit demo)
14
+ tools/ One-off dev / debug scripts
15
+ tests/ Pytest suite
16
+ assets/ Templates, logos, non-data static files
17
+ data/ label_mappings.json (other data dirs are gitignored)
18
+ docs/ Internal markdown docs
19
+ .github/ CI workflow + PR/issue templates
20
+ ```
21
+
22
+ ## Local setup
23
+
24
+ ```bash
25
+ python -m venv .venv
26
+ source .venv/bin/activate # or: .venv\Scripts\activate on Windows
27
+ pip install -e ".[dev,ui]"
28
+ pip install -r requirements.txt # exact pins (optional; for reproducibility)
29
+ ```
30
+
31
+ External requirement: **Tesseract OCR with the French language pack**
32
+ must be on `PATH` for inference to work.
33
+
34
+ ## Branch strategy
35
+
36
+ GitHub Flow:
37
+
38
+ - `main` is always deployable. Protected: requires PR + green CI to merge.
39
+ - One topic branch per work unit. Naming:
40
+ - `feature/<short-slug>` β€” new capability
41
+ - `fix/<short-slug>` β€” bug fix
42
+ - `chore/<short-slug>` β€” refactor, infra, deps
43
+ - `docs/<short-slug>` β€” docs only
44
+ - Squash-merge into `main`. Delete the branch after merge.
45
+
46
+ ## Workflow
47
+
48
+ ```bash
49
+ git checkout main && git pull
50
+ git checkout -b feature/my-thing
51
+ # … edits …
52
+ pytest -q # local sanity check
53
+ ruff check src/ tests/ # lint
54
+ mypy --config-file mypy.ini src/guichetoi/cms.py src/guichetoi/recommendation.py
55
+ git push -u origin feature/my-thing
56
+ gh pr create # or open via github.com
57
+ ```
58
+
59
+ CI runs lint + tests on every PR. Both must be green to merge.
60
+
61
+ ## What never goes in git
62
+
63
+ - Customer documents (`DataSet1/`, `DataSet2/`, `DataRef/`)
64
+ - Real extracted PII (`assets/sample_verdicts.json`)
65
+ - Model weights (`models/`)
66
+ - Label Studio raw exports (`project-*-at-*.json`)
67
+
68
+ `.gitignore` enforces these β€” when in doubt, check `git status` before
69
+ committing and never use `git add -f` to override an ignore rule.
pyproject.toml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ──────────────────────────────────────────────────────────────────────────
2
+ # GuichetOI ML β€” Python project metadata
3
+ # ──────────────────────────────────────────────────────────────────────────
4
+ # Install for development:
5
+ # pip install -e .[dev]
6
+ #
7
+ # Install runtime only:
8
+ # pip install -e .
9
+ # # then: pip install -r requirements.txt (for exact pins)
10
+ #
11
+ # `requirements.txt` remains the source of truth for fully-pinned versions
12
+ # used in CI and the Dockerfile. `pyproject.toml` declares loose runtime
13
+ # bounds so the library is `pip install`-friendly.
14
+ # ──────────────────────────────────────────────────────────────────────────
15
+
16
+ [build-system]
17
+ requires = ["setuptools>=68", "wheel"]
18
+ build-backend = "setuptools.build_meta"
19
+
20
+ [project]
21
+ name = "guichetoi"
22
+ version = "1.0.0"
23
+ description = "Inference + recommendation + CMS generation for Orange Guichet Accueil Infrastructures (demande de localisation PAR)."
24
+ readme = "README.md"
25
+ requires-python = ">=3.11"
26
+ license = { text = "MIT" }
27
+ authors = [{ name = "Aziz Mohamed Miladi", email = "medazizmiledi@ieee.org" }]
28
+ keywords = ["layoutlmv3", "document-ai", "ocr", "fiber", "orange"]
29
+ classifiers = [
30
+ "Programming Language :: Python :: 3",
31
+ "Programming Language :: Python :: 3.11",
32
+ "Programming Language :: Python :: 3.12",
33
+ "Operating System :: POSIX :: Linux",
34
+ "Operating System :: Microsoft :: Windows",
35
+ "License :: OSI Approved :: MIT License",
36
+ ]
37
+ dependencies = [
38
+ "torch>=2.0",
39
+ "transformers>=4.35",
40
+ "tokenizers>=0.20",
41
+ "safetensors>=0.4",
42
+ "pytesseract>=0.3.10",
43
+ "PyMuPDF>=1.24",
44
+ "pillow>=10.0",
45
+ "openpyxl>=3.1",
46
+ "fastapi>=0.110",
47
+ "uvicorn[standard]>=0.30",
48
+ "python-multipart>=0.0.9",
49
+ ]
50
+
51
+ [project.optional-dependencies]
52
+ dev = [
53
+ "pytest>=8.0",
54
+ "ruff>=0.6",
55
+ "mypy>=1.10",
56
+ ]
57
+ ui = ["streamlit>=1.30", "altair>=5.0"]
58
+
59
+ [project.urls]
60
+ Homepage = "https://github.com/MedAziz012/GuichetOI_ML"
61
+ Issues = "https://github.com/MedAziz012/GuichetOI_ML/issues"
62
+
63
+ # ──────────────────────────────────────────────────────────────────────────
64
+ # Packaging β€” src/ layout
65
+ # ──────────────────────────────────────────────────────────────────────────
66
+ [tool.setuptools.packages.find]
67
+ where = ["src"]
68
+
69
+ # ──────────────────────────────────────────────────────────────────────────
70
+ # Ruff β€” linting
71
+ # ──────────────────────────────────────────────────────────────────────────
72
+ [tool.ruff]
73
+ line-length = 100
74
+ target-version = "py311"
75
+ extend-exclude = ["scripts", "tools", "apps"] # legacy scripts, not lib code
76
+
77
+ [tool.ruff.lint]
78
+ select = ["E", "F", "I", "B", "UP"]
79
+ ignore = [
80
+ "E501", # line length β€” codebase has long French strings
81
+ "B008", # function-call-in-default-arg β€” used intentionally with FastAPI Depends/File
82
+ ]
src/guichetoi/__init__.py ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ """
2
+ GuichetOI β€” document AI for Orange's Guichet Accueil Infrastructures.
3
+
4
+ Sub-modules:
5
+ guichetoi.inference LayoutLMv3 classifier + extractor pipeline
6
+ guichetoi.recommendation Rule engine that verdicts demande complΓ©tude
7
+ guichetoi.cms Pre-fill CMS IMMO 9 BANBOU xlsx from a Verdict
8
+ guichetoi.api.main FastAPI service wrapping the above
9
+ """
10
+ __version__ = "1.0.0"
src/guichetoi/api/__init__.py ADDED
File without changes