icoa-cli 2.19.449 → 2.19.450

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{spawn as o}from"node:child_process";import{createHash as e}from"node:crypto";import{createReadStream as t,createWriteStream as n,existsSync as a,mkdirSync as r,renameSync as s,rmSync as l,statSync as i}from"node:fs";import{Readable as c}from"node:stream";import{pipeline as d}from"node:stream/promises";import{join as g}from"node:path";import chalk from"chalk";function u(){if(process.env.ICOA_AIDATA_DIR)return process.env.ICOA_AIDATA_DIR;const o="/data/aiproblems";try{if(a(o)&&i(o).isDirectory())return o}catch{}return g(process.cwd(),"icoa-aidata")}function f(o){return g(u(),o.platform,o.id)}function h(o){return o>=1024?`${(o/1024).toFixed(1)}G`:`${o}M`}function y(e,t){return new Promise(n=>{const a=o(e,t,{stdio:"ignore",shell:!1});a.on("error",()=>n(!1)),a.on("close",o=>n(0===o))})}async function p(o){const i=f(o);if(a(i))return console.log(),console.log(chalk.green(` ✓ ${o.id} is already here`)+chalk.gray(` (${i})`)),console.log(chalk.gray(" Nothing to do. ")+chalk.cyan("teleload")+chalk.gray(" lists the rest.")),void console.log();const p=g(u(),o.platform);r(p,{recursive:!0});const m=g(p,`.${o.id}.tar.zst.part`);if(console.log(),console.log(chalk.bold.white(` ⬇ ${o.id}`)+chalk.gray(` · ${h(o.tar_mb)} packed → ${h(o.unpacked_mb)} on disk · ${o.n_files} files`)),console.log(chalk.gray(" Straight from the Singapore data node — nothing goes through your laptop.")),console.log(),!await async function(o,e){const t=Date.now();let a=0,r=1048576*o.tar_mb,s=0;const l=Boolean(process.stdout.isTTY);let i=-1;const g=(o=!1)=>{const e=r>0?Math.min(100,Math.round(a/r*100)):0,n=(Date.now()-t)/1e3,s=n>0?a/1048576/n:0,c=a/1048576,d=r/1048576,g=n>=3&&a>=4194304&&s>0&&r>a?(r-a)/1048576/s:0;if(!l){const t=Math.floor(e/25);return void((t>i||o)&&(i=t,console.log(chalk.cyan(` ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s`))))}const u=Math.round(e/5),f="█".repeat(u)+"░".repeat(20-u),h=o?"":` · ${function(o){if(!Number.isFinite(o)||o<=0)return"--";const e=Math.floor(o/60),t=Math.round(o%60);return e>0?`${e}m${String(t).padStart(2,"0")}s`:`${t}s`}(g)} left`,y=` ${f} ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s${h}`;process.stdout.write(`\r${chalk.cyan(y)}${" ".repeat(12)}${o?"\n":""}`)};try{const t=await fetch(o.url,{signal:AbortSignal.timeout(36e5)});if(!t.ok||!t.body)return!1;const l=Number(t.headers.get("content-length"));Number.isFinite(l)&&l>0&&(r=l);const i=n(e),u=c.fromWeb(t.body);return u.on("data",o=>{a+=o.length;const e=Date.now();e-s>250&&(s=e,g())}),await d(u,i),g(!0),!0}catch{return process.stdout.write("\n"),!1}}(o,m))return l(m,{force:!0}),console.log(chalk.yellow(" ✗ Download failed.")+chalk.gray(" Nothing was changed — just run it again.")),void console.log();process.stdout.write(chalk.gray(" checking the file is intact… "));const w=await($=m,new Promise((o,n)=>{const a=e("sha256"),r=t($);r.on("data",o=>{a.update(o)}),r.on("end",()=>o(a.digest("hex"))),r.on("error",n)})).catch(()=>"");var $;if(o.sha256&&w!==o.sha256)return l(m,{force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" The file arrived damaged and was discarded.")+chalk.gray(" Run it again.")),void console.log();console.log(chalk.green("✓")),process.stdout.write(chalk.gray(" unpacking… "));const b=g(p,`.${o.id}.staging`);l(b,{recursive:!0,force:!0});const v=await async function(o,e){if(r(e,{recursive:!0}),await y("tar",["-xf",o,"-C",e]))return!0;if(await y("tar",["--zstd","-xf",o,"-C",e]))return!0;if(await y("tar",["-I","unzstd","-xf",o,"-C",e]))return!0;const t=`${o}.plain`;if(await y("zstd",["-d","-f","-o",t,o])){const o=await y("tar",["-xf",t,"-C",e]);return l(t,{force:!0}),o}return!1}(m,b);if(l(m,{force:!0}),!v)return l(b,{recursive:!0,force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not unpack the archive.")+chalk.gray(" Run it again.")),void console.log();const k=g(b,o.id);try{s(a(k)?k:b,i)}catch{return console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not move the data into place.")+chalk.gray(" Check disk space.")),void console.log()}l(b,{recursive:!0,force:!0}),console.log(chalk.green("✓")),console.log(),console.log(chalk.green(" 🎁 ready: ")+chalk.white(i)),console.log(chalk.gray(" Open it in a notebook — the path above is the dataset root.")),console.log(chalk.gray(" ")+chalk.cyan("teleload")+chalk.gray(" lists what else is available.")),console.log()}export async function runTeleload(o){const e=await async function(){try{const o=await fetch(process.env.ICOA_TELELOAD_MANIFEST||"https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/manifest.json",{signal:AbortSignal.timeout(3e4)});if(!o.ok)return null;const e=await o.json(),t=Array.isArray(e?.packs)?e.packs:null;return t?t.slice().sort((o,e)=>o.n-e.n):null}catch{return null}}();if(!e)return console.log(),console.log(chalk.yellow(" Could not reach the dataset node right now.")),console.log(chalk.gray(" Check your connection and try again — nothing was changed.")),void console.log();if(0===e.length)return console.log(),console.log(chalk.gray(" No on-demand datasets are published yet — everything ships inside this machine.")),void console.log();const t=(o??"").trim().replace(/^#/,"");if(""===t)return function(o){console.log(),console.log(chalk.bold.cyan(" ⬇ TELELOAD")+chalk.gray(" · big datasets, pulled straight from the data node")),console.log();for(const e of o){const o=a(f(e))?chalk.green("✓ here"):chalk.gray("⬇ not yet");console.log(` ${chalk.bold.white(String(e.n))}. ${chalk.white(e.id.padEnd(34))}`+chalk.gray(`${h(e.unpacked_mb).padStart(6)} `)+o)}console.log(),console.log(chalk.gray(" Pull one with ")+chalk.cyan("teleload <number>")+chalk.gray(" (e.g. ")+chalk.cyan("teleload 2")+chalk.gray(")"));const e="/data/aiproblems"===u();console.log(chalk.gray(e?" Smaller datasets are already baked into this box — those need no pull.":" On a laptop nothing is pre-installed: whatever a task needs, pull it here first.")),console.log()}(e);const n=Number.parseInt(t,10);let r=Number.isFinite(n)?e.find(o=>o.n===n):void 0;if(!r){const o=t.toLowerCase();r=e.find(e=>e.id.toLowerCase()===o)??e.find(e=>e.id.toLowerCase().includes(o))}if(!r){console.log(),console.log(chalk.yellow(` No dataset called "${t}".`)),console.log(chalk.gray(" These are the ones you can pull:"));for(const o of e)console.log(chalk.gray(` ${o.n}. ${o.id}`));return console.log(chalk.gray(" Try ")+chalk.cyan(`teleload ${e[0].n}`)+chalk.gray(" — or just ")+chalk.cyan("teleload")+chalk.gray(" to see sizes.")),void console.log()}await p(r)}export function registerTeleloadCommand(o){o.command("teleload").argument("[pack]","pack number (or id) from `teleload`").description("Pull a big dataset from the data node onto this machine").action(async o=>{await runTeleload(o)})}
1
+ import{spawn as o}from"node:child_process";import{createHash as e}from"node:crypto";import{createReadStream as t,createWriteStream as n,existsSync as a,mkdirSync as r,renameSync as s,rmSync as i,statSync as l,writeFileSync as c}from"node:fs";import{Readable as d}from"node:stream";import{pipeline as g}from"node:stream/promises";import{join as u}from"node:path";import chalk from"chalk";import{buildMediaStarterCells as f}from"../lib/kaggle.js";import{serializeIpynb as h}from"../lib/notebook-doc.js";import{loadSprintTasks as y}from"../lib/sprint-meta.js";import{getConfig as p}from"../lib/config.js";function m(){if(process.env.ICOA_AIDATA_DIR)return process.env.ICOA_AIDATA_DIR;const o="/data/aiproblems";try{if(a(o)&&l(o).isDirectory())return o}catch{}return u(process.cwd(),"icoa-aidata")}function w(o){return u(m(),o.platform,o.id)}function b(o){return o>=1024?`${(o/1024).toFixed(1)}G`:`${o}M`}function $(e,t){return new Promise(n=>{const a=o(e,t,{stdio:"ignore",shell:!1});a.on("error",()=>n(!1)),a.on("close",o=>n(0===o))})}async function v(o){const l=w(o);if(a(l))return console.log(),console.log(chalk.green(` ✓ ${o.id} is already here`)+chalk.gray(` (${l})`)),console.log(chalk.gray(" Nothing to do. ")+chalk.cyan("teleload")+chalk.gray(" lists the rest.")),void console.log();const v=u(m(),o.platform);r(v,{recursive:!0});const k=u(v,`.${o.id}.tar.zst.part`);if(console.log(),console.log(chalk.bold.white(` ⬇ ${o.id}`)+chalk.gray(` · ${b(o.tar_mb)} packed → ${b(o.unpacked_mb)} on disk · ${o.n_files} files`)),console.log(chalk.gray(" Straight from the Singapore data node — nothing goes through your laptop.")),console.log(),!await async function(o,e){const t=Date.now();let a=0,r=1048576*o.tar_mb,s=0;const i=Boolean(process.stdout.isTTY);let l=-1;const c=(o=!1)=>{const e=r>0?Math.min(100,Math.round(a/r*100)):0,n=(Date.now()-t)/1e3,s=n>0?a/1048576/n:0,c=a/1048576,d=r/1048576,g=n>=3&&a>=4194304&&s>0&&r>a?(r-a)/1048576/s:0;if(!i){const t=Math.floor(e/25);return void((t>l||o)&&(l=t,console.log(chalk.cyan(` ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s`))))}const u=Math.round(e/5),f="█".repeat(u)+"░".repeat(20-u),h=o?"":` · ${function(o){if(!Number.isFinite(o)||o<=0)return"--";const e=Math.floor(o/60),t=Math.round(o%60);return e>0?`${e}m${String(t).padStart(2,"0")}s`:`${t}s`}(g)} left`,y=` ${f} ${String(e).padStart(3)}% · ${c.toFixed(0)}/${d.toFixed(0)} MB · ${s.toFixed(1)} MB/s${h}`;process.stdout.write(`\r${chalk.cyan(y)}${" ".repeat(12)}${o?"\n":""}`)};try{const t=await fetch(o.url,{signal:AbortSignal.timeout(36e5)});if(!t.ok||!t.body)return!1;const i=Number(t.headers.get("content-length"));Number.isFinite(i)&&i>0&&(r=i);const l=n(e),u=d.fromWeb(t.body);return u.on("data",o=>{a+=o.length;const e=Date.now();e-s>250&&(s=e,c())}),await g(u,l),c(!0),!0}catch{return process.stdout.write("\n"),!1}}(o,k))return i(k,{force:!0}),console.log(chalk.yellow(" ✗ Download failed.")+chalk.gray(" Nothing was changed — just run it again.")),void console.log();process.stdout.write(chalk.gray(" checking the file is intact… "));const C=await(A=k,new Promise((o,n)=>{const a=e("sha256"),r=t(A);r.on("data",o=>{a.update(o)}),r.on("end",()=>o(a.digest("hex"))),r.on("error",n)})).catch(()=>"");var A;if(o.sha256&&C!==o.sha256)return i(k,{force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" The file arrived damaged and was discarded.")+chalk.gray(" Run it again.")),void console.log();console.log(chalk.green("✓")),process.stdout.write(chalk.gray(" unpacking… "));const x=u(v,`.${o.id}.staging`);i(x,{recursive:!0,force:!0});const S=await async function(o,e){if(r(e,{recursive:!0}),await $("tar",["-xf",o,"-C",e]))return!0;if(await $("tar",["--zstd","-xf",o,"-C",e]))return!0;if(await $("tar",["-I","unzstd","-xf",o,"-C",e]))return!0;const t=`${o}.plain`;if(await $("zstd",["-d","-f","-o",t,o])){const o=await $("tar",["-xf",t,"-C",e]);return i(t,{force:!0}),o}return!1}(k,x);if(i(k,{force:!0}),!S)return i(x,{recursive:!0,force:!0}),console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not unpack the archive.")+chalk.gray(" Run it again.")),void console.log();const T=u(x,o.id);try{s(a(T)?T:x,l)}catch{return console.log(chalk.yellow("✗")),console.log(chalk.yellow(" Could not move the data into place.")+chalk.gray(" Check disk space.")),void console.log()}i(x,{recursive:!0,force:!0}),console.log(chalk.green("✓")),console.log(),console.log(chalk.green(" 🎁 ready: ")+chalk.white(l));const M=y().find(e=>e.media?.pack===o.id),_=u(l,"starter.ipynb");if(M&&!a(_))try{c(_,h(f(l,M))),console.log(chalk.gray(" ▸ ")+chalk.bold.cyan(`icoa ipynb ${_}`)+chalk.gray((p().language||"en").toLowerCase().startsWith("zh")?" ← 清点 + 出一张图 + 说明要建什么":" ← inventory + one figure + what to build"))}catch{console.log(chalk.gray(" Open it in a notebook — the path above is the dataset root."))}else console.log(chalk.gray(" Open it in a notebook — the path above is the dataset root."));console.log(chalk.gray(" ")+chalk.cyan("teleload")+chalk.gray(" lists what else is available.")),console.log()}export async function runTeleload(o){const e=await async function(){try{const o=await fetch(process.env.ICOA_TELELOAD_MANIFEST||"https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/manifest.json",{signal:AbortSignal.timeout(3e4)});if(!o.ok)return null;const e=await o.json(),t=Array.isArray(e?.packs)?e.packs:null;return t?t.slice().sort((o,e)=>o.n-e.n):null}catch{return null}}();if(!e)return console.log(),console.log(chalk.yellow(" Could not reach the dataset node right now.")),console.log(chalk.gray(" Check your connection and try again — nothing was changed.")),void console.log();if(0===e.length)return console.log(),console.log(chalk.gray(" No on-demand datasets are published yet — everything ships inside this machine.")),void console.log();const t=(o??"").trim().replace(/^#/,"");if(""===t)return function(o){console.log(),console.log(chalk.bold.cyan(" ⬇ TELELOAD")+chalk.gray(" · big datasets, pulled straight from the data node")),console.log();for(const e of o){const o=a(w(e))?chalk.green("✓ here"):chalk.gray("⬇ not yet");console.log(` ${chalk.bold.white(String(e.n))}. ${chalk.white(e.id.padEnd(34))}`+chalk.gray(`${b(e.unpacked_mb).padStart(6)} `)+o)}console.log(),console.log(chalk.gray(" Pull one with ")+chalk.cyan("teleload <number>")+chalk.gray(" (e.g. ")+chalk.cyan("teleload 2")+chalk.gray(")"));const e="/data/aiproblems"===m();console.log(chalk.gray(e?" Smaller datasets are already baked into this box — those need no pull.":" On a laptop nothing is pre-installed: whatever a task needs, pull it here first.")),console.log()}(e);const n=Number.parseInt(t,10);let r=Number.isFinite(n)?e.find(o=>o.n===n):void 0;if(!r){const o=t.toLowerCase();r=e.find(e=>e.id.toLowerCase()===o)??e.find(e=>e.id.toLowerCase().includes(o))}if(!r){console.log(),console.log(chalk.yellow(` No dataset called "${t}".`)),console.log(chalk.gray(" These are the ones you can pull:"));for(const o of e)console.log(chalk.gray(` ${o.n}. ${o.id}`));return console.log(chalk.gray(" Try ")+chalk.cyan(`teleload ${e[0].n}`)+chalk.gray(" — or just ")+chalk.cyan("teleload")+chalk.gray(" to see sizes.")),void console.log()}await v(r)}export function registerTeleloadCommand(o){o.command("teleload").argument("[pack]","pack number (or id) from `teleload`").description("Pull a big dataset from the data node onto this machine").action(async o=>{await runTeleload(o)})}
@@ -66,7 +66,13 @@
66
66
  "topic_cn": "260 条 wav 的多类音频分类(A/B 两组前缀),官方解答走 mel-spectrogram + CNN;官方承认该轮数据存在泄漏,定位为教学素材",
67
67
  "comp": "s04-is-that-audio",
68
68
  "status": "ready",
69
- "baseline": "val acc 0.811"
69
+ "baseline": "val acc 0.811",
70
+ "media": {
71
+ "kind": "audio",
72
+ "pack": "s04-is-that-audio-aicc-round-1-2",
73
+ "mb": 12,
74
+ "glob": "data/raw_audio/*.wav"
75
+ }
70
76
  },
71
77
  {
72
78
  "seq": 5,
@@ -434,20 +440,15 @@
434
440
  "cli_mode": "kaggle-arena",
435
441
  "dir": "nitro/34_gaia_ai-league-i_t2_x-planet-x-model-selection",
436
442
  "topic_cn": "1000个回归模型里只有5个是在未损坏标签上训出来的,仅凭它们在训练特征上的预测矩阵把这5个揪出来",
437
- "comp": null,
438
- "status": "teleload",
443
+ "comp": "s26-planet-x",
444
+ "status": "ready",
439
445
  "pack": "s26-x-planet-x-model-selection",
440
446
  "pack_mb": 7,
441
447
  "pack_url": "https://icoa-datasets.sg-sin-1.linodeobjects.com/aidata/s26-x-planet-x-model-selection.tar.zst",
442
448
  "submit_shape": "indices",
443
449
  "submit_note": "Answer is 5 model indices, not a per-row prediction — there is no test.csv to score and none is needed. Scored at judge.nitro-ai.org; an official 100-point solution exists to check yourself against.",
444
450
  "baseline": "none",
445
- "media": {
446
- "kind": "archive",
447
- "pack": "s26-x-planet-x-model-selection",
448
- "mb": 7,
449
- "glob": "train_data__train_data.csv"
450
- }
451
+ "judged": true
451
452
  }
452
453
  ]
453
454
  }
