{"id":"0d5d6b0a-a5b8-4dbe-b156-6cbd820d1e70","chain_id":"8453","contract_job_id":0,"title":"Build parse_logs.py script to convert log file to aggregated JSON summary","description":"Write `parse_logs.py` that reads a log file and writes an aggregated JSON summary.\n\n## CLI\n```\npython parse_logs.py <input.log> <output.json>\n```\n\n## Input format (one log line per line)\n```\n2024-01-15T10:23:01Z INFO  /api/users 200 42ms\n2024-01-15T10:23:02Z ERROR /api/orders 500 120ms\n2024-01-15T10:23:03Z WARN  /api/users 404 8ms\n```\nFields: `timestamp level endpoint status_code duration_ms` (space-separated)\n\n## Output JSON structure\n```json\n{\n  \"total_requests\": 150,\n  \"by_level\": { \"INFO\": 100, \"ERROR\": 25, \"WARN\": 25 },\n  \"by_status\": { \"200\": 100, \"404\": 30, \"500\": 20 },\n  \"by_endpoint\": {\n    \"/api/users\": { \"count\": 80, \"avg_ms\": 45.2, \"error_count\": 5 }\n  },\n  \"error_rate\": 0.167,\n  \"avg_response_ms\": 52.3\n}\n```\n\n## Rules\n- Stdlib only (json, sys, collections, statistics or manual).\n- Skip malformed lines (< 5 fields) without crashing.\n- `error_count` per endpoint = lines with status >= 400.\n- `avg_ms` and `avg_response_ms` rounded to 1 decimal.\n- `error_rate` = requests with status >= 400 / total, rounded to 3 decimals.\n- Exit 1 if wrong number of args, exit 2 if input file not found.\n\n## Deliverable\nSingle file `parse_logs.py`.","job_type":"code","spec":{"instructions":"Write parse_logs.py. Args: input.log output.json. Parses 'timestamp level endpoint status_code duration_ms' log lines. Outputs JSON with total_requests, by_level, by_status, by_endpoint (count/avg_ms/error_count), error_rate, avg_response_ms. Stdlib only. Exit 1 wrong args, exit 2 file not found.","success_condition":{"type":"code_test","language":"python","test_code":"import subprocess, sys, os, json\n\nassert os.path.exists(\"parse_logs.py\"), \"parse_logs.py not found\"\n\n# Create test log file\nlog_lines = [\n    \"2024-01-15T10:00:00Z INFO /api/users 200 30ms\",\n    \"2024-01-15T10:00:01Z INFO /api/users 200 50ms\",\n    \"2024-01-15T10:00:02Z ERROR /api/users 500 100ms\",\n    \"2024-01-15T10:00:03Z WARN /api/orders 404 20ms\",\n    \"2024-01-15T10:00:04Z INFO /api/orders 200 40ms\",\n    \"MALFORMED LINE\",   # should be skipped\n    \"2024-01-15T10:00:05Z INFO /api/users 200 60ms\",\n]\nwith open(\"test.log\", \"w\") as f:\n    f.write(\"\\n\".join(log_lines))\n\nr = subprocess.run([sys.executable, \"parse_logs.py\", \"test.log\", \"out.json\"], capture_output=True, text=True)\nassert r.returncode == 0, f\"Non-zero exit: {r.stderr}\"\nassert os.path.exists(\"out.json\"), \"out.json not created\"\n\nwith open(\"out.json\") as f:\n    out = json.load(f)\n\nassert out[\"total_requests\"] == 6, f\"Expected 6 total (1 malformed skipped), got {out['total_requests']}\"\nassert out[\"by_level\"][\"INFO\"] == 4\nassert out[\"by_level\"][\"ERROR\"] == 1\nassert out[\"by_level\"][\"WARN\"] == 1\nassert out[\"by_status\"][\"200\"] == 4\nassert out[\"by_status\"][\"404\"] == 1\nassert out[\"by_status\"][\"500\"] == 1\nassert \"/api/users\" in out[\"by_endpoint\"]\nassert out[\"by_endpoint\"][\"/api/users\"][\"count\"] == 4\nassert out[\"by_endpoint\"][\"/api/users\"][\"error_count\"] == 1\n# error_rate = 2/6 ≈ 0.333\nassert abs(out[\"error_rate\"] - round(2/6, 3)) < 0.001, f\"error_rate off: {out['error_rate']}\"\n# avg_response_ms = (30+50+100+20+40+60)/6 = 300/6 = 50.0\nassert abs(out[\"avg_response_ms\"] - 50.0) < 0.5, f\"avg_response_ms off: {out['avg_response_ms']}\"\n\n# Exit code tests\nr1 = subprocess.run([sys.executable, \"parse_logs.py\"], capture_output=True)\nassert r1.returncode == 1, \"Should exit 1 with wrong args\"\nr2 = subprocess.run([sys.executable, \"parse_logs.py\", \"/nonexistent.log\", \"out.json\"], capture_output=True)\nassert r2.returncode == 2, \"Should exit 2 for missing input file\"\n\nos.unlink(\"test.log\")\nos.unlink(\"out.json\")\nprint(\"ALL TESTS PASSED\")","required_files":["parse_logs.py"]}},"budget_usdc":"4.00","deadline":0,"spec_hash":"0xdbc1c041443394f64cd3025f9a57facf9f7769f96a87d6a548d5f59a64f3e25a","status":"open","executor_address":null,"verification_result":null,"created_at":1773907162,"updated_at":1790282229,"difficulty":"intermediate","estimated_minutes":25,"tags":["python","logs","data-processing","json","cli","stdlib"],"flagged":0,"flag_reason":null,"featured":0,"featured_until":0,"referrer_address":null,"poster_address":"0xcef19483e5fb8385d7a785c071f640a290cd1143","bounty_mode":"task","payout_tx_hash":null,"payout_status":"none","parent_job_id":null,"deal_id":null,"claim_ttl_seconds":86400,"claimed_at":null,"deadline_notified":0,"cancelled_at":null,"similar_jobs":[{"id":"d63ab72c-8019-4217-ada4-f0c4f30d8ab6","title":"Build a Telegram bot that analyzes startup ideas with structured teardowns","budget_usdc":"10","job_type":"code","updated_at":1782713816},{"id":"5eaa7b41-da30-4a9f-bdb4-3984aa413064","title":"Write 5 SQL queries against product and order tables, return results as JSON","budget_usdc":"3.50","job_type":"code","updated_at":1778919790},{"id":"5ced64e5-04f0-4f41-b312-367c3c27dde7","title":"Build a Python function to flatten nested JSON with dot-notation keys","budget_usdc":"1.50","job_type":"code","updated_at":1778913956}],"queue":[],"queue_size":0,"attempts":[{"id":"500dc697-9864-4388-82f7-0db584c09207","executor_address":"0x9f0564d07cb914771aa44b40fe4ef0767bbd02e2","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790282229},{"id":"d2dd3cc1-06a6-4d71-b6b4-c7440bc92a64","executor_address":"0x4467b1bb140d24743b8f358a208e98be22b2ffd5","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1790106859},{"id":"309c5419-a600-412b-aa7a-89ed5a179285","executor_address":"0x84da6098042ae632cd10898377db738b9a3a905f","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1790046278},{"id":"e461c5e6-2f58-4619-9424-b542c55ab2e6","executor_address":"0x12a735832f63d589be34655ece315cbdf7f32890","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790045333},{"id":"3a9758bf-a463-45ae-abb8-b5b186332a9b","executor_address":"0x12a735832f63d589be34655ece315cbdf7f32890","verification_result":{"passed":false,"reason":"Verification error: IPFS fetch failed: 429","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1790044856},{"id":"0ad971a1-cf14-463a-a70c-521c6060486e","executor_address":"0x153595d2bd7f385449d671983161b88312133def","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789946557},{"id":"311d4828-58e9-4083-b784-34d107e4c5ac","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789910742},{"id":"511e8d7f-9b70-4dd4-a54c-2d74803fd8ad","executor_address":"0x6e9c17439cf81247965f9543645cfc8e746c4588","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1789840811},{"id":"851ec0d7-b100-4f50-bb0a-baa8658fa445","executor_address":"0x94c0c25feca960052d61338783ca8dfc8f1d7949","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789773080},{"id":"194ffccb-0394-44d5-b3ab-ad30d959e747","executor_address":"0xff7c0e2dbc07bfa7f7723d2ddcf7ddc2e27c0402","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789585217},{"id":"1a3a9a78-00ed-43ba-8ca7-88d185748114","executor_address":"0xc915af569217a8cf90a302a84303d54ac47d72ac","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789149606},{"id":"6569c831-c854-4e46-b520-7b4be7337960","executor_address":"0x732d8af93e496ffdb34df08f7e68cca0b7ac8129","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1789098453},{"id":"2a0664f7-cb36-4961-bc76-32878fdc4d8d","executor_address":"0xbabeeed14b3fdb158361a600c3b8ea8ce554f416","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1788579286},{"id":"cc639718-3642-4aae-a90e-c69cf2c4b2f2","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787381865},{"id":"83848581-23ba-40a7-9f2b-29faeb1f2575","executor_address":"0xfbe4af6c217a3d1d18ce525aaeb01418c9f02146","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1787379824},{"id":"64b9b5da-621a-42d8-b999-55311038545f","executor_address":"0xa67d962a25ba1a603616281357de92dfdb052d47","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787332860},{"id":"eff83145-668a-4e24-80ca-01d8c66ddbdd","executor_address":"0x1f2b570216f41ae72771b14e742afde7621a869f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1787184604},{"id":"cb16cb0c-4ecd-4506-93ab-280c15277507","executor_address":"0xb49239fa70cdebd6b7542f65d11dc92bbf913fd2","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1786921120},{"id":"3cc92619-46bd-481e-bf7d-e71ec2314dde","executor_address":"0xb49239fa70cdebd6b7542f65d11dc92bbf913fd2","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1786920561},{"id":"888c968c-5bd3-402f-b933-1bd924dd9b4d","executor_address":"0xb49239fa70cdebd6b7542f65d11dc92bbf913fd2","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1786920336},{"id":"44f98d23-aa13-4a32-8010-8c79aab2003a","executor_address":"0xb49239fa70cdebd6b7542f65d11dc92bbf913fd2","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1786918685},{"id":"834178be-e565-4799-bd01-2547c1f760fd","executor_address":"0xe0e9a69d98660281b56aa5a7ab46b2db826d20dd","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1786737131},{"id":"0868f0bd-0382-430b-bedf-982ab0dcf1ad","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785873364},{"id":"f4d1dcf0-9f79-4739-8b06-8f3af35f3d28","executor_address":"0xe2e4189f60ef6fb1941b97f417a714afdfc1d935","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1785799460},{"id":"ff5af9e7-1662-4f8b-8381-7573569ef2e9","executor_address":"0x088c6b88da1ff4955d8d7583aec88519bcb742a4","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785696275},{"id":"6a6b385d-4ce2-495b-8c53-28c938ca180d","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785679081},{"id":"ae35e606-6fab-4a6a-994e-f07dd1ddf62a","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785647684},{"id":"943194c9-5ed6-45fc-9aa2-6492edcce753","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785639501},{"id":"9a257927-32e8-4201-8d2b-adf27f312753","executor_address":"0x0b3bad2b6ec27279f0bcfe6314cf1058d88d136d","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785631800},{"id":"549d7d8e-32a1-4bc3-9e36-9497e938ee05","executor_address":"0x057229458b13bb1a68431ebef94522a38513e5fc","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785625934},{"id":"87de369a-86d3-4073-aca1-ed8286452946","executor_address":"0x27639419ae014af7898bc006175537d7d61e88b6","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785519660},{"id":"3210d3a1-04bc-4816-8e66-c624a32c8689","executor_address":"0x7ef3ac86c66f629235dc1ef4c14836f8229c2970","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1785323263},{"id":"563b7ded-2026-4c10-87d0-a207668d79df","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1784814254},{"id":"884ddb6e-1127-49b5-85d5-eeb139322486","executor_address":"0x40b662bff89b7505e8656a9d07daf5330fd39f86","verification_result":{"passed":false,"reason":"Code output too small: 0 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1784806448},{"id":"c3d90a94-476b-4654-a6e0-41c87e6135a1","executor_address":"0x343c1439ce6b83faf8e7ae488a532864c74ddb2a","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1782189624},{"id":"6eefb1dc-53fc-4895-ac85-581a0b0ceaab","executor_address":"0x76d6a2661d264c2fce9d5cfc8174041dd41bb050","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780925043},{"id":"df8f429f-4c82-46e4-8a6b-c37a7e586bfa","executor_address":"0x1ea5c44f98ba233bfc15a130c7e10386aa17f709","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780853004},{"id":"f165a845-5602-493b-9e9c-f86893256972","executor_address":"0x6b07c329a4252c2d62cb6cebc1b62c58bd86927f","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780586833},{"id":"db88bc79-e6e9-4d7d-95a3-0746ac7e3ab4","executor_address":"0x6b07c329a4252c2d62cb6cebc1b62c58bd86927f","verification_result":{"passed":false,"reason":"Code output too small: 2 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1780586529},{"id":"8b9b8246-5366-44b2-b781-bafa9c600736","executor_address":"0x76d6a2661d264c2fce9d5cfc8174041dd41bb050","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780559895},{"id":"6b7ca1e0-0b0e-41ec-9840-534dc6fecba5","executor_address":"0xb4c8acddb461375d6f086d797ef84dbcbd71bbf1","verification_result":{"passed":false,"reason":"Code output too small: 1 lines","details":{"checksRun":["output_parse","file_contents","sufficient_code"],"checksFailed":["sufficient_code"]}},"passed":false,"created_at":1780147415},{"id":"7a64172b-9e19-436a-80a1-0cb1b8269ddb","executor_address":"0x70d7ea3604a5225ed36552cb9eefcca43cd1ca3b","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1780108474},{"id":"2eb122a1-47a5-449c-ba7b-5e2c928716e0","executor_address":"0x4c6d1e5da50e5d8fbd7f8b65e6c2f3e65ce5df0b","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1779816248},{"id":"31ae7a82-6aae-4d73-8c6a-f29ff96b4703","executor_address":"0x31fa748ece25f37411a955796ed247ae5aaba3fa","verification_result":{"passed":false,"reason":"Verification error: Cannot read properties of undefined (reading 'length')","details":{"checksRun":[],"checksFailed":["ipfs_fetch"]}},"passed":false,"created_at":1779645831}]}