Use content_hash as asset names when publishing runs
- Remove output_name from publish form and endpoint - Assets on L2 are now named by their content_hash - All inputs, recipe, and output referenced by content_hash - Simplified publish flow - no user input needed Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
19
server.py
19
server.py
@@ -1089,13 +1089,10 @@ async def run_detail(run_id: str, request: Request):
|
||||
publish_html = f'''
|
||||
<div class="border-t border-dark-500 pt-6 mt-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-3">Publish to L2</h2>
|
||||
<p class="text-sm text-gray-400 mb-4">Register this transformation output on the L2 ActivityPub server.</p>
|
||||
<p class="text-sm text-gray-400 mb-4">Register this run (inputs, recipe, output) on the L2 ActivityPub server. Assets are identified by their content hash.</p>
|
||||
<div id="publish-result"></div>
|
||||
<form hx-post="/ui/publish-run/{run.run_id}" hx-target="#publish-result" hx-swap="innerHTML"
|
||||
class="flex flex-wrap gap-3 items-center">
|
||||
<input type="text" name="output_name" value="{run.output_name}"
|
||||
placeholder="Asset name" required
|
||||
class="px-4 py-2 bg-dark-600 border border-dark-500 rounded-lg text-white placeholder-gray-500 focus:border-blue-500 focus:outline-none min-w-[200px]">
|
||||
<button type="submit"
|
||||
class="px-4 py-2 bg-blue-600 hover:bg-blue-700 text-white font-medium rounded-lg transition-colors">
|
||||
Publish to L2
|
||||
@@ -3855,8 +3852,8 @@ async def logout():
|
||||
|
||||
|
||||
@app.post("/ui/publish-run/{run_id}", response_class=HTMLResponse)
|
||||
async def ui_publish_run(run_id: str, request: Request, output_name: str = Form(...)):
|
||||
"""Publish a run to L2 from the web UI."""
|
||||
async def ui_publish_run(run_id: str, request: Request):
|
||||
"""Publish a run to L2 from the web UI. Assets are named by content_hash."""
|
||||
ctx = await get_user_context_from_cookie(request)
|
||||
if not ctx:
|
||||
return HTMLResponse('<div class="error">Not logged in</div>')
|
||||
@@ -3871,12 +3868,12 @@ async def ui_publish_run(run_id: str, request: Request, output_name: str = Form(
|
||||
return HTMLResponse('<div class="bg-red-900/50 border border-red-700 text-red-300 px-4 py-3 rounded-lg">Run not found</div>')
|
||||
|
||||
# Call L2 to publish the run, including this L1's public URL
|
||||
# Longer timeout because L2 calls back to L1 to fetch run details
|
||||
# Assets are named by their content_hash - no output_name needed
|
||||
l2_server = ctx.l2_server
|
||||
try:
|
||||
resp = http_requests.post(
|
||||
f"{l2_server}/assets/record-run",
|
||||
json={"run_id": run_id, "output_name": output_name, "l1_server": L1_PUBLIC_URL},
|
||||
json={"run_id": run_id, "l1_server": L1_PUBLIC_URL},
|
||||
headers={"Authorization": f"Bearer {token}"},
|
||||
timeout=30
|
||||
)
|
||||
@@ -3920,10 +3917,12 @@ async def ui_publish_run(run_id: str, request: Request, output_name: str = Form(
|
||||
|
||||
# Use HTTPS for L2 links
|
||||
l2_https = l2_server.replace("http://", "https://")
|
||||
asset_name = result["asset"]["name"]
|
||||
short_name = asset_name[:16] + "..." if len(asset_name) > 20 else asset_name
|
||||
return HTMLResponse(f'''
|
||||
<div class="bg-green-900/50 border border-green-700 text-green-300 px-4 py-3 rounded-lg mb-4">
|
||||
Published to L2 as <strong>{result["asset"]["name"]}</strong>!
|
||||
<a href="{l2_https}/asset/{result["asset"]["name"]}" target="_blank" class="underline">View on L2</a>
|
||||
Published to L2 as <strong>{short_name}</strong>!
|
||||
<a href="{l2_https}/assets/{asset_name}" target="_blank" class="underline">View on L2</a>
|
||||
</div>
|
||||
''')
|
||||
except http_requests.exceptions.HTTPError as e:
|
||||
|
||||
Reference in New Issue
Block a user