@@ -12,6 +12,9 @@ export interface EditorCommand {
12
12
  cmd: string;
13
13
  args: string[];
14
14
  }
15
+ /** Full argv for the editor child: the user's own args, then the vim
16
+ * compat fix when applicable, then the file. Pure given `probe`. */
17
+ export declare function buildEditorArgv(ed: EditorCommand, file: string, probe?: (cmd: string) => boolean): string[];
15
18
  /** $VISUAL → $EDITOR → vi (notepad on native Windows). vi is the POSIX
16
19
  * floor — present on every baseline terminal, and what the coretools track
17
20
  * teaches — whereas nano isn't guaranteed installed. Values like "code -w"
@@ -1 +1 @@
1
- import{spawnSync as r}from"node:child_process";import{mkdtempSync as o,readFileSync as t,rmSync as s,writeFileSync as e}from"node:fs";import{tmpdir as i}from"node:os";import{join as n}from"node:path";export function resolveEditor(r=process.env,o=process.platform){const t=(r.VISUAL??"").trim()||(r.EDITOR??"").trim();if(t){const r=t.split(/\s+/);return{cmd:r[0],args:r.slice(1)}}return"win32"===o?{cmd:"notepad",args:[]}:{cmd:"vi",args:[]}}export function editTextInEditor(c,d=".py"){const l=o(n(i(),"icoa-cell-")),m=n(l,`cell${d}`);e(m,""===c||c.endsWith("\n")?c:`${c}\n`);const p=resolveEditor(),a=process.stdin,f=!!a.isTTY&&a.isRaw;try{a.isTTY&&a.setRawMode(!1);const o=r(p.cmd,[...p.args,m],{stdio:"inherit"});return o.error||0!==o.status?null:t(m,"utf8")}catch{return null}finally{a.isTTY&&f&&a.setRawMode(!0),s(l,{recursive:!0,force:!0})}}
1
+ import{spawnSync as t}from"node:child_process";import{mkdtempSync as e,readFileSync as r,rmSync as o,writeFileSync as i}from"node:fs";import{tmpdir as s}from"node:os";import{join as n}from"node:path";const c=["-c","set nocompatible","-c","set backspace=indent,eol,start"],d=new Set(["vi","vim","vim.tiny","vim.basic","vimx"]),a=new Map;function p(e){const r=a.get(e);if(void 0!==r)return r;let o=!1;try{const r=t(e,["--version"],{encoding:"utf8",timeout:2e3});o=/VIM - Vi IMproved/.test(r.stdout??"")}catch{o=!1}return a.set(e,o),o}export function buildEditorArgv(t,e,r=p){return function(t){const e=(t.split(/[\\/]/).pop()??"").toLowerCase().replace(/\.exe$/,"");return d.has(e)}(t.cmd)&&r(t.cmd)?[...t.args,...c,e]:[...t.args,e]}export function resolveEditor(t=process.env,e=process.platform){const r=(t.VISUAL??"").trim()||(t.EDITOR??"").trim();if(r){const t=r.split(/\s+/);return{cmd:t[0],args:t.slice(1)}}return"win32"===e?{cmd:"notepad",args:[]}:{cmd:"vi",args:[]}}export function editTextInEditor(c,d=".py"){const a=e(n(s(),"icoa-cell-")),p=n(a,`cell${d}`);i(p,""===c||c.endsWith("\n")?c:`${c}\n`);const l=resolveEditor(),m=process.stdin,u=!!m.isTTY&&m.isRaw;try{m.isTTY&&m.setRawMode(!1);const e=t(l.cmd,buildEditorArgv(l,p),{stdio:"inherit"});return e.error||0!==e.status?null:r(p,"utf8")}catch{return null}finally{m.isTTY&&u&&m.setRawMode(!0),o(a,{recursive:!0,force:!0})}}
@@ -91,3 +91,25 @@ export interface SubmissionVerdict {
91
91
  * naive comma-splitting is safe here.
92
92
  */
