From c87b481dffcdb9be04dcaae6995883a508b95216 Mon Sep 17 00:00:00 2001 From: Eliott C Date: Wed, 10 Apr 2024 14:18:41 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=91=B7=20Fix=20deno=20test=20(#617)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: coyotte508 --- .github/workflows/test.yml | 3 ++- .vscode/settings.json | 4 +++- e2e/deno/index.ts | 12 +++++++++++- e2e/ts/.gitignore | 1 + 4 files changed, 17 insertions(+), 3 deletions(-) create mode 100644 e2e/ts/.gitignore diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 70e1e1257..158851022 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -89,6 +89,7 @@ jobs: deno-version: vx.x.x - name: E2E test - deno import from npm working-directory: e2e/deno - run: deno run --allow-net index.ts + run: deno run --allow-net --allow-env=HF_TOKEN index.ts env: NPM_CONFIG_REGISTRY: http://localhost:4874/ + HF_TOKEN: ${{ secrets.HF_TOKEN }} diff --git a/.vscode/settings.json b/.vscode/settings.json index 072ae9648..0d052137b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,5 +11,7 @@ "json.format.enable": false, "[json]": { "editor.defaultFormatter": "esbenp.prettier-vscode" - } + }, + "cSpell.words": ["huggingface"], + "deno.enablePaths": ["./e2e/deno"] } diff --git a/e2e/deno/index.ts b/e2e/deno/index.ts index 278484f8d..4181fd6a6 100644 --- a/e2e/deno/index.ts +++ b/e2e/deno/index.ts @@ -1,7 +1,12 @@ import { HfInference } from "npm:@huggingface/inference@*"; import { whoAmI, listFiles } from "npm:@huggingface/hub@*"; -const hf = new HfInference(); +const token = Deno.env.get("HF_TOKEN"); + +if (!token) { + console.error("Please set the HF_TOKEN environment variable."); + Deno.exit(1); +} const info = await whoAmI({ credentials: { accessToken: "hf_hub.js" }, hubUrl: "https://hub-ci.huggingface.co" }); console.log(info); @@ -10,6 +15,11 @@ for await (const file of listFiles({ credentials: { accessToken: "hf_hub.js" }, console.log(file); } +const hf = new HfInference(token); + +const tokenInfo = await whoAmI({ credentials: { accessToken: token } }); +console.log(tokenInfo); + const sum = await hf.summarization({ model: "facebook/bart-large-cnn", inputs: diff --git a/e2e/ts/.gitignore b/e2e/ts/.gitignore new file mode 100644 index 000000000..483a9c42c --- /dev/null +++ b/e2e/ts/.gitignore @@ -0,0 +1 @@ +package-lock.json \ No newline at end of file