Skip to content

Commit

Permalink
👷 Fix deno test (#617)
Browse files Browse the repository at this point in the history
Co-authored-by: coyotte508 <[email protected]>
  • Loading branch information
coyotte508 and coyotte508 authored Apr 10, 2024
1 parent e16e823 commit c87b481
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@
"json.format.enable": false,
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
}
},
"cSpell.words": ["huggingface"],
"deno.enablePaths": ["./e2e/deno"]
}
12 changes: 11 additions & 1 deletion e2e/deno/index.ts
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions e2e/ts/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock.json

0 comments on commit c87b481

Please sign in to comment.