93
93
  export declare function validateSubmissionText(submission: string, sample: string): SubmissionVerdict;
94
+ /**
95
+ * Starter cells for a teleload-only task — the 6 sprint tasks whose dataset is a
96
+ * pack of images / weights / archives rather than a CSV three-pack.
97
+ *
98
+ * Those tasks shipped with NO notebook at all: `teleload` unpacked a folder and
99
+ * left the student staring at it. This is deliberately an ORIENTATION starter,
100
+ * not a solution — it inventories the pack, draws one picture of what is inside,
101
+ * and states what has to be built. Shipping the official winning notebook here
102
+ * would hand over the answer and delete the exercise.
103
+ *
104
+ * Same cell model as the CSV starter: markdown for prose, python for work, one
105
+ * `plt.show()` so `icoa ipynb` writes exactly one figure and opens one viewer.
106
+ */
107
+ export declare function buildMediaStarterCells(dir: string, task: {
108
+ seq?: number;
109
+ title?: string;
110
+ topic_cn?: string;
111
+ media?: {
112
+ kind?: string;
113
+ glob?: string;
114
+ };
115
+ }): NbCell[];
@@ -1 +1 @@
1
- import{sprintTaskForComp as e}from"./sprint-meta.js";export function parseKaggleTaskList(e){const t=e??{},a=(t.data??t).tasks;if(!Array.isArray(a))return[];const i=[];for(const e of a){if(!e||"object"!=typeof e)continue;const t=e;"string"==typeof t.comp_id&&""!==t.comp_id&&i.push({comp_id:t.comp_id,title:"string"==typeof t.title?t.title:t.comp_id,metric:"string"==typeof t.metric?t.metric:"accuracy",description:"string"==typeof t.description&&""!==t.description?t.description:void 0,kaggle_url:"string"==typeof t.kaggle_url?t.kaggle_url:null,licence:"string"==typeof t.licence?t.licence:void 0,attribution:"string"==typeof t.attribution?t.attribution:void 0,data_base:"string"==typeof t.data_base&&""!==t.data_base?t.data_base:null,id_col:"string"==typeof t.id_col?t.id_col:void 0,target_col:"string"==typeof t.target_col?t.target_col:void 0,n_train:"number"==typeof t.n_train?t.n_train:void 0,n_test:"number"==typeof t.n_test?t.n_test:void 0,judge:"string"==typeof t.judge&&""!==t.judge?t.judge:void 0,board_event:"string"==typeof t.board_event&&""!==t.board_event?t.board_event:null,needs_gpu:!0===t.needs_gpu})}return i}export function dataFileUrls(e){const t=e.data_base;if("string"!=typeof t||""===t)return null;const a=t.replace(/\/$/,"");return{train:`${a}/train.csv`,test:`${a}/test.csv`,sample_submission:`${a}/sample_submission.csv`}}export function buildStarterCells(t,a){const i=a.id_col??"id",n=a.target_col??"target";var s;s=a.metric,/rmse|mse|mae|error/i.test(s);const r="icoa-holdout"===a.judge,o=e=>({kind:"markdown",source:e,result:null}),l=e=>({kind:"code",source:e.join("\n"),result:null}),c=[`# ${a.title}`,"",...a.description?[a.description,""]:[],`Kaggle-style practice — metric: **${a.metric}**.`,"","- `train.csv` — labelled training data",`- \`test.csv\` — rows to predict (no \`${n}\` column)`,"- `sample_submission.csv` — the exact format Kaggle expects","","Run all cells top to bottom: a baseline model trains on your CPU and","`submission.csv` appears next to the data. Then improve the model cell",...r?["and re-run — `icoa kaggle submit` scores it and ranks you on the board."]:["and re-run — your score is whatever Kaggle says it is."],"","**AI help:** split your terminal (`Ctrl-b %`), run `icoa` in the right pane","and type `ai4ioai` for a live Gemma 3n E4B. Ask it for feature ideas or bug fixes —","then verify every suggestion with the val score. A tip that lowers it, drop it.",...a.licence?["",`**Data licence:** ${a.licence}`]:[],...a.attribution?[`**Attribution:** ${a.attribution}`]:[]].join("\n"),d=l(["# setup — load the data (leave as is)","import os","import numpy as np","import pandas as pd","from pandas.api.types import is_numeric_dtype","from sklearn.feature_extraction.text import TfidfVectorizer","from sklearn.model_selection import train_test_split","from sklearn.metrics import accuracy_score, mean_squared_error","","# same code everywhere: in a GPU session these env vars point at the","# box's own dataset copy + workspace — locally they are unset.",`DIR = os.environ.get("ICOA_KAGGLE_DATA") or r"${t}"`,'OUT = os.environ.get("ICOA_KAGGLE_OUT") or DIR',...a.data_base?[`DATA_BASE = "${a.data_base.replace(/\/$/,"")}"`,'if not os.path.exists(DIR + "/train.csv"):'," import urllib.request"," os.makedirs(DIR, exist_ok=True)",' for f in ("train.csv", "test.csv", "sample_submission.csv"):',' urllib.request.urlretrieve(DATA_BASE + "/" + f, DIR + "/" + f)']:[],'train = pd.read_csv(DIR + "/train.csv")','test = pd.read_csv(DIR + "/test.csv")','sub_fmt = pd.read_csv(DIR + "/sample_submission.csv")',"","# 🔴 The submission column names are NOT always the training column names.","# On tasks imported from other platforms the two genuinely differ: train.csv",'# labels the answer "class" or "result" while sample_submission.csv calls it','# "answer". Hard-coding the submission name here used to raise KeyError on the',"# very first cell. So trust the DATA: whatever column train has and test lacks","# is the thing to predict.",`SUB_ID, SUB_TARGET = "${i}", "${n}" # names the submission file wants`,"only_train = [c for c in train.columns if c not in test.columns]","TARGET = only_train[-1] if only_train else SUB_TARGET","shared = [c for c in train.columns if c in test.columns]","# Only treat a column as the row id when the submission actually names it AND",'# both files carry it. Falling back to "first shared column" silently spent a',"# real feature as an id on tasks whose id lives only in test.csv.","ID = SUB_ID if SUB_ID in shared else None",'assert TARGET in train.columns, f"cannot find the label column in {list(train.columns)}"',"","# Regression or classification? Decided from the labels, not from metadata —","# several tasks ship continuous labels, and handing those to a classifier",'# raises "Unknown label type: continuous".',"REG = is_numeric_dtype(train[TARGET]) and train[TARGET].nunique() > 20",'print(f"train {train.shape} · test {test.shape} · predicting {TARGET!r} "'," f\"({'regression' if REG else 'classification'})\")"]),u=e(a.comp_id),m=u?.media,p="audio"===m?.kind?"scipy.io.wavfile.read(path) -> numpy, then scipy.signal for a spectrogram":"image"===m?.kind?"PIL.Image.open(path) -> numpy":"weights"===m?.kind?"torch.load(path, weights_only=True) — the model itself is the input here":"unpack the archive inside the pack, then read what is in it",h=l(["# FEATURES — turn raw columns into numbers a model can use (improve THIS cell).","# Numbers: fill gaps with the median. Category (<= 20 distinct): one-hot.","# Free text: TF-IDF — on a text task the sentences ARE the signal, and dropping",'# them as "high-cardinality" leaves nothing to train on (that used to crash the','# whole notebook with "No objects to concatenate").',"# only columns present in BOTH files — a train-only column cannot be a feature","# at prediction time, and indexing test with it raises KeyError.","feat = [c for c in shared if c not in (ID, TARGET)]","Xtr_raw, Xte_raw = train[feat].copy(), test[feat].copy()","num = [c for c in feat if is_numeric_dtype(Xtr_raw[c])]","cat = [c for c in feat if c not in num and Xtr_raw[c].nunique() <= 20]","# Everything else is vectorised as text. Requiring a long average length here","# used to throw away high-cardinality SHORT strings — ingredient names, single","# words, category codes — which on several tasks are the entire signal, leaving","# the notebook with zero features.","txt = [c for c in feat if c not in num and c not in cat]","for c in num:"," med = Xtr_raw[c].median()"," Xtr_raw[c] = Xtr_raw[c].fillna(med)"," Xte_raw[c] = Xte_raw[c].fillna(med)","blocks_tr, blocks_te = [], []","if num or cat:"," d_tr = pd.get_dummies(Xtr_raw[num + cat], columns=cat, dummy_na=True)"," d_te = pd.get_dummies(Xte_raw[num + cat], columns=cat, dummy_na=True)",' d_tr, d_te = d_tr.align(d_te, join="left", axis=1, fill_value=0)'," blocks_tr.append(d_tr.to_numpy(dtype=float))"," blocks_te.append(d_te.to_numpy(dtype=float))","for c in txt:"," # fillna BEFORE astype(str): a real NaN reaching the vectoriser raises",' # "np.nan is an invalid document", and astype alone does not catch it.',' tr_txt = Xtr_raw[c].fillna("").astype(str)',' te_txt = Xte_raw[c].fillna("").astype(str)'," # min_df=1: on a short-token column (one ingredient per row) min_df=2 can"," # filter the vocabulary down to nothing."," long_col = tr_txt.str.len().mean() >= 12"," # Try the good settings, then a permissive fallback, then give up on THIS"," # column only. A column whose vocabulary prunes to nothing used to abort the",' # whole run with "After pruning, no terms remain".',' for kw in ({"min_df": 2 if long_col else 1,',' "analyzer": "word" if long_col else "char_wb"},',' {"min_df": 1, "analyzer": "char_wb"}):'," try:"," vec = TfidfVectorizer(max_features=3000, ngram_range=(1, 2), **kw)"," b_tr = vec.fit_transform(tr_txt).toarray()"," blocks_tr.append(b_tr)"," blocks_te.append(vec.transform(te_txt).toarray())"," break"," except ValueError as e:"," last = e"," else:",' print(f" skipped text column {c!r}: {last}")',"if not blocks_tr:"," raise SystemExit(",' f"No usable feature columns. The shared columns are {feat} — none of them "',' f"is numeric, categorical or text.\\n"',...m?[` "The signal for this task is in ${m.kind} files, not in the CSVs.\\n"`,` " 1. fetch them (${m.mb}MB): teleload ${m.pack}\\n"`,...m.glob?[` " files land at <pack dir>/${m.glob}\\n"`]:[],` " 2. replace this cell: ${p}\\n"`,' " build one feature row per file, then keep the rest of the notebook.\\n"']:[' f"Two kinds of task land here, and both are real work rather than a bug:\\n"',' f" 1. audio/image — train.csv only lists sample ids and labels and the "',' f"signal is in media files. Read them with scipy.io.wavfile (audio) or "',' f"PIL (images) and turn each file into a feature row.\\n"',' f" 2. train.csv and test.csv describe different things (a retrieval or "',' f"matching task). Read both files, work out what links a test row to a "',' f"train row, and build that mapping yourself.\\n"'],...m?[' f"columns — train={list(train.columns)} test={list(test.columns)}"']:[' f"Either way: replace this cell. train={list(train.columns)} "',' f"test={list(test.columns)}"']," )","X = np.hstack(blocks_tr)","X_test = np.hstack(blocks_te)","y = train[TARGET]","X_tr, X_val, y_tr, y_val = train_test_split(X, y, test_size=0.2, random_state=0)",'print(f"{X.shape[1]} model-ready features "',' f"({len(num)} numeric, {len(cat)} one-hot, {len(txt)} TF-IDF text)")']),f=l(["# MODEL — a working baseline. Improve THIS cell to climb the board.","from sklearn.linear_model import LogisticRegression, Ridge","# REG was decided from the labels back in setup.","model = Ridge() if REG else LogisticRegression(max_iter=2000)"]),g=l(["# validate — quick local score on a held-out fifth of train","model.fit(X_tr, y_tr)","p_val = model.predict(X_val)","if REG:",' print("val RMSE:", round(mean_squared_error(y_val, p_val) ** 0.5, 4))',"else:"," acc = accuracy_score(y_val, p_val)",' print("val accuracy:", round(acc, 4))'," if acc < 0.3:"," # A near-zero baseline is the expected result on several of these tasks,"," # not a broken notebook — say so, or the student reads it as a bug.",' print(" A score this low usually means the linear baseline cannot "',' "represent the pattern at all (combination rules, sequences, "',' "spelling). That IS the task: build features that expose it, "',' "or switch to a model that can. The chain itself works — "',' "submission.csv is written either way.")']),_=l(["# submission — retrain on ALL data, write submission.csv (Kaggle format)","model.fit(X, y)","pred = model.predict(X_test)",'out = OUT + "/submission.csv"',"# Copy the layout of sample_submission.csv and swap in the predictions, rather","# than rebuilding the file from column names. Some tasks want more than two","# columns (e.g. subtaskID,datapointID,answer) and a hand-built 2-column frame","# is rejected by the grader even when every prediction is right.","if len(sub_fmt) == len(pred):"," sub = sub_fmt.copy()"," sub[sub.columns[-1]] = pred","else:"," keys = {}"," if ID is not None and ID in test.columns:"," keys[SUB_ID] = test[ID]"," keys[SUB_TARGET] = pred"," sub = pd.DataFrame(keys)",' print(f"NOTE: sample_submission has {len(sub_fmt)} rows but test has "',' f"{len(pred)} — built the file from column names instead; "',' f"check it against the task page before submitting.")',"sub.to_csv(out, index=False)",'print("wrote", out, "·", list(sub.columns))',r?`print("score it: icoa kaggle submit ${a.comp_id}")`:'print("format check: icoa kaggle check")']),b=r?["## Submit to ICOA (scored on the server)","",`1. In the ICOA CLI run \`icoa kaggle submit ${a.comp_id}\``,"2. The server scores `submission.csv` against the secret test labels"," and your rank lands on the live board (`icoa board`).","3. Improve the MODEL cell, re-run, submit again — best score counts."]:"nitro"===a.judge?["## Where this one gets scored","","This task comes from **judge.nitro-ai.org** and the answer key stays on","their server, so ICOA cannot score it for you. That does not make it a","practice stub — it is a real task, just judged elsewhere.","",`1. \`icoa kaggle check ${a.comp_id}\` — checks the FORMAT of`," `submission.csv` (headers, row count, ids). Format errors are the most"," common way a correct answer still scores zero.","2. Watch the **val score** printed above — that is your real feedback loop"," during the sprint, and it needs no account anywhere.","3. Want the official number? Register at judge.nitro-ai.org and submit"," there. Otherwise compare against the official solution, or ask"," `ai4ioai` to review your approach."]:a.kaggle_url?["## Submit on Kaggle (manual, your own account)","",`1. Open ${a.kaggle_url}`,"2. **Submit Predictions** → upload `submission.csv`","3. Read your leaderboard score, come back, improve the MODEL cell, repeat."]:["## Submit on Kaggle (manual, your own account)","","_This dataset has no live Kaggle page linked yet._","The loop is identical: upload `submission.csv`, read the score, improve","the MODEL cell, repeat. Meanwhile the **val score** printed above is a","real signal you can work against with no account at all."];return[o(c),d,h,f,g,_,o(b.join("\n"))]}export function parseSubmitResponse(e){const t=e&&"object"==typeof e?e:{},a=t.data??t,i=a&&"object"==typeof a?a:{};return"number"==typeof i.score&&"string"==typeof i.metric?{ok:!0,score:i.score,metric:i.metric,rank:"number"==typeof i.rank_at_time?i.rank_at_time:null,fieldSize:"number"==typeof i.field_size?i.field_size:null,deduped:!0===i.deduped,boardEvent:"string"==typeof i.board_event?i.board_event:null}:"string"==typeof i.reason&&""!==i.reason?{ok:!1,reason:i.reason,error:"string"==typeof i.error?i.error:void 0,problems:Array.isArray(i.problems)?i.problems.filter(e=>"string"==typeof e):void 0}:{ok:!1,reason:"network"}}export function validateSubmissionText(e,t){const a=[],i=e.trim().split(/\r?\n/),n=t.trim().split(/\r?\n/),s=i[0]??"",r=n[0]??"";s.trim()!==r.trim()&&a.push(`header mismatch: expected "${r}", got "${s}"`);const o=i.slice(1).filter(e=>""!==e.trim()),l=n.slice(1).filter(e=>""!==e.trim());o.length!==l.length&&a.push(`row count mismatch: expected ${l.length}, got ${o.length}`);const c=e=>new Set(e.map(e=>(e.split(",")[0]??"").trim())),d=c(o),u=c(l),m=[...u].filter(e=>!d.has(e)),p=[...d].filter(e=>!u.has(e));if(m.length>0||p.length>0){const e=[];m.length>0&&e.push(`${m.length} missing (e.g. ${m[0]})`),p.length>0&&e.push(`${p.length} unknown (e.g. ${p[0]})`),a.push(`id mismatch vs sample_submission: ${e.join(", ")}`)}for(let e=0;e<o.length;e++)if(o[e].split(",").some(e=>""===e.trim())){a.push(`empty cell in data row ${e+1}`);break}return{ok:0===a.length,problems:a}}
1
+ import{sprintTaskForComp as e}from"./sprint-meta.js";export function parseKaggleTaskList(e){const t=e??{},s=(t.data??t).tasks;if(!Array.isArray(s))return[];const a=[];for(const e of s){if(!e||"object"!=typeof e)continue;const t=e;"string"==typeof t.comp_id&&""!==t.comp_id&&a.push({comp_id:t.comp_id,title:"string"==typeof t.title?t.title:t.comp_id,metric:"string"==typeof t.metric?t.metric:"accuracy",description:"string"==typeof t.description&&""!==t.description?t.description:void 0,kaggle_url:"string"==typeof t.kaggle_url?t.kaggle_url:null,licence:"string"==typeof t.licence?t.licence:void 0,attribution:"string"==typeof t.attribution?t.attribution:void 0,data_base:"string"==typeof t.data_base&&""!==t.data_base?t.data_base:null,id_col:"string"==typeof t.id_col?t.id_col:void 0,target_col:"string"==typeof t.target_col?t.target_col:void 0,n_train:"number"==typeof t.n_train?t.n_train:void 0,n_test:"number"==typeof t.n_test?t.n_test:void 0,judge:"string"==typeof t.judge&&""!==t.judge?t.judge:void 0,board_event:"string"==typeof t.board_event&&""!==t.board_event?t.board_event:null,needs_gpu:!0===t.needs_gpu})}return a}export function dataFileUrls(e){const t=e.data_base;if("string"!=typeof t||""===t)return null;const s=t.replace(/\/$/,"");return{train:`${s}/train.csv`,test:`${s}/test.csv`,sample_submission:`${s}/sample_submission.csv`}}export function buildStarterCells(t,s){const a=s.id_col??"id",i=s.target_col??"target";var n;n=s.metric,/rmse|mse|mae|error/i.test(n);const r="icoa-holdout"===s.judge,o=e=>({kind:"markdown",source:e,result:null}),l=e=>({kind:"code",source:e.join("\n"),result:null}),c=[`# ${s.title}`,"",...s.description?[s.description,""]:[],`Kaggle-style practice — metric: **${s.metric}**.`,"","- `train.csv` — labelled training data",`- \`test.csv\` — rows to predict (no \`${i}\` column)`,"- `sample_submission.csv` — the exact format Kaggle expects","","Run all cells top to bottom: a baseline model trains on your CPU and","`submission.csv` appears next to the data. Then improve the model cell",...r?["and re-run — `icoa kaggle submit` scores it and ranks you on the board."]:["and re-run — your score is whatever Kaggle says it is."],"","**AI help:** split your terminal (`Ctrl-b %`), run `icoa` in the right pane","and type `ai4ioai` for a live Gemma 3n E4B. Ask it for feature ideas or bug fixes —","then verify every suggestion with the val score. A tip that lowers it, drop it.",...s.licence?["",`**Data licence:** ${s.licence}`]:[],...s.attribution?[`**Attribution:** ${s.attribution}`]:[]].join("\n"),p=l(["# setup — load the data (leave as is)","import os","import numpy as np","import pandas as pd","from pandas.api.types import is_numeric_dtype","from sklearn.feature_extraction.text import TfidfVectorizer","from sklearn.model_selection import train_test_split","from sklearn.metrics import accuracy_score, mean_squared_error","","# same code everywhere: in a GPU session these env vars point at the","# box's own dataset copy + workspace — locally they are unset.",`DIR = os.environ.get("ICOA_KAGGLE_DATA") or r"${t}"`,'OUT = os.environ.get("ICOA_KAGGLE_OUT") or DIR',...s.data_base?[`DATA_BASE = "${s.data_base.replace(/\/$/,"")}"`,'if not os.path.exists(DIR + "/train.csv"):'," import urllib.request"," os.makedirs(DIR, exist_ok=True)",' for f in ("train.csv", "test.csv", "sample_submission.csv"):',' urllib.request.urlretrieve(DATA_BASE + "/" + f, DIR + "/" + f)']:[],'train = pd.read_csv(DIR + "/train.csv")','test = pd.read_csv(DIR + "/test.csv")','sub_fmt = pd.read_csv(DIR + "/sample_submission.csv")',"","# 🔴 The submission column names are NOT always the training column names.","# On tasks imported from other platforms the two genuinely differ: train.csv",'# labels the answer "class" or "result" while sample_submission.csv calls it','# "answer". Hard-coding the submission name here used to raise KeyError on the',"# very first cell. So trust the DATA: whatever column train has and test lacks","# is the thing to predict.",`SUB_ID, SUB_TARGET = "${a}", "${i}" # names the submission file wants`,"only_train = [c for c in train.columns if c not in test.columns]","TARGET = only_train[-1] if only_train else SUB_TARGET","shared = [c for c in train.columns if c in test.columns]","# Only treat a column as the row id when the submission actually names it AND",'# both files carry it. Falling back to "first shared column" silently spent a',"# real feature as an id on tasks whose id lives only in test.csv.","ID = SUB_ID if SUB_ID in shared else None",'assert TARGET in train.columns, f"cannot find the label column in {list(train.columns)}"',"","# Regression or classification? Decided from the labels, not from metadata —","# several tasks ship continuous labels, and handing those to a classifier",'# raises "Unknown label type: continuous".',"REG = is_numeric_dtype(train[TARGET]) and train[TARGET].nunique() > 20",'print(f"train {train.shape} · test {test.shape} · predicting {TARGET!r} "'," f\"({'regression' if REG else 'classification'})\")","# 前几行 —— 看一眼真实数据长什么样,比看列名有用得多","print(train.head(3).to_string(max_colwidth=24)[:700])"]),d=e(s.comp_id),u=d?.media,m="audio"===u?.kind?"scipy.io.wavfile.read(path) -> numpy, then scipy.signal for a spectrogram":"image"===u?.kind?"PIL.Image.open(path) -> numpy":"weights"===u?.kind?"torch.load(path, weights_only=True) — the model itself is the input here":"unpack the archive inside the pack, then read what is in it",h=l(["# FEATURES — turn raw columns into numbers a model can use (improve THIS cell).","# Numbers: fill gaps with the median. Category (<= 20 distinct): one-hot.","# Free text: TF-IDF — on a text task the sentences ARE the signal, and dropping",'# them as "high-cardinality" leaves nothing to train on (that used to crash the','# whole notebook with "No objects to concatenate").',"# only columns present in BOTH files — a train-only column cannot be a feature","# at prediction time, and indexing test with it raises KeyError.","feat = [c for c in shared if c not in (ID, TARGET)]","Xtr_raw, Xte_raw = train[feat].copy(), test[feat].copy()","num = [c for c in feat if is_numeric_dtype(Xtr_raw[c])]","cat = [c for c in feat if c not in num and Xtr_raw[c].nunique() <= 20]","# Everything else is vectorised as text. Requiring a long average length here","# used to throw away high-cardinality SHORT strings — ingredient names, single","# words, category codes — which on several tasks are the entire signal, leaving","# the notebook with zero features.","txt = [c for c in feat if c not in num and c not in cat]","for c in num:"," med = Xtr_raw[c].median()"," Xtr_raw[c] = Xtr_raw[c].fillna(med)"," Xte_raw[c] = Xte_raw[c].fillna(med)","blocks_tr, blocks_te = [], []","if num or cat:"," d_tr = pd.get_dummies(Xtr_raw[num + cat], columns=cat, dummy_na=True)"," d_te = pd.get_dummies(Xte_raw[num + cat], columns=cat, dummy_na=True)",' d_tr, d_te = d_tr.align(d_te, join="left", axis=1, fill_value=0)'," blocks_tr.append(d_tr.to_numpy(dtype=float))"," blocks_te.append(d_te.to_numpy(dtype=float))","for c in txt:"," # fillna BEFORE astype(str): a real NaN reaching the vectoriser raises",' # "np.nan is an invalid document", and astype alone does not catch it.',' tr_txt = Xtr_raw[c].fillna("").astype(str)',' te_txt = Xte_raw[c].fillna("").astype(str)'," # min_df=1: on a short-token column (one ingredient per row) min_df=2 can"," # filter the vocabulary down to nothing."," long_col = tr_txt.str.len().mean() >= 12"," # Try the good settings, then a permissive fallback, then give up on THIS"," # column only. A column whose vocabulary prunes to nothing used to abort the",' # whole run with "After pruning, no terms remain".',' for kw in ({"min_df": 2 if long_col else 1,',' "analyzer": "word" if long_col else "char_wb"},',' {"min_df": 1, "analyzer": "char_wb"}):'," try:"," vec = TfidfVectorizer(max_features=3000, ngram_range=(1, 2), **kw)"," b_tr = vec.fit_transform(tr_txt).toarray()"," blocks_tr.append(b_tr)"," blocks_te.append(vec.transform(te_txt).toarray())"," break"," except ValueError as e:"," last = e"," else:",' print(f" skipped text column {c!r}: {last}")',"if not blocks_tr:"," raise SystemExit(",' f"No usable feature columns. The shared columns are {feat} — none of them "',' f"is numeric, categorical or text.\\n"',...u?[` "The signal for this task is in ${u.kind} files, not in the CSVs.\\n"`,` " 1. fetch them (${u.mb}MB): teleload ${u.pack}\\n"`,...u.glob?[` " files land at <pack dir>/${u.glob}\\n"`]:[],` " 2. replace this cell: ${m}\\n"`,' " build one feature row per file, then keep the rest of the notebook.\\n"']:[' f"Two kinds of task land here, and both are real work rather than a bug:\\n"',' f" 1. audio/image — train.csv only lists sample ids and labels and the "',' f"signal is in media files. Read them with scipy.io.wavfile (audio) or "',' f"PIL (images) and turn each file into a feature row.\\n"',' f" 2. train.csv and test.csv describe different things (a retrieval or "',' f"matching task). Read both files, work out what links a test row to a "',' f"train row, and build that mapping yourself.\\n"'],...u?[' f"columns — train={list(train.columns)} test={list(test.columns)}"']:[' f"Either way: replace this cell. train={list(train.columns)} "',' f"test={list(test.columns)}"']," )","X = np.hstack(blocks_tr)","X_test = np.hstack(blocks_te)","y = train[TARGET]","X_tr, X_val, y_tr, y_val = train_test_split(X, y, test_size=0.2, random_state=0)",'print(f"{X.shape[1]} model-ready features "',' f"({len(num)} numeric, {len(cat)} one-hot, {len(txt)} TF-IDF text)")']),f=l(["# EDA — look at the labels before you model. Produces ONE figure:","# left = what you are predicting (class balance / value spread)","# right = what the FEATURES cell will have to work with","# icoa ipynb saves it as a .png and opens your image viewer (type `open` to reopen).","import matplotlib.pyplot as plt","try:"," fig, ax = plt.subplots(1, 2, figsize=(11, 4))"," if REG:",' vals = pd.to_numeric(train[TARGET], errors="coerce").dropna()'," ax[0].hist(vals, bins=30)",' ax[0].set_title(f"{TARGET} — {len(vals)} values, mean {vals.mean():.3g}")'," else:"," vc = train[TARGET].astype(str).value_counts().head(12)"," ax[0].bar(range(len(vc)), vc.values)"," ax[0].set_xticks(range(len(vc)))",' ax[0].set_xticklabels([s[:14] for s in vc.index], rotation=45, ha="right")',' # An imbalanced target is the single most common reason a "good"'," # accuracy means nothing — show the majority share right in the title."," top = vc.iloc[0] / len(train)",' ax[0].set_title(f"{TARGET} — {train[TARGET].nunique()} classes · biggest {top:.0%}")',' kinds = {"numeric": 0, "category": 0, "text": 0}'," for c in [c for c in shared if c not in (ID, TARGET)]:"," if is_numeric_dtype(train[c]):",' kinds["numeric"] += 1'," elif train[c].nunique() <= 20:",' kinds["category"] += 1'," else:",' kinds["text"] += 1'," miss = train.isna().mean()"," miss = miss[miss > 0].sort_values(ascending=False).head(10)"," if len(miss) > 0:"," ax[1].barh(range(len(miss)), miss.values)"," ax[1].set_yticks(range(len(miss)))"," ax[1].set_yticklabels([s[:16] for s in miss.index])",' ax[1].set_title("missing rate (top columns)")'," else:"," ax[1].bar(list(kinds), list(kinds.values()))",' ax[1].set_title(f"{sum(kinds.values())} usable columns · no missing values")'," plt.tight_layout()"," plt.show()",' print("columns by kind:", kinds)',"except Exception as e:"," # EDA is never allowed to stop the run — `run all` halts on the first"," # error, and a plotting hiccup must not cost the student their baseline.",' print("EDA skipped:", type(e).__name__, e)']),g=l(["# MODEL — a working baseline. Improve THIS cell to climb the board.","from sklearn.linear_model import LogisticRegression, Ridge","# REG was decided from the labels back in setup.","model = Ridge() if REG else LogisticRegression(max_iter=2000)"]),_=l(["# validate — quick local score on a held-out fifth of train","model.fit(X_tr, y_tr)","p_val = model.predict(X_val)","if REG:",' print("val RMSE:", round(mean_squared_error(y_val, p_val) ** 0.5, 4))',"else:"," acc = accuracy_score(y_val, p_val)",' print("val accuracy:", round(acc, 4))'," if acc < 0.3:"," # A near-zero baseline is the expected result on several of these tasks,"," # not a broken notebook — say so, or the student reads it as a bug.",' print(" A score this low usually means the linear baseline cannot "',' "represent the pattern at all (combination rules, sequences, "',' "spelling). That IS the task: build features that expose it, "',' "or switch to a model that can. The chain itself works — "',' "submission.csv is written either way.")']),b=l(["# submission — retrain on ALL data, write submission.csv (Kaggle format)","model.fit(X, y)","pred = model.predict(X_test)",'out = OUT + "/submission.csv"',"# Copy the layout of sample_submission.csv and swap in the predictions, rather","# than rebuilding the file from column names. Some tasks want more than two","# columns (e.g. subtaskID,datapointID,answer) and a hand-built 2-column frame","# is rejected by the grader even when every prediction is right.","if len(sub_fmt) == len(pred):"," sub = sub_fmt.copy()"," sub[sub.columns[-1]] = pred","else:"," keys = {}"," if ID is not None and ID in test.columns:"," keys[SUB_ID] = test[ID]"," keys[SUB_TARGET] = pred"," sub = pd.DataFrame(keys)",' print(f"NOTE: sample_submission has {len(sub_fmt)} rows but test has "',' f"{len(pred)} — built the file from column names instead; "',' f"check it against the task page before submitting.")',"sub.to_csv(out, index=False)",'print("wrote", out, "·", list(sub.columns))',r?`print("score it: icoa kaggle submit ${s.comp_id}")`:'print("format check: icoa kaggle check")']),y=r?["## Submit to ICOA (scored on the server)","",`1. In the ICOA CLI run \`icoa kaggle submit ${s.comp_id}\``,"2. The server scores `submission.csv` against the secret test labels"," and your rank lands on the live board (`icoa board`).","3. Improve the MODEL cell, re-run, submit again — best score counts."]:"nitro"===s.judge?["## Where this one gets scored","","This task comes from **judge.nitro-ai.org** and the answer key stays on","their server, so ICOA cannot score it for you. That does not make it a","practice stub — it is a real task, just judged elsewhere.","",`1. \`icoa kaggle check ${s.comp_id}\` — checks the FORMAT of`," `submission.csv` (headers, row count, ids). Format errors are the most"," common way a correct answer still scores zero.","2. Watch the **val score** printed above — that is your real feedback loop"," during the sprint, and it needs no account anywhere.","3. Want the official number? Register at judge.nitro-ai.org and submit"," there. Otherwise compare against the official solution, or ask"," `ai4ioai` to review your approach."]:s.kaggle_url?["## Submit on Kaggle (manual, your own account)","",`1. Open ${s.kaggle_url}`,"2. **Submit Predictions** → upload `submission.csv`","3. Read your leaderboard score, come back, improve the MODEL cell, repeat."]:["## Submit on Kaggle (manual, your own account)","","_This dataset has no live Kaggle page linked yet._","The loop is identical: upload `submission.csv`, read the score, improve","the MODEL cell, repeat. Meanwhile the **val score** printed above is a","real signal you can work against with no account at all."];return[o(c),p,f,h,g,_,b,o(y.join("\n"))]}export function parseSubmitResponse(e){const t=e&&"object"==typeof e?e:{},s=t.data??t,a=s&&"object"==typeof s?s:{};return"number"==typeof a.score&&"string"==typeof a.metric?{ok:!0,score:a.score,metric:a.metric,rank:"number"==typeof a.rank_at_time?a.rank_at_time:null,fieldSize:"number"==typeof a.field_size?a.field_size:null,deduped:!0===a.deduped,boardEvent:"string"==typeof a.board_event?a.board_event:null}:"string"==typeof a.reason&&""!==a.reason?{ok:!1,reason:a.reason,error:"string"==typeof a.error?a.error:void 0,problems:Array.isArray(a.problems)?a.problems.filter(e=>"string"==typeof e):void 0}:{ok:!1,reason:"network"}}export function validateSubmissionText(e,t){const s=[],a=e.trim().split(/\r?\n/),i=t.trim().split(/\r?\n/),n=a[0]??"",r=i[0]??"";n.trim()!==r.trim()&&s.push(`header mismatch: expected "${r}", got "${n}"`);const o=a.slice(1).filter(e=>""!==e.trim()),l=i.slice(1).filter(e=>""!==e.trim());o.length!==l.length&&s.push(`row count mismatch: expected ${l.length}, got ${o.length}`);const c=e=>new Set(e.map(e=>(e.split(",")[0]??"").trim())),p=c(o),d=c(l),u=[...d].filter(e=>!p.has(e)),m=[...p].filter(e=>!d.has(e));if(u.length>0||m.length>0){const e=[];u.length>0&&e.push(`${u.length} missing (e.g. ${u[0]})`),m.length>0&&e.push(`${m.length} unknown (e.g. ${m[0]})`),s.push(`id mismatch vs sample_submission: ${e.join(", ")}`)}for(let e=0;e<o.length;e++)if(o[e].split(",").some(e=>""===e.trim())){s.push(`empty cell in data row ${e+1}`);break}return{ok:0===s.length,problems:s}}export function buildMediaStarterCells(e,t){const s=e=>({kind:"markdown",source:e,result:null}),a=e=>({kind:"code",source:e.join("\n"),result:null}),i=t.media?.kind??"archive",n=t.title??"ICOA sprint task",r=[`# ${t.seq?`${t.seq} · `:""}${n}`,"",...t.topic_cn?[t.topic_cn,""]:[],"This task ships **data, not a baseline** — the CSV starter cannot help here",`because the signal lives in the ${i} files you just pulled.`,"","Run all cells: they inventory the pack and draw one picture of what is inside,","so you start from evidence instead of from the folder name. The last cell says","what you have to build — that part is the task.","","**Reading the files:** on your laptop the notebook env has numpy / scipy /","pandas / scikit-learn / torch / transformers / Pillow — but NOT librosa,","torchaudio or soundfile. The GPU contest box has librosa and torchaudio too."].join("\n"),o=a(["# inventory — what is actually in this pack (counts, sizes, a few real names)","import os","import numpy as np",`DIR = os.environ.get("ICOA_PACK_DIR") or r"${e}"`,"by_ext, total, sample = {}, 0, {}","for root, _dirs, files in os.walk(DIR):"," for f in files:",' ext = os.path.splitext(f)[1].lower() or "(no ext)"'," p = os.path.join(root, f)"," by_ext[ext] = by_ext.get(ext, 0) + 1"," total += os.path.getsize(p)"," sample.setdefault(ext, p)",'print(f"{DIR}\\n{sum(by_ext.values())} files · {total/1048576:.0f} MB")',"for ext, n in sorted(by_ext.items(), key=lambda kv: -kv[1])[:8]:",' print(f" {ext:>10} {n:>6} e.g. {os.path.relpath(sample[ext], DIR)}")',"# 🔴 a leftover .zip means the pack still needs unpacking before you can read it",'zips = [p for e, p in sample.items() if e == ".zip"]',"if zips:",' print("\\nNOTE: there is still a .zip in here — unpack it first:")',' print(f" import zipfile; zipfile.ZipFile(r\\"{zips[0]}\\").extractall(DIR)")']),l=["# EDA — one picture of what is inside. icoa ipynb saves it as a .png and","# opens your image viewer (`open` reopens it).","import matplotlib.pyplot as plt","try:"];"image"===i?l.push(" from PIL import Image"," imgs = []"," for root, _d, files in os.walk(DIR):"," for f in sorted(files):",' if os.path.splitext(f)[1].lower() in (".jpg", ".jpeg", ".png"):'," imgs.append(os.path.join(root, f))"," if len(imgs) >= 9:"," break"," fig, axes = plt.subplots(3, 3, figsize=(7, 7))"," for ax, p in zip(axes.ravel(), imgs[:9]):"," ax.imshow(Image.open(p))"," ax.set_title(os.path.basename(p)[:18], fontsize=8)"," for ax in axes.ravel():",' ax.axis("off")',' plt.suptitle(f"{len(imgs)}+ images · first 9")'):"weights"===i?l.push(" import torch"," wfiles = []"," for root, _d, files in os.walk(DIR):"," for f in sorted(files):",' if os.path.splitext(f)[1].lower() in (".pt", ".pth"):'," wfiles.append(os.path.join(root, f))"," fig, ax = plt.subplots(1, max(1, min(2, len(wfiles))), figsize=(10, 4), squeeze=False)"," for i, p in enumerate(wfiles[:2]):"," # weights_only=True: never unpickle arbitrary objects from a data file",' obj = torch.load(p, map_location="cpu", weights_only=True)',' t = obj if hasattr(obj, "flatten") else list(obj.values())[0]'," v = np.asarray(t, dtype=float).ravel()"," ax[0][i].hist(v, bins=60)",' ax[0][i].set_title(f"{os.path.basename(p)} · shape {tuple(np.shape(t))}", fontsize=9)',' print(os.path.basename(p), "shape", tuple(np.shape(t)))'):l.push(" import pandas as pd"," csvs = []"," for root, _d, files in os.walk(DIR):"," for f in files:",' if f.lower().endswith(".csv"):'," csvs.append(os.path.join(root, f))"," csvs.sort(key=os.path.getsize, reverse=True)"," df = pd.read_csv(csvs[0])"," print(os.path.basename(csvs[0]), df.shape)"," print(df.head(3).to_string(max_colwidth=24)[:600])"," # the last low-cardinality column is the usual label; if there is none,"," # plot the row-length spread so the picture still says something true"," cand = [c for c in df.columns if df[c].nunique() <= 30]"," fig, ax = plt.subplots(figsize=(8, 4))"," if cand:"," vc = df[cand[-1]].astype(str).value_counts().head(12)"," ax.bar(range(len(vc)), vc.values)"," ax.set_xticks(range(len(vc)))",' ax.set_xticklabels([s[:14] for s in vc.index], rotation=45, ha="right")',' ax.set_title(f"{cand[-1]} — {df[cand[-1]].nunique()} values")'," else:"," ax.hist([len(str(x)) for x in df[df.columns[-1]]], bins=30)",' ax.set_title(f"length of {df.columns[-1]}")'),l.push(" plt.tight_layout()"," plt.show()","except Exception as e:"," # never stop the run on a plotting problem — `run all` halts on first error",' print("EDA skipped:", type(e).__name__, e)');const c=["## Your job","","There is no baseline to beat here — you build the first one. The shape of it:","","1. **turn each file into a row of numbers** — that is the whole trick","image"===i?" (`PIL.Image.open` → resize → `np.asarray` → flatten, or a pretrained encoder)":"weights"===i?" (`torch.load(..., weights_only=True)` → the tensors themselves ARE the features)":" (read the CSVs / unpack the archive, then vectorise the text columns)","2. keep a held-out fifth of the data and print a val score every time","3. write your predictions in exactly the format the task page asks for","","`add` makes a new code cell · `add md` a note cell · `run all` runs everything ·","a cell that raises offers `ai N`, which sends that cell and its traceback to the AI."].join("\n");return[s(r),o,a(l),s(c)]}
@@ -44,7 +44,18 @@ export declare function sprintTaskForComp(comp: string | null | undefined): Spri
44
44
  export declare function taskSteps(t: SprintTaskMeta): string[];
