-
Notifications
You must be signed in to change notification settings - Fork 215
Task 5 Submission – report_bundle.zip by Lial Adam #73
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
e8b56b1
4fb8381
92d5c48
2138f72
76fc6c8
5d2a910
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Report Bundle | ||
|
|
||
| Hi! | ||
| This report includes everything you need to review the image generation results. | ||
|
|
||
| What’s inside: | ||
| - `results.csv` — a table with image scores and file paths | ||
| - `config.json` — the exact settings used during generation (models, prompts, etc.) | ||
| - Grid images — labeled previews of the outputs | ||
|
|
||
| Feel free to explore or reuse any part of it. Let me know if anything’s missing! | ||
|
|
||
| — Lial |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "model": "stable-diffusion", | ||
| "seed": 42, | ||
| "steps": 30, | ||
| "sampler": "Euler" | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| """ | ||
|
|
||
| This script (generate_report.py) generates a ZIP archive... | ||
|
|
||
| This script validates the presence and structure of required files (CSV, config, README), | ||
| checks for missing images listed in results.csv, and packages all content—including the | ||
| 'grids' folder—into a single ZIP file named report.zip. | ||
|
|
||
| Used for reporting and archiving results of image-based evaluations. | ||
| """ | ||
|
|
||
| import os | ||
| import csv | ||
| import zipfile | ||
|
|
||
| RESULTS_FILE = 'results.csv' | ||
| CONFIG_FILE = 'config.json' | ||
| GRIDS_DIR = 'grids' | ||
| README_FILE = 'README.txt' | ||
| OUTPUT_ZIP = 'report.zip' | ||
|
|
||
|
|
||
| required_files = [RESULTS_FILE, CONFIG_FILE, README_FILE] | ||
| for file in required_files: | ||
| if not os.path.exists(file): | ||
| raise FileNotFoundError(f"{file} not found!") | ||
|
|
||
| if not os.path.isdir(GRIDS_DIR): | ||
| raise FileNotFoundError("Grids directory not found!") | ||
|
|
||
|
|
||
| required_columns = {'id', 'image_path', 'score'} | ||
| with open(RESULTS_FILE, newline='') as csvfile: | ||
| reader = csv.DictReader(csvfile) | ||
| if not required_columns.issubset(reader.fieldnames): | ||
| raise ValueError(f"CSV missing required columns: {required_columns - set(reader.fieldnames)}") | ||
|
|
||
| for row in reader: | ||
| if not os.path.exists(row['image_path']): | ||
| raise FileNotFoundError(f"Image file not found: {row['image_path']}") | ||
|
|
||
| with zipfile.ZipFile(OUTPUT_ZIP, 'w', compression=zipfile.ZIP_DEFLATED) as zf: | ||
| zf.write(RESULTS_FILE) | ||
| zf.write(CONFIG_FILE) | ||
| zf.write(README_FILE) | ||
|
|
||
| for foldername, subfolders, filenames in os.walk(GRIDS_DIR): | ||
| for filename in filenames: | ||
| file_path = os.path.join(foldername, filename) | ||
| arcname = os.path.relpath(file_path, start='.') | ||
| zf.write(file_path, arcname=arcname) | ||
|
|
||
|
|
||
|
|
||
|
|
||
| print("✅ report.zip created successfully!") |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| id,image_path,score | ||
| 1,grids/grid1.png,0.95 | ||
| 2,grids/grid2.png,0.88 |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,14 @@ | ||||||||
| import csv | ||||||||
|
|
||||||||
| def test_csv_schema(filename): | ||||||||
| required_columns = {'id', 'image_path', 'score'} | ||||||||
| with open(filename, newline='') as csvfile: | ||||||||
| reader = csv.DictReader(csvfile) | ||||||||
| headers = set(reader.fieldnames) | ||||||||
| missing = required_columns - headers | ||||||||
| if missing: | ||||||||
|
Comment on lines
+8
to
+9
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (code-quality): Use named expression to simplify assignment and conditional (
Suggested change
|
||||||||
| raise ValueError(f"CSV is missing required columns: {missing}") | ||||||||
|
Comment on lines
+9
to
+10
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. issue (code-quality): Avoid conditionals in tests. ( ExplanationAvoid complex code, like conditionals, in test functions.Google's software engineering guidelines says:
Some ways to fix this:
Software Engineering at Google / Don't Put Logic in Tests |
||||||||
| print("✅ CSV schema test passed!") | ||||||||
|
|
||||||||
| if __name__ == "__main__": | ||||||||
| test_csv_schema('results.csv') | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All suggestions applied — ready for final review. Thanks!