A newer version of the Streamlit SDK is available: 1.62.0
Deploy Log β HF Dev Space (Chen4700/drl-trading-bot-dev)
Date: 2026-03-19 Goal: Switch HF Space from Docker (full trading stack) to Streamlit SDK (client-only UI)
What Was Done
1. README.md frontmatter updated
Changed from Docker SDK to Streamlit SDK:
# Before
sdk: docker
app_port: 7860
# After
sdk: streamlit
sdk_version: 1.42.0
app_file: src/ui/app.py
2. Created requirements-hf.txt
New lightweight requirements file for HF UI-only deployment:
streamlit>=1.42.0streamlit-lightweight-charts>=0.1.0pandas,numpy,requests,plotlypython-dotenv,pymongo,dnspython,certifi
Why pymongo is needed: src/data/storage.py has a bare import pymongo at the top level (not guarded). The app falls back to JsonFileStorage if STORAGE_TYPE is not set to mongo, but the import must succeed.
3. Created hf-deploy branch
mainstays untouched (full requirements for local dev)hf-deploybranch replacesrequirements.txtwith lightweight HF version- Force-pushed
hf-deploy β mainonhuggingfaceremote
4. Build Result
- Build completed in ~21 seconds (pip install phase)
- All 11 lightweight deps installed cleanly
- No errors in build log
5. Runtime Result
- Stage: RUNNING
- SDK: streamlit (confirmed via HF API)
- Streamlit startup confirmed: "You can now view your Streamlit app in your browser."
API Tunnel Status
Tunnel URL: https://advertise-refined-doom-bicycle.trycloudflare.com
Test: curl -s .../api/ping
Result: {"ok":true,"timestamp":"2026-03-19T13:21:45.580803"} β
The HF Space needs API_SERVER_URL set to this tunnel URL as a HF Space variable.
Check: Go to the dev space Settings β Variables and verify API_SERVER_URL = https://advertise-refined-doom-bicycle.trycloudflare.com
Known Issues / Notes
Cloudflare Tunnel is ephemeral β The tunnel URL changes every time
cloudflared tunnelis restarted. When that happens, updateAPI_SERVER_URLin the HF Space variables.storage.py import β
import pymongois at module level insrc/data/storage.py. Must be in requirements. If the space should truly be API-only with no local storage, this import can be guarded later.LFS files β The HF space still contains model
.zip/.pklfiles (883 MB via Git LFS). These aren't needed for a client-only space. To save space, consider adding them to.gitattributesas not-LFS on the deploy branch, or using.hfignore.Production space β NOT touched. Only
Chen4700/drl-trading-bot-devwas modified.
Git State
- Branch
hf-deploypushed tohuggingfaceremote asmain(force push) origin(GitHub)mainbranch unchanged- Commit:
3857657β "Deploy: Switch HF Space to Streamlit SDK (client-only)"
Session 2 β 2026-03-19
Goal: Fix testnet /api/testnet/status hang + push to HF dev space
Fixes Applied
1. BinanceConnector timeout (src/api/binance.py)
- Added
'timeout': 10000(10s) to ccxt config β prevents indefinite hangs on slow/blocked proxy - Added
'fetchMarkets': Falseand'loadMarketsAlways': Falseβ disables ccxt's lazy market-loading which could block on testnet's limited exchange info
2. Load dotenv in API server (src/ui/api_server.py)
- Added
load_dotenv()at module startup β ensures.envvars (incl.BINANCE_TESTNET_PROXY_URL) are available for local dev
3. Testnet symbol whitelist (src/ui/api_server.py)
- Binance spot testnet only supports ~10 pairs (BTC, ETH, BNB, LTC, TRX, XRP, SOL, ADA, DOGE vs USDT)
- When iterating wallet balances, skip ticker fetch for currencies not in this whitelist
- Fixes "binance Invalid symbol" errors that accumulated and made the endpoint appear to hang
Build Result
- Build logs: CACHED (all deps unchanged, only app files copied) β completed in ~7s
- Streamlit confirmed running: "You can now view your Streamlit app in your browser."
- Commit:
75e6612
Verification Results
- HF Space stage: PAUSED β flagged as abusive by HF moderation (not a code issue)
- Space must be manually unpaused at huggingface.co/spaces/Chen4700/drl-trading-bot-dev
- Cloudflare tunnel: DOWN (error 1033) β
cloudflaredis not running locally- Restart tunnel:
cloudflared tunnel --url http://localhost:5001 - Update
API_SERVER_URLHF Space variable after restart
- Restart tunnel:
- Integration tests: 22/22 PASSED (71s) β all endpoints, testnet structure, app.py API migration verified
Git State
- Branch
hf-deploy(commit75e6612) force-pushed tohuggingfaceremote asmain origin(GitHub)mainbranch unchanged β fixes remain onhf-deployonly