45
45
  /** One-line answer to "will `run all` give me a number?" */
46
46
  export declare function baselineChip(t: SprintTaskMeta, zh: boolean): string;
47
- /** `💻 CPU 可做` / `⚡ 需 GPU · 晚场` — decides what a student can do right now. */
47
+ /**
48
+ * What a student can do RIGHT NOW.
49
+ *
50
+ * 🔴 The GPU half used to read "⚡ 需 GPU · 排晚场", which sent students to
51
+ * `gpu on` — and that path is currently broken for sprint tasks: the box's data
52
+ * tree is `/data/aiproblems/<platform>/<source-name>` while the notebook asks
53
+ * for `/data/kaggle/<comp_id>`, so the kernel lands on a directory that does not
54
+ * exist (and these comps carry no `data_base` fallback either). Meanwhile we
55
+ * MEASURED every one of them producing a baseline on a laptop CPU. So the chip
56
+ * says the true thing: heavy, GPU optional, starts here. Put "evening window"
57
+ * back once the box-side hydration lands.
58
+ */
48
59
  export declare function computeChip(t: SprintTaskMeta, zh: boolean): string;
49
60
  /**
50
61
  * The media block: what is missing, the command that fetches it, and the first
@@ -1 +1 @@
1
- import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,join as i}from"node:path";import{fileURLToPath as o}from"node:url";const a=n(o(import.meta.url));export function sprintDataPath(t){const n=[i(a,"..","data",t),i(a,"..","..","src","data",t)];for(const t of n)if(e(t))return t;return n[0]}let r=null;export function loadSprintTasks(){if(r)return r;try{const e=JSON.parse(t(sprintDataPath("sprint-tasks.json"),"utf8"));r=Array.isArray(e?.tasks)?e.tasks.slice().sort((e,t)=>e.seq-t.seq):[]}catch{r=[]}return r}export function sprintTaskForComp(e){if(!e)return null;const t=e.trim().toLowerCase();return loadSprintTasks().find(e=>(e.comp||"").toLowerCase()===t)??null}export function taskSteps(e){const t=[];return e.media&&t.push(`teleload ${e.media.pack}`),"teleload"===e.status?t.length>0?t:[`teleload ${e.comp??""}`.trim()]:(e.comp&&t.push(`kaggle ${e.comp}`),t)}export function baselineChip(e,t){const n=(e.baseline||"").trim();if(!n)return"";if("none"===n)return t?"📊 无 baseline — 特征要你自己建(见下)":"📊 no baseline — you build the features (below)";if("pack"===n)return t?"📊 官方 baseline.ipynb 在数据包里":"📊 the pack ships the official baseline.ipynb";const i=t?`📊 开箱 baseline ${n}`:`📊 out-of-the-box baseline ${n}`;return/\b0\.(0\d|1\d|2\d)/.test(n)||/\b0\.000/.test(n)?i+(t?" — 线性模型对这题本就无效,不是坏了":" — a linear model cannot express this task; not a bug"):i}export function computeChip(e,t){return e.needs_gpu?t?"⚡ GPU · 排晚场":"⚡ needs GPU · evening window":t?"💻 CPU 可做 · 现在就能开":"💻 CPU is enough · start now"}function s(e,t){switch(e){case"audio":return t?"本机 aienv:scipy.io.wavfile.read → numpy → scipy.signal 求谱(没有 librosa)· GPU 箱上 librosa/torchaudio 都有":"on your laptop: scipy.io.wavfile.read → numpy → scipy.signal (no librosa here) · on the GPU box librosa/torchaudio both exist";case"image":return t?"PIL.Image.open 读图 → numpy":"PIL.Image.open → numpy";case"weights":return t?"torch.load(..., weights_only=True) 读权重(输入就是模型)":"torch.load(..., weights_only=True) — the model IS the input here";default:return t?"先解开包里的压缩档再读":"unpack the archive inside the pack first"}}export function mediaHelpLines(e,t){const n=e.media;if(!n)return[];const i="audio"===n.kind?t?"音频":"audio":"image"===n.kind?t?"图片":"images":"weights"===n.kind?t?"模型权重":"model weights":t?"附件档":"an archive",o="none"===(e.baseline||"").trim()?t?`⚠ 这题的信号在${i}里,CSV 只有 id 和标签 —— 通用 starter 会在第 3 格停下。`:`⚠ The signal is in the ${i}; the CSVs carry only ids and labels — the generic starter stops at cell 3.`:t?`⚠ 真信号在${i}里。只喂 CSV 也能跑完,但分数接近瞎猜(${e.baseline})。`:`⚠ The real signal is in the ${i}. CSV-only does finish, but scores near chance (${e.baseline}).`;return t?[o,`▸ 先拉数据(${n.mb}MB):teleload ${n.pack}`,`▸ 然后把 FEATURES 那一格换成:${s(n.kind,!0)}`,...n.glob?[` 文件在 <数据目录>/${n.glob}`]:[]]:[o,`▸ Pull it first (${n.mb}MB): teleload ${n.pack}`,`▸ Then replace the FEATURES cell: ${s(n.kind,!1)}`,...n.glob?[` files live at <data dir>/${n.glob}`]:[]]}
1
+ import{existsSync as e,readFileSync as t}from"node:fs";import{dirname as n,join as i}from"node:path";import{fileURLToPath as a}from"node:url";const o=n(a(import.meta.url));export function sprintDataPath(t){const n=[i(o,"..","data",t),i(o,"..","..","src","data",t)];for(const t of n)if(e(t))return t;return n[0]}let r=null;export function loadSprintTasks(){if(r)return r;try{const e=JSON.parse(t(sprintDataPath("sprint-tasks.json"),"utf8"));r=Array.isArray(e?.tasks)?e.tasks.slice().sort((e,t)=>e.seq-t.seq):[]}catch{r=[]}return r}export function sprintTaskForComp(e){if(!e)return null;const t=e.trim().toLowerCase();return loadSprintTasks().find(e=>(e.comp||"").toLowerCase()===t)??null}export function taskSteps(e){const t=[];return e.media&&t.push(`teleload ${e.media.pack}`),"teleload"===e.status?t.length>0?t:[`teleload ${e.comp??""}`.trim()]:(e.comp&&t.push(`kaggle ${e.comp}`),t)}export function baselineChip(e,t){const n=(e.baseline||"").trim();if(!n)return"";if("none"===n)return t?"📊 无 baseline — 特征要你自己建(见下)":"📊 no baseline — you build the features (below)";if("pack"===n)return t?"📊 官方 baseline.ipynb 在数据包里":"📊 the pack ships the official baseline.ipynb";const i=t?`📊 开箱 baseline ${n}`:`📊 out-of-the-box baseline ${n}`;return/\b0\.(0\d|1\d|2\d)/.test(n)||/\b0\.000/.test(n)?i+(t?" — 线性模型对这题本就无效,不是坏了":" — a linear model cannot express this task; not a bug"):i}export function computeChip(e,t){return e.needs_gpu?t?"⚡ 数据大/训练重 · GPU 可选 —— baseline 本机就能跑":"⚡ heavy (GPU optional) the baseline still runs on your laptop":t?"💻 CPU 可做 · 现在就能开":"💻 CPU is enough · start now"}function s(e,t){switch(e){case"audio":return t?"本机 aienv:scipy.io.wavfile.read → numpy → scipy.signal 求谱(没有 librosa)· GPU 箱上 librosa/torchaudio 都有":"on your laptop: scipy.io.wavfile.read → numpy → scipy.signal (no librosa here) · on the GPU box librosa/torchaudio both exist";case"image":return t?"PIL.Image.open 读图 → numpy":"PIL.Image.open → numpy";case"weights":return t?"torch.load(..., weights_only=True) 读权重(输入就是模型)":"torch.load(..., weights_only=True) — the model IS the input here";default:return t?"先解开包里的压缩档再读":"unpack the archive inside the pack first"}}export function mediaHelpLines(e,t){const n=e.media;if(!n)return[];const i="audio"===n.kind?t?"音频":"audio":"image"===n.kind?t?"图片":"images":"weights"===n.kind?t?"模型权重":"model weights":t?"附件档":"an archive",a="none"===(e.baseline||"").trim()?t?`⚠ 这题的信号在${i}里,CSV 只有 id 和标签 —— 通用 starter 会在第 3 格停下。`:`⚠ The signal is in the ${i}; the CSVs carry only ids and labels — the generic starter stops at cell 3.`:t?`⚠ 真信号在${i}里。只喂 CSV 也能跑完,但分数接近瞎猜(${e.baseline})。`:`⚠ The real signal is in the ${i}. CSV-only does finish, but scores near chance (${e.baseline}).`;return t?[a,`▸ 先拉数据(${n.mb}MB):teleload ${n.pack}`,`▸ 然后把 FEATURES 那一格换成:${s(n.kind,!0)}`,...n.glob?[` 文件在 <数据目录>/${n.glob}`]:[]]:[a,`▸ Pull it first (${n.mb}MB): teleload ${n.pack}`,`▸ Then replace the FEATURES cell: ${s(n.kind,!1)}`,...n.glob?[` files live at <data dir>/${n.glob}`]:[]]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icoa-cli",
3
- "version": "2.19.449",
3
+ "version": "2.19.450",
4
4
  "description": "ICOA CLI — The world's first CLI-native cyber & AI security olympiad terminal: AI4CTF (Day 1), CTF4AI (Day 2), VLA4CTF (Pioneer Round — embodied AI)",
5
5
  "type": "module",
6
6
  "bin": {