fix: review of phase-2 stage 0 and fronts 5, 6 and 11
All checks were successful
Build and deploy / Publish images (push) Successful in 1m5s
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 5m7s
Build and deploy / Secret scan and release gate (push) Successful in 6s
All checks were successful
Build and deploy / Publish images (push) Successful in 1m5s
Build and deploy / Validate source (push) Successful in 5s
Build and deploy / Integration suite on a real stack (push) Successful in 5m7s
Build and deploy / Secret scan and release gate (push) Successful in 6s
- A paid treatment adds its 24 h to Arte recebida's acceptable time, on the card and in Números (fronts 5 and 11). - TINY_PRODUCT_TREATMENT is a required Tiny setting once the treatment has a price, instead of every treated order failing at the Tiny. - A quote reads each PDF once: Files caches the header and the DPI. - A proof made from the parent's final split into parts uses the part that holds the finest stroke, not the last one (0.1). - Prumo report: one format line per item, the time from the claim (kept on the finished print file), and the stroke class in customer words. - The Site says the Prumo checks the art, and a too-tall PNG no longer says "Este PDF". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -16,6 +16,7 @@ Sheets of several GB are the normal order: a PNG or a PDF is read band by
|
||||
band, so its size does not matter. Any other file above LARGE_SOURCE_BYTES
|
||||
is prepared by hand from the original.
|
||||
"""
|
||||
import io
|
||||
import logging
|
||||
import multiprocessing
|
||||
import os
|
||||
@@ -53,6 +54,36 @@ def generated_identity(order_id):
|
||||
return uuid5(NAMESPACE_URL, f'dtf-print-file:{order_id}')
|
||||
|
||||
|
||||
def proof_part(heights_cm, original_height_cm, fraction):
|
||||
"""Which part of a split final holds the finest stroke, and where inside it.
|
||||
|
||||
`heights_cm` are the parts' heights in order, `fraction` the stroke's
|
||||
position on the original film (0 at the top, 1 at the bottom). A single
|
||||
part returns the same fraction, as before.
|
||||
"""
|
||||
heights = [float(height) for height in heights_cm]
|
||||
if not heights:
|
||||
return 0, 0.0
|
||||
position = min(1.0, max(0.0, float(fraction or 0))) * float(original_height_cm)
|
||||
start = 0.0
|
||||
for index, height in enumerate(heights):
|
||||
end = start + height
|
||||
if position <= end or index == len(heights) - 1:
|
||||
inside = (position - start) / height if height > 0 else 0.0
|
||||
return index, min(1.0, max(0.0, inside))
|
||||
start = end
|
||||
return len(heights) - 1, 1.0
|
||||
|
||||
|
||||
def png_height_cm(storage, row):
|
||||
"""A PNG's height in cm at 300 DPI, from its header alone (a Range read)."""
|
||||
head = storage.client.get_object(Bucket=storage.bucket, Key=row['object_key'],
|
||||
Range='bytes=0-65535')['Body'].read()
|
||||
with Image.open(io.BytesIO(head)) as image:
|
||||
height_px = image.size[1]
|
||||
return float(Decimal(height_px) * Decimal('2.54') / Decimal(300))
|
||||
|
||||
|
||||
def queue(c, order_id, items, only_missing=False):
|
||||
"""Queue (or re-queue) generation for every item of an order."""
|
||||
for index in range(items):
|
||||
@@ -123,15 +154,26 @@ def render_one(storage):
|
||||
item = job['snapshot']['items'][job['item_index']]
|
||||
source_ids = [UUID(u) for u in item['uploads']]
|
||||
# A format such as CDR needs a human to prepare the full-size final on
|
||||
# the parent. The child still generates its own 15 cm proof from that PNG.
|
||||
# the parent. The child still generates its own 15 cm proof from that PNG,
|
||||
# or from the part of it that holds the finest stroke when the film was
|
||||
# cut into parts (item 13).
|
||||
if job['parent_id']:
|
||||
source = c.execute('''SELECT u.id FROM dtf_local.order_files f
|
||||
finals = c.execute('''SELECT u.id,u.object_key FROM dtf_local.order_files f
|
||||
JOIN dtf_local.uploads u ON u.id=f.upload_id
|
||||
LEFT JOIN dtf_local.print_parts p ON p.order_id=f.order_id
|
||||
AND p.item_index=f.item_index AND p.upload_id=f.upload_id
|
||||
WHERE f.order_id=%s AND f.item_index=%s AND f.kind='final' AND f.active
|
||||
AND u.purged_at IS NULL AND u.expires_at>now()
|
||||
ORDER BY f.created_at DESC LIMIT 1''',
|
||||
(job['parent_id'], item['proof_parent_item_index'])).fetchone()
|
||||
if source:
|
||||
ORDER BY p.part NULLS LAST, f.created_at''',
|
||||
(job['parent_id'], item['proof_parent_item_index'])).fetchall()
|
||||
if finals:
|
||||
source = finals[0]
|
||||
if len(finals) > 1:
|
||||
heights = [png_height_cm(storage, row) for row in finals]
|
||||
index, fraction = proof_part(heights, item['production']['height_cm'],
|
||||
item.get('proof_y_fraction'))
|
||||
source = finals[index]
|
||||
job['proof_fraction'] = fraction
|
||||
source_ids = [source['id']]
|
||||
item = {**item, 'uploads': [str(source['id'])]}
|
||||
job['proof_fallback'] = True
|
||||
@@ -194,8 +236,9 @@ def render_one(storage):
|
||||
expires_at,scan_state,scan_reason,scanned_at)
|
||||
VALUES(%s,%s,%s,%s,%s,'',true,%s,'clean','generated from scanned artwork',now())''',
|
||||
(uid, generated_identity(job['order_id']), name, size, key, expiry))
|
||||
# claimed_at stays: the Prumo report measures generation from the claim.
|
||||
c.execute('''UPDATE dtf_local.print_files SET status='ready', upload_id=%s, detail=%s,
|
||||
finished_at=now(),claim_token=NULL,claimed_at=NULL WHERE id=%s''', (stored[0][0], Jsonb(detail), job['id']))
|
||||
finished_at=now(),claim_token=NULL WHERE id=%s''', (stored[0][0], Jsonb(detail), job['id']))
|
||||
c.execute('DELETE FROM dtf_local.print_parts WHERE order_id=%s AND item_index=%s',
|
||||
(job['order_id'], job['item_index']))
|
||||
for number, (uid, _, _, _) in enumerate(stored, 1):
|
||||
@@ -274,11 +317,15 @@ def produce(storage, job, item, uploads):
|
||||
width_px, height_px = final.size
|
||||
width_cm = float(Decimal(width_px) * Decimal('2.54') / Decimal(300))
|
||||
height_cm = float(Decimal(height_px) * Decimal('2.54') / Decimal(300))
|
||||
original_height = float(item['production']['height_cm'])
|
||||
fraction = float(item.get('proof_y_fraction') or 0)
|
||||
if job.get('proof_fraction') is not None:
|
||||
# Already relative to the chosen part (proof_part).
|
||||
fraction = float(job['proof_fraction'])
|
||||
else:
|
||||
original_height = float(item['production']['height_cm'])
|
||||
fraction = min(1, float(item.get('proof_y_fraction') or 0) * original_height / height_cm)
|
||||
source = {'kind': 'sheet', 'width_cm': width_cm, 'length_cm': height_cm,
|
||||
'copies': 1, 'rotation_degrees': 0, 'mirrored': False, 'measurement': 'file'}
|
||||
item = {**item, 'proof_y_fraction': min(1, fraction * original_height / height_cm),
|
||||
item = {**item, 'proof_y_fraction': fraction,
|
||||
'production': {'version': 3, 'film_width_cm': width_cm,
|
||||
'height_cm': height_cm, 'sources': [source],
|
||||
'placements': [{'source_index': 0, 'copy_index': 0,
|
||||
|
||||
Reference in New Issue
Block a user