Skip to content

Commit

Permalink
💚 No failing tests when external pull requests (#684)
Browse files Browse the repository at this point in the history
  • Loading branch information
coyotte508 committed May 18, 2024
1 parent 9a4d4e2 commit 4805fce
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 31 deletions.
40 changes: 18 additions & 22 deletions e2e/deno/index.ts
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
import { HfInference } from "npm:@huggingface/inference@*";
import { whoAmI, listFiles } from "npm:@huggingface/hub@*";

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);

for await (const file of listFiles({ credentials: { accessToken: "hf_hub.js" }, repo: "gpt2" })) {
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:
"The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930.",
parameters: {
max_length: 100,
},
});

console.log(sum);
const token = Deno.env.get("HF_TOKEN");
if (token) {
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:
"The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930.",
parameters: {
max_length: 100,
},
});

console.log(sum);
}
20 changes: 11 additions & 9 deletions e2e/ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ const hf = new HfInference(hfToken);
const info = await whoAmI({ credentials: { accessToken: "hf_hub.js" }, hubUrl: "https://hub-ci.huggingface.co" });
console.log(info);

const sum = await hf.summarization({
model: "facebook/bart-large-cnn",
inputs:
"The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930.",
parameters: {
max_length: 100,
},
});
if (hfToken) {
const sum = await hf.summarization({
model: "facebook/bart-large-cnn",
inputs:
"The tower is 324 metres (1,063 ft) tall, about the same height as an 81-storey building, and the tallest structure in Paris. Its base is square, measuring 125 metres (410 ft) on each side. During its construction, the Eiffel Tower surpassed the Washington Monument to become the tallest man-made structure in the world, a title it held for 41 years until the Chrysler Building in New York City was finished in 1930.",
parameters: {
max_length: 100,
},
});

console.log(sum);
console.log(sum);
}
})();
4 changes: 4 additions & 0 deletions packages/hub/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,7 @@ export type {
SpaceStage,
} from "./types/public";
export { HubApiError, InvalidApiResponseFormatError } from "./error";
/**
* Only exported for E2Es convenience
*/
export { sha256 as __internal_sha256 } from "./utils/sha256";

0 comments on commit 4805fce

Please sign in to comment.