Skip to content

Commit c87b481

Browse files
authored
👷 Fix deno test (#617)
Co-authored-by: coyotte508 <[email protected]>
1 parent e16e823 commit c87b481

File tree

4 files changed

+17
-3
lines changed

4 files changed

+17
-3
lines changed

‎.github/workflows/test.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ jobs:
8989
deno-version: vx.x.x
9090
- name: E2E test - deno import from npm
9191
working-directory: e2e/deno
92-
run: deno run --allow-net index.ts
92+
run: deno run --allow-net --allow-env=HF_TOKEN index.ts
9393
env:
9494
NPM_CONFIG_REGISTRY: http://localhost:4874/
95+
HF_TOKEN: ${{ secrets.HF_TOKEN }}

‎.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,7 @@
1111
"json.format.enable": false,
1212
"[json]": {
1313
"editor.defaultFormatter": "esbenp.prettier-vscode"
14-
}
14+
},
15+
"cSpell.words": ["huggingface"],
16+
"deno.enablePaths": ["./e2e/deno"]
1517
}

‎e2e/deno/index.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
11
import { HfInference } from "npm:@huggingface/inference@*";
22
import { whoAmI, listFiles } from "npm:@huggingface/hub@*";
33

4-
const hf = new HfInference();
4+
const token = Deno.env.get("HF_TOKEN");
5+
6+
if (!token) {
7+
console.error("Please set the HF_TOKEN environment variable.");
8+
Deno.exit(1);
9+
}
510

611
const info = await whoAmI({ credentials: { accessToken: "hf_hub.js" }, hubUrl: "https://hub-ci.huggingface.co" });
712
console.log(info);
@@ -10,6 +15,11 @@ for await (const file of listFiles({ credentials: { accessToken: "hf_hub.js" },
1015
console.log(file);
1116
}
1217

18+
const hf = new HfInference(token);
19+
20+
const tokenInfo = await whoAmI({ credentials: { accessToken: token } });
21+
console.log(tokenInfo);
22+
1323
const sum = await hf.summarization({
1424
model: "facebook/bart-large-cnn",
1525
inputs:

‎e2e/ts/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock.json

0 commit comments

Comments
 (0)