Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added tasks/report_bundle.zip
Binary file not shown.
13 changes: 13 additions & 0 deletions tasks/report_bundle/README.txt
Copy link
Author

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!

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
6 changes: 6 additions & 0 deletions tasks/report_bundle/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"model": "stable-diffusion",
"seed": 42,
"steps": 30,
"sampler": "Euler"
}
56 changes: 56 additions & 0 deletions tasks/report_bundle/generate_report.py
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!")
Binary file added tasks/report_bundle/grids/grid1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added tasks/report_bundle/grids/grid2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions tasks/report_bundle/results.csv
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
14 changes: 14 additions & 0 deletions tasks/report_bundle/test_schema.py
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (code-quality): Use named expression to simplify assignment and conditional (use-named-expression)

Suggested change
missing = required_columns - headers
if missing:
if missing := required_columns - headers:

raise ValueError(f"CSV is missing required columns: {missing}")
Comment on lines +9 to +10
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue (code-quality): Avoid conditionals in tests. (no-conditionals-in-tests)

ExplanationAvoid complex code, like conditionals, in test functions.

Google's software engineering guidelines says:
"Clear tests are trivially correct upon inspection"
To reach that avoid complex code in tests:

  • loops
  • conditionals

Some ways to fix this:

  • Use parametrized tests to get rid of the loop.
  • Move the complex logic into helpers.
  • Move the complex part into pytest fixtures.

Complexity is most often introduced in the form of logic. Logic is defined via the imperative parts of programming languages such as operators, loops, and conditionals. When a piece of code contains logic, you need to do a bit of mental computation to determine its result instead of just reading it off of the screen. It doesn't take much logic to make a test more difficult to reason about.

Software Engineering at Google / Don't Put Logic in Tests

print("✅ CSV schema test passed!")

if __name__ == "__main__":
test_csv_schema('results.csv')