DecodeMarketing FloWeinert Claude Opus 4.7 (1M context) commited on
Commit
66b36bf
·
unverified ·
1 Parent(s): 93ccd43

Deploy: ruff cleanup tab1-tab4 (repo-wide green gate) (#23)

Browse files

* ci: add CODEOWNERS for restructure

* docs: add github-security-posture per decode-ai-standards

* Refresh CODEOWNERS + posture doc to match current branch-protection model (#6)

* Refresh .github/CODEOWNERS to match current branch-protection model

* Refresh docs/github-security-posture.md to match current branch-protection model

* [ai-standards][slice-2] structure and dependency reproducibility (#8)

* [ai-standards][slice-1] orientation and deploy boundary (#7)

Adds docs-only governance artifacts per the shrunken slice-1 plan
(post hardening commits 1878a50..c7599a7). No changes to app code,
requirements, devcontainer, .streamlit, existing workflows, existing
.claude/.githooks, or CLAUDE.md. README.md changes are additive only.

Artifacts:
- AGENTS.md (thin entrypoint -> CLAUDE.md + docs/INDEX.md)
- SECURITY.md (HF_TOKEN handling, deploy boundary)
- docs/ (INDEX, architecture, reference, guides, progress)
- .github/pull_request_template.md (deploy-boundary checklist)
- scripts/repo_validate.py (py_compile sweep + requirements parse)
- .github/workflows/repo_validate.yml (PR-only, parallel to gate.yml)
- README.md: additive Verification + Branch & Deploy + Architecture sections

Refs decode-ai-standards@81c3f17.

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [ai-standards][slice-2] structure and dependency reproducibility

Adds dependency reproducibility artifacts and policy/runbook documentation
per the shrunken slice-2 plan (workflow hardening deferred to a later slice
on user instruction to keep deploy risk at zero for this slice).

Artifacts:
- pyproject.toml (PEP 621 metadata; no [project.dependencies] to avoid
drift; requirements.txt remains the source of truth consumed by HF Spaces)
- requirements.lock (47 packages, autogenerated by
`uv pip compile --python-version=3.12 requirements.txt`)
- .python-version (3.12; matches runtime.txt and HF Spaces)
- .env.example (comment-only; declares no local env vars; documents
HF_TOKEN as a GitHub Actions secret consumed only by main.yml)
- docs/policies/naming-conventions.md (tab<N>.py rule, helper.py role,
what we explicitly do NOT do)
- docs/policies/root-artifact-policy.md (what is tracked at root, what is
gitignored, what is tolerated locally)
- docs/runbooks/local-setup.md (Windows / macOS / Linux setup walkthrough,
troubleshooting table)
- docs/INDEX.md (link the three new docs under new ## policies and
## runbooks sections; remove their entries from the "planned" stub)

Out of scope (deferred):
- Workflow SHA pinning + permissions blocks on main.yml, gate.yml,
check-file-size.yml — deferred to a later slice because main.yml is the
HF deploy pipeline and deserves its own focused PR + verification cycle
- .gitignore additions for .ruff_cache/, .venv/, .pytest_cache/ — deferred

No changes to app code (app.py, helper.py, tab1.py-tab8.py), requirements.txt,
runtime.txt, .streamlit/, .devcontainer/, existing workflows, existing
.githooks/, existing .claude/, CLAUDE.md, or .gitignore. HF Spaces deploy
is a no-op for this slice because no runtime file is touched.

Refs decode-ai-standards@81c3f17.

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* fix(tab5): carry lowercase sub-block letter into stim labels and reports

Block folders briefed as <NN><lowercase-letter><Category> (e.g. 05cColours)
encode a sub-block. The previous logic stripped every non-digit from the
folder name, dropping the letter, so stims were labelled 01B05whisper... instead
of 01B05cwhisper... A new parse_block() helper extracts the block number and the
optional single lowercase letter (uppercase = start of category name, so 05Colours
has no letter). Applied at every block-ID construction site used by the
'Name stims by block' tool (tab5) and the Asset Overview PDF (tab4).

tab6 (Rerun Matrix): rebuild the brand index from the Excel 'factor' column and
the leading brand number instead of regex-parsing the brand out of the ID, since
the optional sub-block letter makes ID-based brand parsing ambiguous.

tab5 instructions updated to document the lowercase-letter naming convention.

* fix(app): swap Resize / Place on Canvas tab handlers to match labels

The 'Resize' tab (tab7) was calling center_on_canvas_tool() and the
'Place on Canvas' tab (tab8) was calling resize_with_transparent_canvas_tool().
Swap the two calls so each tab runs the tool its label names, matching the
documented tool order (7 = Resize, 8 = Place on Canvas).

* chore: fix ruff lint errors in app/helper/tab5/tab6 (green language-gate)

Resolve the ruff findings the DECODE language-gate flags on these files:
remove unused imports and locals, replace bare 'except:' with 'except Exception:',
drop unused 'as e' bindings, and remove f-prefixes from placeholder-less strings.
No behavior change; verified with py_compile and an end-to-end process_files run.

* chore: fix ruff lint errors in tab1-tab4 (repo-wide green language-gate)

Remove unused imports (A4, getSampleStyleSheet, tempfile, get_files_by_marke),
remove unused locals (dateien_pro_marke, total_files), replace bare except with
except Exception, and drop an f-prefix from a placeholder-less string. The unused
'Overwrite original files' checkbox keeps rendering; only its dead binding is dropped.
No behavior change; verified with ruff, py_compile, and import of all modules.

---------

Co-authored-by: FloWeinert <weinert@decodemarketing.com>
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Files changed (4) hide show
  1. tab1.py +2 -3
  2. tab2.py +0 -1
  3. tab3.py +2 -3
  4. tab4.py +2 -8
tab1.py CHANGED
@@ -5,7 +5,6 @@ import tempfile
5
  import zipfile
6
  from pathlib import Path
7
  import streamlit as st
8
- from reportlab.lib.pagesizes import A4
9
 
10
  from helper import get_excel_worksheets_simple, extract_images_from_xlsx_by_sheet
11
 
@@ -46,7 +45,7 @@ def excel_extractor_tool():
46
  all_options = ["All worksheets"] + available_sheets
47
 
48
  selected = st.multiselect(
49
- f"Choose sheets to extract images from:",
50
  all_options,
51
  default=["All worksheets"],
52
  help="Select specific sheets or 'All worksheets' to extract from all sheets",
@@ -69,7 +68,7 @@ def excel_extractor_tool():
69
  try:
70
  os.remove(temp_path)
71
  os.rmdir(temp_dir)
72
- except:
73
  pass
74
 
75
  if st.button("Extract Images", type="primary", key="extract_btn_fixed"):
 
5
  import zipfile
6
  from pathlib import Path
7
  import streamlit as st
 
8
 
9
  from helper import get_excel_worksheets_simple, extract_images_from_xlsx_by_sheet
10
 
 
45
  all_options = ["All worksheets"] + available_sheets
46
 
47
  selected = st.multiselect(
48
+ "Choose sheets to extract images from:",
49
  all_options,
50
  default=["All worksheets"],
51
  help="Select specific sheets or 'All worksheets' to extract from all sheets",
 
68
  try:
69
  os.remove(temp_path)
70
  os.rmdir(temp_dir)
71
+ except Exception:
72
  pass
73
 
74
  if st.button("Extract Images", type="primary", key="extract_btn_fixed"):
tab2.py CHANGED
@@ -1,7 +1,6 @@
1
  import io
2
  import os
3
  import shutil
4
- import tempfile
5
  import zipfile
6
  from pathlib import Path
7
  import pandas as pd
 
1
  import io
2
  import os
3
  import shutil
 
4
  import zipfile
5
  from pathlib import Path
6
  import pandas as pd
tab3.py CHANGED
@@ -7,8 +7,6 @@ import cv2
7
  import numpy as np
8
  import streamlit as st
9
  from PIL import Image as PILImage
10
- from reportlab.lib.pagesizes import A4
11
- from reportlab.lib.styles import getSampleStyleSheet
12
 
13
  from helper import ALLOWED_IMAGE_EXTENSIONS
14
 
@@ -21,7 +19,8 @@ def white_to_transparent_tool():
21
  with col1:
22
  crop_image = st.checkbox("Crop white background", value=False)
23
  with col2:
24
- overwrite = st.checkbox("Overwrite original files", value=False)
 
25
 
26
  # File upload
27
  uploaded_files = st.file_uploader(
 
7
  import numpy as np
8
  import streamlit as st
9
  from PIL import Image as PILImage
 
 
10
 
11
  from helper import ALLOWED_IMAGE_EXTENSIONS
12
 
 
19
  with col1:
20
  crop_image = st.checkbox("Crop white background", value=False)
21
  with col2:
22
+ # Widget retained for UI parity; its value is not currently consumed.
23
+ st.checkbox("Overwrite original files", value=False)
24
 
25
  # File upload
26
  uploaded_files = st.file_uploader(
tab4.py CHANGED
@@ -1,10 +1,8 @@
1
  import os
2
  import zipfile
3
  import streamlit as st
4
- from reportlab.lib.pagesizes import A4
5
- from reportlab.lib.styles import getSampleStyleSheet
6
 
7
- from helper import extract_zip_to_temp, erkenne_marken_aus_ordnern, generate_pdf_report, get_files_by_marke, analyze_files_by_filename, generate_two_section_pdf_report
8
 
9
  def pdf_generator_tool():
10
  st.header("Asset Overview​")
@@ -46,10 +44,7 @@ def pdf_generator_tool():
46
  return
47
 
48
  st.success(f"Found brands: {', '.join(marken)}")
49
-
50
- # Get file counts for processing
51
- dateien_pro_marke = get_files_by_marke(input_folder, marken)
52
-
53
  # Options
54
  erste_marke = st.selectbox(
55
  "Which brand should appear first in the overview?",
@@ -88,7 +83,6 @@ def pdf_generator_tool():
88
 
89
  # Show analysis preview
90
  with st.expander("Analysis Preview"):
91
- total_files = len(all_files)
92
  for folder, brands in renamed_files_by_folder_and_marke.items():
93
  st.write(f"**{folder}:**")
94
  for brand, files in brands.items():
 
1
  import os
2
  import zipfile
3
  import streamlit as st
 
 
4
 
5
+ from helper import extract_zip_to_temp, erkenne_marken_aus_ordnern, generate_pdf_report, analyze_files_by_filename, generate_two_section_pdf_report
6
 
7
  def pdf_generator_tool():
8
  st.header("Asset Overview​")
 
44
  return
45
 
46
  st.success(f"Found brands: {', '.join(marken)}")
47
+
 
 
 
48
  # Options
49
  erste_marke = st.selectbox(
50
  "Which brand should appear first in the overview?",
 
83
 
84
  # Show analysis preview
85
  with st.expander("Analysis Preview"):
 
86
  for folder, brands in renamed_files_by_folder_and_marke.items():
87
  st.write(f"**{folder}:**")
88
  for brand, files in brands.items():