- render_teasing_more_ae.py: Teasing More A-E for any tier - render_topless_az_aberx.py: Topless A-Z + ABERX (with A0 rename) Usage: python3 scripts/render_teasing_more_ae.py --tier Wealthy python3 scripts/render_topless_az_aberx.py --tier Wealthy --workers 25 Replaces per-tier copy/paste scripts with parameterized canonical versions.
This commit is contained in:
Executable
+228
@@ -0,0 +1,228 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Tier-independent Teasing More A-E renderer.
|
||||
Usage: python3 render_teasing_more_ae.py --tier Wealthy [--workers 25] [--output-base /path]
|
||||
"""
|
||||
import argparse, base64, json, subprocess, time, os, sys
|
||||
from pathlib import Path
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
import requests
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Render Teasing More A-E for a courtesan tier')
|
||||
parser.add_argument('--tier', required=True, help='Tier name (e.g., Wealthy, Comfortable)')
|
||||
parser.add_argument('--workers', type=int, default=25, help='Concurrent workers (default: 25)')
|
||||
parser.add_argument('--output-base', default='/home/rick/output/to-dnd-session-rclone/Grok-NPCs/Courtesans',
|
||||
help='Base output directory')
|
||||
parser.add_argument('--manifest-dir', default='/home/rick/.openclaw/workspace/memory/npc-run-manifests',
|
||||
help='Manifest directory for identity lookup')
|
||||
args = parser.parse_args()
|
||||
|
||||
tier_dir = Path(args.output_base) / args.tier
|
||||
ref_dir = tier_dir / 'Teasing'
|
||||
out_dir = tier_dir / 'Teasing More'
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Load identities from manifests
|
||||
identity_by_name = {}
|
||||
manifest_dir = Path(args.manifest_dir)
|
||||
for p in sorted([p for p in manifest_dir.glob('*.json') if 'payloads' not in p.name],
|
||||
key=lambda p: p.stat().st_mtime, reverse=True):
|
||||
try:
|
||||
data = json.load(p.open())
|
||||
except Exception:
|
||||
continue
|
||||
for npc in data.get('individuals', []):
|
||||
n = npc.get('name')
|
||||
if n not in identity_by_name:
|
||||
identity_by_name[n] = npc
|
||||
for pair in data.get('pairs', []):
|
||||
for npc in pair.get('npcs', []):
|
||||
n = npc.get('name')
|
||||
if n not in identity_by_name:
|
||||
identity_by_name[n] = npc
|
||||
for n, npc in data.get('npc_profiles', {}).items():
|
||||
if n not in identity_by_name:
|
||||
identity_by_name[n] = npc
|
||||
|
||||
# Get API key
|
||||
key = subprocess.check_output(['bash', '-lc', 'pass show x.ai/apikey | head -n1']).decode().strip()
|
||||
headers = {"Authorization": f"Bearer {key}", "Content-Type": "application/json"}
|
||||
|
||||
API_URL = "https://api.x.ai/v1/images/edits"
|
||||
|
||||
NEGATIVE_TEXT = "no text, no labels, no captions, no logos, no watermark, no signage, no letters, no symbols, no UI overlays"
|
||||
|
||||
anti_modern = (
|
||||
"Strict medieval Norse look: no bathrobes, no knit sweaters/cardigans, no modern trousers/pants, "
|
||||
"no lace-up modern boots, no tufted upholstery, no modern cushions/pillows, no folded towels, "
|
||||
"no modern plumbing/fixtures, no contemporary fabrics or cuts."
|
||||
)
|
||||
|
||||
pose_variants = {
|
||||
'A': 'standing relaxed, hands at sides',
|
||||
'B': 'seated on a cushioned bench, relaxed posture',
|
||||
'C': 'leaning lightly against a carved post',
|
||||
'D': 'walking slowly with a small step',
|
||||
'E': 'adjusting the neckline with one hand',
|
||||
}
|
||||
|
||||
def data_url(path: Path):
|
||||
return "data:image/jpeg;base64," + base64.b64encode(path.read_bytes()).decode()
|
||||
|
||||
def extract_eye(identity: str):
|
||||
for part in identity.split(';'):
|
||||
if 'eye' in part.lower():
|
||||
return part.strip()
|
||||
return None
|
||||
|
||||
def build_prompt_single(ref_name, tag, identity_map):
|
||||
# Extract name from filename
|
||||
name_part = ref_name.split('_Teasing')[0].replace('_Single_Courtesan_' + args.tier, '').replace('_', ' ')
|
||||
identity = identity_map.get(name_part.replace(' ', '_'), {}).get('identity', '')
|
||||
eye = extract_eye(identity) or 'eyes'
|
||||
pose = pose_variants[tag]
|
||||
|
||||
return f"""
|
||||
Single adult, character name reference: {name_part}.
|
||||
Identity: {identity}.
|
||||
Eye color: {eye}. Eye color must match the reference exactly.
|
||||
Use ONLY the provided reference image as the exact outfit source.
|
||||
Keep the same garment, colors, fabrics, patterns, and accessory placement; pattern placement must match the reference.
|
||||
Garments remain intact with no tears, rips, holes, fraying, or cuts.
|
||||
Teasing More stage (Topless-Framed): both shoulders bare; garment lowered to expose chest fully; nipples visible and unobstructed; garment still worn high framing the chest; no nudity below the waist.
|
||||
Pose: {pose}.
|
||||
Same setting as reference image, consistent architecture and lighting.
|
||||
Keep the same face/likeness as the reference; preserve facial marks exactly; no airbrushing.
|
||||
Smiling warmly with inviting expression and direct eye contact.
|
||||
Cinematic 16:9, photorealistic, warm intimate lighting.
|
||||
No facial scars or injuries.
|
||||
{anti_modern}
|
||||
{NEGATIVE_TEXT}
|
||||
""".strip()
|
||||
|
||||
def build_prompt_pair(ref_name, tag, identity_map):
|
||||
# Parse pair names from filename
|
||||
parts = ref_name.split('_')
|
||||
if ref_name.startswith('DoubleTwin'):
|
||||
name1 = f"{parts[1]} {parts[2]}"
|
||||
name2 = f"{parts[3]} {parts[4]}"
|
||||
twin_clause = "They are identical twins with the same face, same features, same marks."
|
||||
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
|
||||
id_clause = f"Identity for both: {id1}."
|
||||
elif ref_name.startswith('Double_'):
|
||||
name1 = f"{parts[1]} {parts[2]}"
|
||||
name2 = f"{parts[3]} {parts[4]}"
|
||||
twin_clause = "They have distinct faces and clearly different facial features."
|
||||
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
|
||||
id2 = identity_map.get(f"{parts[3]}_{parts[4]}", {}).get('identity', '')
|
||||
id_clause = f"Identity {name1}: {id1}. Identity {name2}: {id2}."
|
||||
elif ref_name.startswith('Triple'):
|
||||
name1 = f"{parts[1]} {parts[2]}"
|
||||
name2 = f"{parts[3]} {parts[4]}"
|
||||
name3 = f"{parts[5]} {parts[6]}"
|
||||
twin_clause = "They have distinct faces and clearly different facial features."
|
||||
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
|
||||
id2 = identity_map.get(f"{parts[3]}_{parts[4]}", {}).get('identity', '')
|
||||
id3 = identity_map.get(f"{parts[5]}_{parts[6]}", {}).get('identity', '')
|
||||
id_clause = f"Identity {name1}: {id1}. Identity {name2}: {id2}. Identity {name3}: {id3}."
|
||||
|
||||
pose = pose_variants[tag]
|
||||
|
||||
return f"""
|
||||
Multiple adult women, character name references: {name1}, {name2}{', ' + name3 if 'name3' in locals() else ''}.
|
||||
{twin_clause}
|
||||
{id_clause}
|
||||
Use ONLY the provided reference image as the exact outfit source.
|
||||
Keep the same garment, colors, fabrics, patterns, and accessory placement; pattern placement must match the reference.
|
||||
Garments remain intact with no tears, rips, holes, fraying, or cuts.
|
||||
Teasing More stage (Topless-Framed): both shoulders bare on each; garments lowered to expose chests fully; nipples visible and unobstructed with anatomically correct lateral placement; garments still worn high framing each chest; no nudity below the waist.
|
||||
Pose: {pose}.
|
||||
Same setting as reference image, consistent architecture and lighting.
|
||||
Keep the same face/likeness as the reference; preserve facial marks exactly; no airbrushing.
|
||||
Smiling warmly with inviting expression and direct eye contact.
|
||||
Cinematic 16:9, photorealistic, warm intimate lighting.
|
||||
No facial scars or injuries.
|
||||
{anti_modern}
|
||||
{NEGATIVE_TEXT}
|
||||
""".strip()
|
||||
|
||||
def render_job(ref_path, tag, runhex, identity_map):
|
||||
ref_name = ref_path.stem.replace('_Teasing__' + ref_path.stem.split('__')[-1], '')
|
||||
out_file = f"{ref_name}_TeasingMore_{tag}__{runhex}.jpg"
|
||||
out_path = out_dir / out_file
|
||||
|
||||
if out_path.exists():
|
||||
return {"status": "skip", "output": str(out_path)}
|
||||
|
||||
# Determine if single or pair/triple
|
||||
if any(ref_name.startswith(p) for p in ['Double', 'Triple']):
|
||||
prompt = build_prompt_pair(ref_name, tag, identity_map)
|
||||
else:
|
||||
prompt = build_prompt_single(ref_name, tag, identity_map)
|
||||
|
||||
payload = {
|
||||
"model": "grok-imagine-image",
|
||||
"prompt": prompt,
|
||||
"image": {"url": data_url(ref_path)},
|
||||
"aspect_ratio": "16:9",
|
||||
}
|
||||
|
||||
try:
|
||||
r = requests.post(API_URL, headers=headers, data=json.dumps(payload), timeout=90)
|
||||
if r.status_code == 200:
|
||||
url = r.json()["data"][0]["url"]
|
||||
subprocess.run(["curl", "-sS", "-L", url, "-o", str(out_path)], check=True, timeout=60)
|
||||
return {"status": "success", "output": str(out_path)}
|
||||
else:
|
||||
return {"status": "failed", "error": f"HTTP {r.status_code}: {r.text[:200]}"}
|
||||
except Exception as e:
|
||||
return {"status": "exception", "error": str(e)}
|
||||
|
||||
# Build job list
|
||||
runhex = os.urandom(4).hex()
|
||||
print(f"{'='*60}")
|
||||
print(f"{args.tier} Teasing More A-E (runhex={runhex})")
|
||||
print(f"{'='*60}\n")
|
||||
|
||||
teasing_refs = list(ref_dir.glob('*_Teasing__*.jpg'))
|
||||
teasing_more_exist = {f.stem.split('_TeasingMore')[0] for f in out_dir.glob('*_TeasingMore__*.jpg')}
|
||||
|
||||
jobs = []
|
||||
for ref in teasing_refs:
|
||||
ref_base = ref.stem.replace('_Teasing__' + ref.stem.split('__')[-1], '')
|
||||
if ref_base in teasing_more_exist:
|
||||
continue # Already have Teasing More
|
||||
for tag in ['A', 'B', 'C', 'D', 'E']:
|
||||
jobs.append((ref, tag, runhex, identity_by_name))
|
||||
|
||||
print(f"Total jobs: {len(jobs)}\n")
|
||||
|
||||
success = 0
|
||||
failed = 0
|
||||
skip = 0
|
||||
|
||||
with ThreadPoolExecutor(max_workers=args.workers) as ex:
|
||||
futures = {ex.submit(render_job, *j): j for j in jobs}
|
||||
for future in as_completed(futures):
|
||||
try:
|
||||
result = future.result()
|
||||
if result["status"] == "success":
|
||||
success += 1
|
||||
if success % 10 == 0:
|
||||
print(f"PROGRESS: ok={success} fail={failed} skip={skip}")
|
||||
elif result["status"] == "skip":
|
||||
skip += 1
|
||||
else:
|
||||
failed += 1
|
||||
if failed <= 5:
|
||||
print(f"FAIL: {result.get('error', '?')[:100]}")
|
||||
except Exception as e:
|
||||
failed += 1
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f"DONE: ok={success} fail={failed} skip={skip}")
|
||||
print(f"{'='*60}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Executable
+280
@@ -0,0 +1,280 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Tier-independent Topless A-Z + ABERX renderer.
|
||||
Usage: python3 render_topless_az_aberx.py --tier Wealthy [--workers 25]
|
||||
|
||||
Generates:
|
||||
- A-Z (24 letters, skip I/O)
|
||||
- Renames A→A0, B→B0, E→E0, R→R0, X→X0
|
||||
- Generates A1-A9, B1-B9, E1-E9, R1-R9, X1-X9
|
||||
Total: 69 images per NPC/scene
|
||||
"""
|
||||
import argparse, base64, json, subprocess, time, os, sys, re
|
||||
from pathlib import Path
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
import requests
|
||||
|
||||
# Pose mapping (A-Z skip I/O)
|
||||
LETTERS = ["A","B","C","D","E","F","G","H","J","K","L","M","N","P","Q","R","S","T","U","V","W","X","Y","Z"]
|
||||
POSE_LIST = [
|
||||
'standing relaxed, hands at sides', 'seated on a cushioned bench, relaxed posture',
|
||||
'leaning lightly against a carved post', 'walking slowly with a small step',
|
||||
'adjusting the neckline with one hand', 'standing with one hand resting on hip',
|
||||
'seated on a low stool, upright posture', 'leaning forward slightly with hands clasped',
|
||||
'standing and brushing hair back with one hand', 'seated on the edge of a cushioned seat',
|
||||
'standing with arms loosely crossed', 'seated on a bench, slight twist at waist',
|
||||
'leaning against a wall, one knee bent', 'standing with a slight contrapposto',
|
||||
'seated on a low step, hands resting on knees', 'standing with one arm raised to adjust hair',
|
||||
'walking slowly, garment swaying', 'standing, hands clasped behind back',
|
||||
'seated, one leg tucked slightly under', 'leaning on a beam with one shoulder',
|
||||
'standing in profile three-quarter, head turned to camera', 'seated on a stool, one hand on thigh',
|
||||
'standing, one hand lightly touching collarbone', 'leaning forward, hands on hips',
|
||||
]
|
||||
POSE_MAP = {LETTERS[i]: POSE_LIST[i] for i in range(len(LETTERS))}
|
||||
|
||||
# A-B method: garment dropped below shoulders
|
||||
# C-E method: no fabric above waist
|
||||
METHOD_AB = set(LETTERS[:10]) # A-K
|
||||
METHOD_CE = set(LETTERS[10:]) # L-Z
|
||||
|
||||
ABERX_LETTERS = ['A', 'B', 'E', 'R', 'X']
|
||||
|
||||
NEGATIVE_TEXT = "no text, no labels, no captions, no logos, no watermark, no signage, no letters, no symbols, no UI overlays"
|
||||
ANTI_MODERN = (
|
||||
"Strict medieval Norse look: no bathrobes, no knit sweaters/cardigans, no modern trousers/pants, "
|
||||
"no lace-up modern boots, no tufted upholstery, no modern cushions/pillows, no folded towels, "
|
||||
"no modern plumbing/fixtures, no contemporary fabrics or cuts."
|
||||
)
|
||||
|
||||
def data_url(path: Path):
|
||||
return "data:image/jpeg;base64," + base64.b64encode(path.read_bytes()).decode()
|
||||
|
||||
def extract_eye(identity: str):
|
||||
for part in identity.split(';'):
|
||||
if 'eye' in part.lower():
|
||||
return part.strip()
|
||||
return None
|
||||
|
||||
def build_prompt_single(ref_name, letter, identity_map, tier):
|
||||
name_part = ref_name.replace('_Dressed', '').replace(f'_Single_Courtesan_{tier}', '').replace('_', ' ')
|
||||
identity = identity_map.get(name_part.replace(' ', '_'), {}).get('identity', '')
|
||||
eye = extract_eye(identity) or 'eyes'
|
||||
pose = POSE_MAP[letter]
|
||||
|
||||
if letter in METHOD_AB:
|
||||
topless_clause = "garment dropped below shoulders; arms may still have fabric; chest fully bare"
|
||||
else:
|
||||
topless_clause = "no fabric above the waist or on arms/shoulders; upper body fully bare"
|
||||
|
||||
return f"""
|
||||
Single adult, character name reference: {name_part}.
|
||||
Identity: {identity}.
|
||||
Eye color: {eye}. Eye color must match the reference exactly.
|
||||
Use ONLY the provided reference image as the exact outfit source.
|
||||
Keep the same garment colors, fabrics, patterns below the waist.
|
||||
Garments remain intact with no tears, rips, holes, fraying, or cuts.
|
||||
Topless stage: {topless_clause}; nipples visible and unobstructed; same skirt/lower gown as reference; no nudity below the waist.
|
||||
Pose: {pose}.
|
||||
Same setting as reference image, consistent architecture and lighting.
|
||||
Keep the same face/likeness as the reference; preserve facial marks exactly; no airbrushing.
|
||||
Smiling warmly with inviting expression and direct eye contact.
|
||||
Cinematic 16:9, photorealistic, warm intimate lighting.
|
||||
No facial scars or injuries.
|
||||
{ANTI_MODERN}
|
||||
{NEGATIVE_TEXT}
|
||||
""".strip()
|
||||
|
||||
def build_prompt_pair(ref_name, letter, identity_map, tier):
|
||||
parts = ref_name.split('_')
|
||||
if ref_name.startswith('DoubleTwin'):
|
||||
name1, name2 = f"{parts[1]} {parts[2]}", f"{parts[3]} {parts[4]}"
|
||||
twin_clause = "identical twins"
|
||||
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
|
||||
id_clause = f"Identity for both: {id1}."
|
||||
elif ref_name.startswith('Double_'):
|
||||
name1, name2 = f"{parts[1]} {parts[2]}", f"{parts[3]} {parts[4]}"
|
||||
twin_clause = "distinct faces"
|
||||
id1 = identity_map.get(f"{parts[1]}_{parts[2]}", {}).get('identity', '')
|
||||
id2 = identity_map.get(f"{parts[3]}_{parts[4]}", {}).get('identity', '')
|
||||
id_clause = f"Identity {name1}: {id1}. Identity {name2}: {id2}."
|
||||
else: # Triple
|
||||
return "" # Simplified for now
|
||||
|
||||
pose = POSE_MAP[letter]
|
||||
|
||||
if letter in METHOD_AB:
|
||||
topless_clause = "garments dropped below shoulders on each; chests fully bare"
|
||||
else:
|
||||
topless_clause = "no fabric above the waist on either; upper bodies fully bare"
|
||||
|
||||
return f"""
|
||||
Two adult women ({twin_clause}), character name references: {name1}, {name2}.
|
||||
{id_clause}
|
||||
Use ONLY the provided reference image as the exact outfit source.
|
||||
Keep the same garment colors, fabrics, patterns below the waist.
|
||||
Garments remain intact with no tears, rips, holes, fraying, or cuts.
|
||||
Topless stage: {topless_clause}; exactly two nipples visible and unobstructed with anatomically correct lateral placement; same skirts/lower gowns as reference; no nudity below the waist.
|
||||
Pose: {pose}.
|
||||
Same setting as reference image, consistent architecture and lighting.
|
||||
Keep the same face/likeness as the reference; preserve facial marks exactly; no airbrushing.
|
||||
Smiling warmly with inviting expression and direct eye contact.
|
||||
Cinematic 16:9, photorealistic, warm intimate lighting.
|
||||
No facial scars or injuries.
|
||||
{ANTI_MODERN}
|
||||
{NEGATIVE_TEXT}
|
||||
""".strip()
|
||||
|
||||
def render_job(ref_path, letter, variant_num, runhex, identity_map, tier, out_dir, api_url, headers):
|
||||
ref_base = ref_path.stem.replace('_Dressed__' + ref_path.stem.split('__')[-1], '')
|
||||
|
||||
if variant_num == 0:
|
||||
out_file = f"{ref_base}_Topless_{letter}__{runhex}.jpg"
|
||||
else:
|
||||
out_file = f"{ref_base}_Topless_{letter}{variant_num}__{runhex}.jpg"
|
||||
|
||||
out_path = out_dir / out_file
|
||||
|
||||
if out_path.exists():
|
||||
return {"status": "skip"}
|
||||
|
||||
# Build prompt
|
||||
if any(ref_base.startswith(p) for p in ['Double', 'Triple']):
|
||||
prompt = build_prompt_pair(ref_base, letter, identity_map, tier)
|
||||
else:
|
||||
prompt = build_prompt_single(ref_base, letter, identity_map, tier)
|
||||
|
||||
if not prompt:
|
||||
return {"status": "skip"}
|
||||
|
||||
payload = {
|
||||
"model": "grok-imagine-image",
|
||||
"prompt": prompt,
|
||||
"image": {"url": data_url(ref_path)},
|
||||
"aspect_ratio": "16:9",
|
||||
}
|
||||
|
||||
try:
|
||||
r = requests.post(api_url, headers=headers, data=json.dumps(payload), timeout=90)
|
||||
if r.status_code == 200:
|
||||
url = r.json()["data"][0]["url"]
|
||||
subprocess.run(["curl", "-sS", "-L", url, "-o", str(out_path)], check=True, timeout=60)
|
||||
return {"status": "success", "file": out_file}
|
||||
else:
|
||||
return {"status": "failed", "error": f"HTTP {r.status_code}"}
|
||||
except Exception as e:
|
||||
return {"status": "exception", "error": str(e)}
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser(description='Render Topless A-Z + ABERX for a courtesan tier')
|
||||
parser.add_argument('--tier', required=True)
|
||||
parser.add_argument('--workers', type=int, default=25)
|
||||
parser.add_argument('--output-base', default='/home/rick/output/to-dnd-session-rclone/Grok-NPCs/Courtesans')
|
||||
args = parser.parse_args()
|
||||
|
||||
tier_dir = Path(args.output_base) / args.tier
|
||||
dressed_dir = tier_dir / 'Dressed'
|
||||
out_dir = tier_dir / 'Topless'
|
||||
out_dir.mkdir(parents=True, exist_ok=True)
|
||||
|
||||
# Load identities
|
||||
identity_map = {}
|
||||
manifest_dir = Path('/home/rick/.openclaw/workspace/memory/npc-run-manifests')
|
||||
for p in sorted([p for p in manifest_dir.glob('*.json') if 'payloads' not in p.name],
|
||||
key=lambda p: p.stat().st_mtime, reverse=True):
|
||||
try:
|
||||
data = json.load(p.open())
|
||||
for npc in data.get('individuals', []):
|
||||
n = npc.get('name')
|
||||
if n not in identity_map:
|
||||
identity_map[n] = npc
|
||||
for pair in data.get('pairs', []):
|
||||
for npc in pair.get('npcs', []):
|
||||
n = npc.get('name')
|
||||
if n not in identity_map:
|
||||
identity_map[n] = npc
|
||||
except Exception:
|
||||
continue
|
||||
|
||||
key = subprocess.check_output(['bash', '-lc', 'pass show x.ai/apikey | head -n1']).decode().strip()
|
||||
headers = {"Authorization": f"Bearer {key}", "Content-Type": "application/json"}
|
||||
api_url = "https://api.x.ai/v1/images/edits"
|
||||
|
||||
runhex = os.urandom(4).hex()
|
||||
print(f"{'='*60}")
|
||||
print(f"{args.tier} Topless A-Z + ABERX (runhex={runhex})")
|
||||
print(f"{'='*60}\n")
|
||||
|
||||
dressed_refs = list(dressed_dir.glob('*_Dressed__*.jpg'))
|
||||
|
||||
# Phase 1: A-Z (variant 0)
|
||||
jobs_az = []
|
||||
for ref in dressed_refs:
|
||||
for letter in LETTERS:
|
||||
jobs_az.append((ref, letter, 0, runhex, identity_map, args.tier, out_dir, api_url, headers))
|
||||
|
||||
print(f"Phase 1: A-Z ({len(jobs_az)} jobs)")
|
||||
|
||||
success, failed, skip = 0, 0, 0
|
||||
aberx_to_rename = []
|
||||
|
||||
with ThreadPoolExecutor(max_workers=args.workers) as ex:
|
||||
futures = {ex.submit(render_job, *j): j for j in jobs_az}
|
||||
for future in as_completed(futures):
|
||||
result = future.result()
|
||||
if result["status"] == "success":
|
||||
success += 1
|
||||
# Track ABERX for rename
|
||||
file = result["file"]
|
||||
for ltr in ABERX_LETTERS:
|
||||
if f"_Topless_{ltr}__" in file:
|
||||
aberx_to_rename.append((file, ltr))
|
||||
break
|
||||
if success % 100 == 0:
|
||||
print(f" Progress: {success}/{len(jobs_az)}")
|
||||
elif result["status"] == "skip":
|
||||
skip += 1
|
||||
else:
|
||||
failed += 1
|
||||
|
||||
print(f"Phase 1 done: ok={success} fail={failed} skip={skip}\n")
|
||||
|
||||
# Phase 2: Rename ABERX to A0/B0/E0/R0/X0
|
||||
print(f"Phase 2: Renaming {len(aberx_to_rename)} ABERX files to *0 format")
|
||||
for old_file, ltr in aberx_to_rename:
|
||||
old_path = out_dir / old_file
|
||||
new_file = old_file.replace(f"_Topless_{ltr}__", f"_Topless_{ltr}0__")
|
||||
new_path = out_dir / new_file
|
||||
if old_path.exists() and not new_path.exists():
|
||||
old_path.rename(new_path)
|
||||
print("✓ Renamed\n")
|
||||
|
||||
# Phase 3: ABERX 1-9
|
||||
jobs_aberx = []
|
||||
for ref in dressed_refs:
|
||||
for letter in ABERX_LETTERS:
|
||||
for num in range(1, 10):
|
||||
jobs_aberx.append((ref, letter, num, runhex, identity_map, args.tier, out_dir, api_url, headers))
|
||||
|
||||
print(f"Phase 3: ABERX 1-9 ({len(jobs_aberx)} jobs)")
|
||||
|
||||
success2, failed2, skip2 = 0, 0, 0
|
||||
|
||||
with ThreadPoolExecutor(max_workers=args.workers) as ex:
|
||||
futures = {ex.submit(render_job, *j): j for j in jobs_aberx}
|
||||
for future in as_completed(futures):
|
||||
result = future.result()
|
||||
if result["status"] == "success":
|
||||
success2 += 1
|
||||
if success2 % 100 == 0:
|
||||
print(f" Progress: {success2}/{len(jobs_aberx)}")
|
||||
elif result["status"] == "skip":
|
||||
skip2 += 1
|
||||
else:
|
||||
failed2 += 1
|
||||
|
||||
print(f"\n{'='*60}")
|
||||
print(f"DONE: Phase1 ok={success} Phase3 ok={success2} total_fail={failed+failed2}")
|
||||
print(f"{'='*60}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user