Spaces:
Running on Zero
Running on Zero
Self-contained startup and first-party private HF recovery
Browse files- RELEASE_MANIFEST.json +3 -3
- client.js +16 -4
- index.html +2 -0
- server.py +7 -2
RELEASE_MANIFEST.json
CHANGED
|
@@ -10,11 +10,11 @@
|
|
| 10 |
"assets/formula_template.json": "80f745df82bb7be45af52785fd582460bcddc63c5a4e1d8375d85b3122db4c6b",
|
| 11 |
"bin/altd-sim": "2f2f2144ae14b0ef599ca8510f95712da00243c6875881491d384b394e7499f7",
|
| 12 |
"bin/extract_saved_track": "3a7733c45b4301a786fcbfe92660a1c484749272da5f608d62f34878bd4ff31a",
|
| 13 |
-
"client.js": "
|
| 14 |
"delivery.py": "4f5a4e45df92e5cbfdef6eb449ede9ba26217fe24da376fafddae5cbbb73847a",
|
| 15 |
-
"index.html": "
|
| 16 |
"requirements.txt": "dbdedd8a6f30e16dc41bc3e210c1a936f679655420075f8f89bdd40bdd03f91b",
|
| 17 |
-
"server.py": "
|
| 18 |
"worker.py": "3370c812e1a48b7b7f09deaca769bb1a5c7ec30ca776dc97e484181e6bcec7c3"
|
| 19 |
},
|
| 20 |
"hosted_verified": false,
|
|
|
|
| 10 |
"assets/formula_template.json": "80f745df82bb7be45af52785fd582460bcddc63c5a4e1d8375d85b3122db4c6b",
|
| 11 |
"bin/altd-sim": "2f2f2144ae14b0ef599ca8510f95712da00243c6875881491d384b394e7499f7",
|
| 12 |
"bin/extract_saved_track": "3a7733c45b4301a786fcbfe92660a1c484749272da5f608d62f34878bd4ff31a",
|
| 13 |
+
"client.js": "b2a1c68bf50aae0acfeccb7ee0947e9aceb0d90c5c92d241f8b42fbdaec445f9",
|
| 14 |
"delivery.py": "4f5a4e45df92e5cbfdef6eb449ede9ba26217fe24da376fafddae5cbbb73847a",
|
| 15 |
+
"index.html": "caeafcd208a638cd8c4235ca282b5b6451b81eb0e363fcfbb2ee02ed021a4db0",
|
| 16 |
"requirements.txt": "dbdedd8a6f30e16dc41bc3e210c1a936f679655420075f8f89bdd40bdd03f91b",
|
| 17 |
+
"server.py": "6375fb9f0a6ed39be0d7ce3cbe5c4c820e412e91417f424ad10a1b5f6f94062f",
|
| 18 |
"worker.py": "3370c812e1a48b7b7f09deaca769bb1a5c7ec30ca776dc97e484181e6bcec7c3"
|
| 19 |
},
|
| 20 |
"hosted_verified": false,
|
client.js
CHANGED
|
@@ -101,11 +101,23 @@ setInterval(()=>{
|
|
| 101 |
if(!remaining && !busy){job=null; buttons(); say('Result access has expired. Server cleanup runs independently of this browser.');}
|
| 102 |
},1000);
|
| 103 |
buttons();
|
| 104 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
try {
|
| 106 |
-
const capabilities=await (await request('/api/capabilities')).json();
|
|
|
|
| 107 |
$('gpuOption').disabled=!capabilities.gpu;
|
| 108 |
$('backendNote').textContent=capabilities.gpu?'CPU uses no GPU allowance. GPU requires available allowance. No automatic switching.':'CPU available. GPU is not connected on this deployment; no GPU allowance is needed for CPU.';
|
| 109 |
capabilitiesReady=true; buttons();
|
| 110 |
-
|
| 111 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
if(!remaining && !busy){job=null; buttons(); say('Result access has expired. Server cleanup runs independently of this browser.');}
|
| 102 |
},1000);
|
| 103 |
buttons();
|
| 104 |
+
async function connect(){
|
| 105 |
+
$('retry').disabled=true;
|
| 106 |
+
$('backendNote').textContent='Checking available backends…';
|
| 107 |
+
const controller=new AbortController();
|
| 108 |
+
const timeout=setTimeout(()=>controller.abort(),10000);
|
| 109 |
try {
|
| 110 |
+
const capabilities=await (await request('/api/capabilities',{signal:controller.signal})).json();
|
| 111 |
+
if(capabilities.cpu!==true)throw new Error('CPU unavailable');
|
| 112 |
$('gpuOption').disabled=!capabilities.gpu;
|
| 113 |
$('backendNote').textContent=capabilities.gpu?'CPU uses no GPU allowance. GPU requires available allowance. No automatic switching.':'CPU available. GPU is not connected on this deployment; no GPU allowance is needed for CPU.';
|
| 114 |
capabilitiesReady=true; buttons();
|
| 115 |
+
say('Connected. Choose your track and network, then run the test.');
|
| 116 |
+
} catch(error) {
|
| 117 |
+
capabilitiesReady=false; buttons();
|
| 118 |
+
$('backendNote').textContent='Connection unavailable — training is disabled.';
|
| 119 |
+
say('Private HF access may be blocked inside the embedded page. Use “Open app in its own tab” above, or retry. No run was started.');
|
| 120 |
+
} finally {clearTimeout(timeout);$('retry').disabled=false;}
|
| 121 |
+
}
|
| 122 |
+
$('retry').onclick=()=>{if(!busy&&!job)connect();};
|
| 123 |
+
connect();
|
index.html
CHANGED
|
@@ -7,8 +7,10 @@
|
|
| 7 |
<p>Game by ActivationFunction · <a href="https://store.steampowered.com/app/3312030/AI_Learns_To_Drive/">Steam store</a></p>
|
| 8 |
<p>Simulator by <a href="https://github.com/Zorro909/driving_sim_rs">Zorro909</a> · UI and HF implementation by <a href="https://github.com/seeker-cyber-maker/driving_sim_rs">TiGa (seeker-cyber-maker)</a></p>
|
| 9 |
<p class="hint">Private release integration · bounded training test. No app account needed; private hosting may require access.</p>
|
|
|
|
| 10 |
<div class="grid"><section class="card"><h2>Simulation</h2><p>4 vehicles · 1 generation · 60 requested ticks. Formula networks, steering and acceleration; speed and raycast sensors. This is not yet the full trainer.</p>
|
| 11 |
<p><label for="backend">Compute</label><select id="backend" disabled><option value="cpu">CPU — no GPU allowance</option><option id="gpuOption" value="gpu" disabled>GPU — uses GPU allowance</option></select></p><p id="backendNote" class="hint">Checking available backends…</p>
|
|
|
|
| 12 |
<p><label>Track (.track) <input id="track" type="file" accept=".track"></label></p>
|
| 13 |
<p><label>Formula network (.evolution) <input id="network" type="file" accept=".evolution"></label></p>
|
| 14 |
<p><label><input id="automatic" type="checkbox" checked> Automatically delete server-side job data after receiving the result</label></p>
|
|
|
|
| 7 |
<p>Game by ActivationFunction · <a href="https://store.steampowered.com/app/3312030/AI_Learns_To_Drive/">Steam store</a></p>
|
| 8 |
<p>Simulator by <a href="https://github.com/Zorro909/driving_sim_rs">Zorro909</a> · UI and HF implementation by <a href="https://github.com/seeker-cyber-maker/driving_sim_rs">TiGa (seeker-cyber-maker)</a></p>
|
| 9 |
<p class="hint">Private release integration · bounded training test. No app account needed; private hosting may require access.</p>
|
| 10 |
+
<p><a id="standalone" href="" target="_blank" rel="noopener noreferrer">Open app in its own tab — recommended for private HF access</a><br><small>Uses this page’s existing HF access link. No privacy-setting changes needed. Select files again in the new tab; do not share private access links.</small></p>
|
| 11 |
<div class="grid"><section class="card"><h2>Simulation</h2><p>4 vehicles · 1 generation · 60 requested ticks. Formula networks, steering and acceleration; speed and raycast sensors. This is not yet the full trainer.</p>
|
| 12 |
<p><label for="backend">Compute</label><select id="backend" disabled><option value="cpu">CPU — no GPU allowance</option><option id="gpuOption" value="gpu" disabled>GPU — uses GPU allowance</option></select></p><p id="backendNote" class="hint">Checking available backends…</p>
|
| 13 |
+
<button id="retry" type="button">Retry connection</button>
|
| 14 |
<p><label>Track (.track) <input id="track" type="file" accept=".track"></label></p>
|
| 15 |
<p><label>Formula network (.evolution) <input id="network" type="file" accept=".evolution"></label></p>
|
| 16 |
<p><label><input id="automatic" type="checkbox" checked> Automatically delete server-side job data after receiving the result</label></p>
|
server.py
CHANGED
|
@@ -4,7 +4,7 @@ import json
|
|
| 4 |
from pathlib import Path
|
| 5 |
import threading
|
| 6 |
from fastapi import HTTPException, Request
|
| 7 |
-
from fastapi.responses import FileResponse, Response
|
| 8 |
from starlette.concurrency import run_in_threadpool
|
| 9 |
from delivery import create_api, CapacityExceeded
|
| 10 |
from worker import run_reported
|
|
@@ -18,7 +18,12 @@ def create_app(worker=run_reported,store=None,gpu_worker=None):
|
|
| 18 |
def capabilities():
|
| 19 |
return {'cpu':True,'gpu':gpu_worker is not None,'default':'cpu'}
|
| 20 |
@app.get('/')
|
| 21 |
-
def index():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 22 |
@app.get('/client.js')
|
| 23 |
def script(): return FileResponse(ROOT/'client.js',media_type='text/javascript')
|
| 24 |
@app.get('/policy')
|
|
|
|
| 4 |
from pathlib import Path
|
| 5 |
import threading
|
| 6 |
from fastapi import HTTPException, Request
|
| 7 |
+
from fastapi.responses import FileResponse, Response, HTMLResponse
|
| 8 |
from starlette.concurrency import run_in_threadpool
|
| 9 |
from delivery import create_api, CapacityExceeded
|
| 10 |
from worker import run_reported
|
|
|
|
| 18 |
def capabilities():
|
| 19 |
return {'cpu':True,'gpu':gpu_worker is not None,'default':'cpu'}
|
| 20 |
@app.get('/')
|
| 21 |
+
def index():
|
| 22 |
+
# Deliver the bootstrap with the authenticated document: private HF
|
| 23 |
+
# iframe subresource access can fail before an external script runs.
|
| 24 |
+
script=(ROOT/'client.js').read_text().replace('</script','<\\/script')
|
| 25 |
+
return HTMLResponse((ROOT/'index.html').read_text().replace(
|
| 26 |
+
'<script src="/client.js"></script>','<script>'+script+'</script>'))
|
| 27 |
@app.get('/client.js')
|
| 28 |
def script(): return FileResponse(ROOT/'client.js',media_type='text/javascript')
|
| 29 |
@app.get('/policy')
|