From de048e0d6eb6c1dd6225b0d09daffa2e1107c8fc Mon Sep 17 00:00:00 2001 From: coyotte508 Date: Tue, 3 Dec 2024 14:30:50 +0100 Subject: [PATCH] run prettier everywhere --- .github/workflows/dduf-publish.yml | 1 - packages/dduf/src/check-dduf.ts | 5 +- packages/hub/src/lib/cache-management.ts | 2 +- packages/hub/src/lib/dataset-info.spec.ts | 10 +- packages/hub/src/lib/dataset-info.ts | 4 +- .../lib/download-file-to-cache-dir.spec.ts | 152 ++++++++++-------- .../hub/src/lib/download-file-to-cache-dir.ts | 4 +- packages/hub/src/lib/download-file.spec.ts | 22 +-- packages/hub/src/lib/model-info.spec.ts | 6 +- packages/hub/src/lib/model-info.ts | 4 +- packages/hub/src/lib/paths-info.spec.ts | 10 +- packages/hub/src/lib/paths-info.ts | 62 +++---- packages/hub/src/lib/space-info.spec.ts | 14 +- packages/hub/src/lib/space-info.ts | 4 +- packages/tasks-gen/.prettierignore | 5 + packages/tasks-gen/README.md | 2 +- 16 files changed, 166 insertions(+), 141 deletions(-) create mode 100644 packages/tasks-gen/.prettierignore diff --git a/.github/workflows/dduf-publish.yml b/.github/workflows/dduf-publish.yml index b0a9115a5..8d543d03e 100644 --- a/.github/workflows/dduf-publish.yml +++ b/.github/workflows/dduf-publish.yml @@ -50,7 +50,6 @@ jobs: git commit . -m "🔖 @huggingface/dduf $BUMPED_VERSION" git tag "dduf-v$BUMPED_VERSION" - - name: "Check Deps are published before publishing this package" run: pnpm -w check-deps blob diff --git a/packages/dduf/src/check-dduf.ts b/packages/dduf/src/check-dduf.ts index 8bd04dca2..a4f17a959 100644 --- a/packages/dduf/src/check-dduf.ts +++ b/packages/dduf/src/check-dduf.ts @@ -8,10 +8,7 @@ export interface DDUFFileEntry { fileHeaderOffset: number; } -export async function* checkDDUF( - url: Blob | URL, - opts?: { log?: (x: string) => void } -): AsyncGenerator { +export async function* checkDDUF(url: Blob | URL, opts?: { log?: (x: string) => void }): AsyncGenerator { const blob = url instanceof Blob ? url : await createBlob(url); opts?.log?.("File size: " + blob.size); diff --git a/packages/hub/src/lib/cache-management.ts b/packages/hub/src/lib/cache-management.ts index 98c3be5b4..84b664077 100644 --- a/packages/hub/src/lib/cache-management.ts +++ b/packages/hub/src/lib/cache-management.ts @@ -25,7 +25,7 @@ const FILES_TO_IGNORE: string[] = [".DS_Store"]; export const REPO_ID_SEPARATOR: string = "--"; export function getRepoFolderName({ name, type }: RepoId): string { - const parts = [`${type}s`, ...name.split("/")] + const parts = [`${type}s`, ...name.split("/")]; return parts.join(REPO_ID_SEPARATOR); } diff --git a/packages/hub/src/lib/dataset-info.spec.ts b/packages/hub/src/lib/dataset-info.spec.ts index 982bdcf40..ae235e5e8 100644 --- a/packages/hub/src/lib/dataset-info.spec.ts +++ b/packages/hub/src/lib/dataset-info.spec.ts @@ -20,9 +20,9 @@ describe("datasetInfo", () => { }); it("should return the dataset info with author", async () => { - const info: DatasetEntry & Pick = await datasetInfo({ + const info: DatasetEntry & Pick = await datasetInfo({ name: "nyu-mll/glue", - additionalFields: ['author'], + additionalFields: ["author"], }); expect(info).toEqual({ id: "621ffdd236468d709f181e3f", @@ -32,12 +32,12 @@ describe("datasetInfo", () => { updatedAt: expect.any(Date), likes: expect.any(Number), private: false, - author: 'nyu-mll' + author: "nyu-mll", }); }); it("should return the dataset info for a specific revision", async () => { - const info: DatasetEntry & Pick = await datasetInfo({ + const info: DatasetEntry & Pick = await datasetInfo({ name: "nyu-mll/glue", revision: "cb2099c76426ff97da7aa591cbd317d91fb5fcb7", additionalFields: ["sha"], @@ -50,7 +50,7 @@ describe("datasetInfo", () => { updatedAt: expect.any(Date), likes: expect.any(Number), private: false, - sha: 'cb2099c76426ff97da7aa591cbd317d91fb5fcb7' + sha: "cb2099c76426ff97da7aa591cbd317d91fb5fcb7", }); }); }); diff --git a/packages/hub/src/lib/dataset-info.ts b/packages/hub/src/lib/dataset-info.ts index bb62df7f8..542b5aa0f 100644 --- a/packages/hub/src/lib/dataset-info.ts +++ b/packages/hub/src/lib/dataset-info.ts @@ -31,7 +31,9 @@ export async function datasetInfo< ]).toString(); const response = await (params.fetch || fetch)( - `${params?.hubUrl || HUB_URL}/api/datasets/${params.name}/revision/${encodeURIComponent(params.revision ?? "HEAD")}?${search.toString()}`, + `${params?.hubUrl || HUB_URL}/api/datasets/${params.name}/revision/${encodeURIComponent( + params.revision ?? "HEAD" + )}?${search.toString()}`, { headers: { ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}), diff --git a/packages/hub/src/lib/download-file-to-cache-dir.spec.ts b/packages/hub/src/lib/download-file-to-cache-dir.spec.ts index 05e2e6de9..879a4d406 100644 --- a/packages/hub/src/lib/download-file-to-cache-dir.spec.ts +++ b/packages/hub/src/lib/download-file-to-cache-dir.spec.ts @@ -8,46 +8,52 @@ import { getHFHubCachePath, getRepoFolderName } from "./cache-management"; import { toRepoId } from "../utils/toRepoId"; import { downloadFileToCacheDir } from "./download-file-to-cache-dir"; -vi.mock('node:fs/promises', () => ({ +vi.mock("node:fs/promises", () => ({ writeFile: vi.fn(), rename: vi.fn(), symlink: vi.fn(), lstat: vi.fn(), mkdir: vi.fn(), - stat: vi.fn() + stat: vi.fn(), })); -vi.mock('./paths-info', () => ({ +vi.mock("./paths-info", () => ({ pathsInfo: vi.fn(), })); const DUMMY_REPO: RepoId = { - name: 'hello-world', - type: 'model', + name: "hello-world", + type: "model", }; const DUMMY_ETAG = "dummy-etag"; // utility test method to get blob file path -function _getBlobFile(params: { +function _getBlobFile(params: { repo: RepoDesignation; etag: string; - cacheDir?: string, // default to {@link getHFHubCache} + cacheDir?: string; // default to {@link getHFHubCache} }) { return join(params.cacheDir ?? getHFHubCachePath(), getRepoFolderName(toRepoId(params.repo)), "blobs", params.etag); } // utility test method to get snapshot file path -function _getSnapshotFile(params: { +function _getSnapshotFile(params: { repo: RepoDesignation; path: string; - revision : string; - cacheDir?: string, // default to {@link getHFHubCache} + revision: string; + cacheDir?: string; // default to {@link getHFHubCache} }) { - return join(params.cacheDir ?? getHFHubCachePath(), getRepoFolderName(toRepoId(params.repo)), "snapshots", params.revision, params.path); + return join( + params.cacheDir ?? getHFHubCachePath(), + getRepoFolderName(toRepoId(params.repo)), + "snapshots", + params.revision, + params.path + ); } -describe('downloadFileToCacheDir', () => { +describe("downloadFileToCacheDir", () => { const fetchMock: typeof fetch = vi.fn(); beforeEach(() => { vi.resetAllMocks(); @@ -55,43 +61,45 @@ describe('downloadFileToCacheDir', () => { vi.mocked(fetchMock).mockResolvedValue({ status: 200, ok: true, - body: 'dummy-body' + body: "dummy-body", } as unknown as Response); // prevent to use caching - vi.mocked(stat).mockRejectedValue(new Error('Do not exists')); - vi.mocked(lstat).mockRejectedValue(new Error('Do not exists')); + vi.mocked(stat).mockRejectedValue(new Error("Do not exists")); + vi.mocked(lstat).mockRejectedValue(new Error("Do not exists")); }); - test('should throw an error if fileDownloadInfo return nothing', async () => { + test("should throw an error if fileDownloadInfo return nothing", async () => { await expect(async () => { await downloadFileToCacheDir({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", fetch: fetchMock, }); - }).rejects.toThrowError('cannot get path info for /README.md'); + }).rejects.toThrowError("cannot get path info for /README.md"); - expect(pathsInfo).toHaveBeenCalledWith(expect.objectContaining({ - repo: DUMMY_REPO, - paths: ['/README.md'], - fetch: fetchMock, - })); + expect(pathsInfo).toHaveBeenCalledWith( + expect.objectContaining({ + repo: DUMMY_REPO, + paths: ["/README.md"], + fetch: fetchMock, + }) + ); }); - test('existing symlinked and blob should not re-download it', async () => { + test("existing symlinked and blob should not re-download it", async () => { // ///snapshots/README.md const expectPointer = _getSnapshotFile({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", revision: "dd4bc8b21efa05ec961e3efc4ee5e3832a3679c7", }); // stat ensure a symlink and the pointed file exists - vi.mocked(stat).mockResolvedValue({} as Stats) // prevent default mocked reject + vi.mocked(stat).mockResolvedValue({} as Stats); // prevent default mocked reject const output = await downloadFileToCacheDir({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", fetch: fetchMock, revision: "dd4bc8b21efa05ec961e3efc4ee5e3832a3679c7", }); @@ -100,17 +108,17 @@ describe('downloadFileToCacheDir', () => { // Get call argument for stat const starArg = vi.mocked(stat).mock.calls[0][0]; - expect(starArg).toBe(expectPointer) + expect(starArg).toBe(expectPointer); expect(fetchMock).not.toHaveBeenCalledWith(); expect(output).toBe(expectPointer); }); - test('existing blob should only create the symlink', async () => { + test("existing blob should only create the symlink", async () => { // ///snapshots/README.md const expectPointer = _getSnapshotFile({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", revision: "dummy-commit-hash", }); // //blobs/ @@ -122,21 +130,23 @@ describe('downloadFileToCacheDir', () => { // mock existing blob only no symlink vi.mocked(lstat).mockResolvedValue({} as Stats); // mock pathsInfo resolve content - vi.mocked(pathsInfo).mockResolvedValue([{ - oid: DUMMY_ETAG, - size: 55, - path: 'README.md', - type: 'file', - lastCommit: { - date: new Date(), - id: 'dummy-commit-hash', - title: 'Commit msg', + vi.mocked(pathsInfo).mockResolvedValue([ + { + oid: DUMMY_ETAG, + size: 55, + path: "README.md", + type: "file", + lastCommit: { + date: new Date(), + id: "dummy-commit-hash", + title: "Commit msg", + }, }, - }]); + ]); const output = await downloadFileToCacheDir({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", fetch: fetchMock, }); @@ -153,11 +163,11 @@ describe('downloadFileToCacheDir', () => { expect(output).toBe(expectPointer); }); - test('expect resolve value to be the pointer path of downloaded file', async () => { + test("expect resolve value to be the pointer path of downloaded file", async () => { // ///snapshots/README.md const expectPointer = _getSnapshotFile({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", revision: "dummy-commit-hash", }); // //blobs/ @@ -166,21 +176,23 @@ describe('downloadFileToCacheDir', () => { etag: DUMMY_ETAG, }); - vi.mocked(pathsInfo).mockResolvedValue([{ - oid: DUMMY_ETAG, - size: 55, - path: 'README.md', - type: 'file', - lastCommit: { - date: new Date(), - id: 'dummy-commit-hash', - title: 'Commit msg', + vi.mocked(pathsInfo).mockResolvedValue([ + { + oid: DUMMY_ETAG, + size: 55, + path: "README.md", + type: "file", + lastCommit: { + date: new Date(), + id: "dummy-commit-hash", + title: "Commit msg", + }, }, - }]); + ]); const output = await downloadFileToCacheDir({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", fetch: fetchMock, }); @@ -191,11 +203,11 @@ describe('downloadFileToCacheDir', () => { expect(output).toBe(expectPointer); }); - test('should write fetch response to blob', async () => { + test("should write fetch response to blob", async () => { // ///snapshots/README.md const expectPointer = _getSnapshotFile({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", revision: "dummy-commit-hash", }); // //blobs/ @@ -205,30 +217,32 @@ describe('downloadFileToCacheDir', () => { }); // mock pathsInfo resolve content - vi.mocked(pathsInfo).mockResolvedValue([{ - oid: DUMMY_ETAG, - size: 55, - path: 'README.md', - type: 'file', - lastCommit: { - date: new Date(), - id: 'dummy-commit-hash', - title: 'Commit msg', + vi.mocked(pathsInfo).mockResolvedValue([ + { + oid: DUMMY_ETAG, + size: 55, + path: "README.md", + type: "file", + lastCommit: { + date: new Date(), + id: "dummy-commit-hash", + title: "Commit msg", + }, }, - }]); + ]); await downloadFileToCacheDir({ repo: DUMMY_REPO, - path: '/README.md', + path: "/README.md", fetch: fetchMock, }); const incomplete = `${expectedBlob}.incomplete`; // 1. should write fetch#response#body to incomplete file - expect(writeFile).toHaveBeenCalledWith(incomplete, 'dummy-body'); + expect(writeFile).toHaveBeenCalledWith(incomplete, "dummy-body"); // 2. should rename the incomplete to the blob expected name expect(rename).toHaveBeenCalledWith(incomplete, expectedBlob); // 3. should create symlink pointing to blob expect(symlink).toHaveBeenCalledWith(expectedBlob, expectPointer); }); -}); \ No newline at end of file +}); diff --git a/packages/hub/src/lib/download-file-to-cache-dir.ts b/packages/hub/src/lib/download-file-to-cache-dir.ts index 72869f307..92c4edbf0 100644 --- a/packages/hub/src/lib/download-file-to-cache-dir.ts +++ b/packages/hub/src/lib/download-file-to-cache-dir.ts @@ -21,7 +21,7 @@ function getFilePointer(storageFolder: string, revision: string, relativeFilenam */ async function exists(path: string, followSymlinks?: boolean): Promise { try { - if(followSymlinks) { + if (followSymlinks) { await stat(path); } else { await lstat(path); @@ -54,7 +54,7 @@ export async function downloadFileToCacheDir( */ revision?: string; hubUrl?: string; - cacheDir?: string, + cacheDir?: string; /** * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. */ diff --git a/packages/hub/src/lib/download-file.spec.ts b/packages/hub/src/lib/download-file.spec.ts index f442f152a..01fc64c94 100644 --- a/packages/hub/src/lib/download-file.spec.ts +++ b/packages/hub/src/lib/download-file.spec.ts @@ -3,8 +3,8 @@ import { downloadFile } from "./download-file"; import type { RepoId } from "../types/public"; const DUMMY_REPO: RepoId = { - name: 'hello-world', - type: 'model', + name: "hello-world", + type: "model", }; describe("downloadFile", () => { @@ -17,12 +17,12 @@ describe("downloadFile", () => { await downloadFile({ repo: DUMMY_REPO, - path: '/README.md', - hubUrl: 'http://dummy-hub', + path: "/README.md", + hubUrl: "http://dummy-hub", fetch: fetchMock, }); - expect(fetchMock).toHaveBeenCalledWith('http://dummy-hub/hello-world/resolve/main//README.md', expect.anything()); + expect(fetchMock).toHaveBeenCalledWith("http://dummy-hub/hello-world/resolve/main//README.md", expect.anything()); }); test("raw params should use raw url", async () => { @@ -34,12 +34,12 @@ describe("downloadFile", () => { await downloadFile({ repo: DUMMY_REPO, - path: 'README.md', + path: "README.md", raw: true, fetch: fetchMock, }); - expect(fetchMock).toHaveBeenCalledWith('https://huggingface.co/hello-world/raw/main/README.md', expect.anything()); + expect(fetchMock).toHaveBeenCalledWith("https://huggingface.co/hello-world/raw/main/README.md", expect.anything()); }); test("internal server error should propagate the error", async () => { @@ -49,17 +49,17 @@ describe("downloadFile", () => { ok: false, headers: new Map([["Content-Type", "application/json"]]), json: () => ({ - error: 'Dummy internal error', + error: "Dummy internal error", }), } as unknown as Response); await expect(async () => { await downloadFile({ repo: DUMMY_REPO, - path: 'README.md', + path: "README.md", raw: true, fetch: fetchMock, }); - }).rejects.toThrowError('Dummy internal error'); + }).rejects.toThrowError("Dummy internal error"); }); -}); \ No newline at end of file +}); diff --git a/packages/hub/src/lib/model-info.spec.ts b/packages/hub/src/lib/model-info.spec.ts index 3886f3039..3657e964d 100644 --- a/packages/hub/src/lib/model-info.spec.ts +++ b/packages/hub/src/lib/model-info.spec.ts @@ -21,7 +21,7 @@ describe("modelInfo", () => { }); it("should return the model info with author", async () => { - const info: ModelEntry & Pick = await modelInfo({ + const info: ModelEntry & Pick = await modelInfo({ name: "openai-community/gpt2", additionalFields: ["author"], }); @@ -39,10 +39,10 @@ describe("modelInfo", () => { }); it("should return the model info for a specific revision", async () => { - const info: ModelEntry & Pick = await modelInfo({ + const info: ModelEntry & Pick = await modelInfo({ name: "openai-community/gpt2", additionalFields: ["sha"], - revision: 'f27b190eeac4c2302d24068eabf5e9d6044389ae', + revision: "f27b190eeac4c2302d24068eabf5e9d6044389ae", }); expect(info).toEqual({ id: "621ffdc036468d709f17434d", diff --git a/packages/hub/src/lib/model-info.ts b/packages/hub/src/lib/model-info.ts index 828322e67..4e4291c3b 100644 --- a/packages/hub/src/lib/model-info.ts +++ b/packages/hub/src/lib/model-info.ts @@ -31,7 +31,9 @@ export async function modelInfo< ]).toString(); const response = await (params.fetch || fetch)( - `${params?.hubUrl || HUB_URL}/api/models/${params.name}/revision/${encodeURIComponent(params.revision ?? "HEAD")}?${search.toString()}`, + `${params?.hubUrl || HUB_URL}/api/models/${params.name}/revision/${encodeURIComponent( + params.revision ?? "HEAD" + )}?${search.toString()}`, { headers: { ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}), diff --git a/packages/hub/src/lib/paths-info.spec.ts b/packages/hub/src/lib/paths-info.spec.ts index 994d623ae..837f4a192 100644 --- a/packages/hub/src/lib/paths-info.spec.ts +++ b/packages/hub/src/lib/paths-info.spec.ts @@ -16,8 +16,8 @@ describe("pathsInfo", () => { expect(result).toHaveLength(1); const modelPathInfo = result[0]; - expect(modelPathInfo.path).toBe('tf_model.h5'); - expect(modelPathInfo.type).toBe('file'); + expect(modelPathInfo.path).toBe("tf_model.h5"); + expect(modelPathInfo.type).toBe("file"); // lfs pointer, therefore lfs should be defined expect(modelPathInfo?.lfs).toBeDefined(); expect(modelPathInfo?.lfs?.oid).toBe("a7a17d6d844b5de815ccab5f42cad6d24496db3850a2a43d8258221018ce87d2"); @@ -31,8 +31,8 @@ describe("pathsInfo", () => { it("expand parmas should fetch lastCommit and securityFileStatus", async () => { const result: (PathInfo & { - lastCommit: CommitInfo, - securityFileStatus: SecurityFileStatus, + lastCommit: CommitInfo; + securityFileStatus: SecurityFileStatus; })[] = await pathsInfo({ repo: { name: "bert-base-uncased", @@ -57,7 +57,7 @@ describe("pathsInfo", () => { }); it("non-LFS pointer should have lfs undefined", async () => { - const result: (PathInfo)[] = await pathsInfo({ + const result: PathInfo[] = await pathsInfo({ repo: { name: "bert-base-uncased", type: "model", diff --git a/packages/hub/src/lib/paths-info.ts b/packages/hub/src/lib/paths-info.ts index 4c9a1de20..c706768f1 100644 --- a/packages/hub/src/lib/paths-info.ts +++ b/packages/hub/src/lib/paths-info.ts @@ -5,32 +5,32 @@ import { HUB_URL } from "../consts"; import { createApiError } from "../error"; export interface LfsPathInfo { - "oid": string, - "size": number, - "pointerSize": number + oid: string; + size: number; + pointerSize: number; } -export interface CommitInfo { - "id": string, - "title": string, - "date": Date, +export interface CommitInfo { + id: string; + title: string; + date: Date; } export interface SecurityFileStatus { - "status": string, + status: string; } export interface PathInfo { - path: string, - type: string, - oid: string, - size: number, + path: string; + type: string; + oid: string; + size: number; /** * Only defined when path is LFS pointer */ - lfs?: LfsPathInfo, - lastCommit?: CommitInfo, - securityFileStatus?: SecurityFileStatus + lfs?: LfsPathInfo; + lastCommit?: CommitInfo; + securityFileStatus?: SecurityFileStatus; } // Define the overloaded signatures @@ -45,8 +45,8 @@ export function pathsInfo( * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. */ fetch?: typeof fetch; - } & Partial -): Promise<(PathInfo & {lastCommit: CommitInfo, securityFileStatus: SecurityFileStatus })[]>; + } & Partial +): Promise<(PathInfo & { lastCommit: CommitInfo; securityFileStatus: SecurityFileStatus })[]>; export function pathsInfo( params: { repo: RepoDesignation; @@ -58,8 +58,8 @@ export function pathsInfo( * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. */ fetch?: typeof fetch; - } & Partial -): Promise<(PathInfo)[]>; + } & Partial +): Promise; export async function pathsInfo( params: { @@ -72,14 +72,16 @@ export async function pathsInfo( * Custom fetch function to use instead of the default one, for example to use a proxy or edit headers. */ fetch?: typeof fetch; - } & Partial + } & Partial ): Promise { const accessToken = checkCredentials(params); const repoId = toRepoId(params.repo); const hubUrl = params.hubUrl ?? HUB_URL; - const url = `${hubUrl}/api/${repoId.type}s/${repoId.name}/paths-info/${encodeURIComponent(params.revision ?? "main")}`; + const url = `${hubUrl}/api/${repoId.type}s/${repoId.name}/paths-info/${encodeURIComponent( + params.revision ?? "main" + )}`; const resp = await (params.fetch ?? fetch)(url, { method: "POST", @@ -87,8 +89,8 @@ export async function pathsInfo( ...(params.credentials && { Authorization: `Bearer ${accessToken}`, }), - 'Accept': 'application/json', - 'Content-Type': 'application/json' + Accept: "application/json", + "Content-Type": "application/json", }, body: JSON.stringify({ paths: params.paths, @@ -101,7 +103,7 @@ export async function pathsInfo( } const json: unknown = await resp.json(); - if(!Array.isArray(json)) throw new Error('malformed response: expected array'); + if (!Array.isArray(json)) throw new Error("malformed response: expected array"); return json.map((item: PathInfo) => ({ path: item.path, @@ -111,10 +113,12 @@ export async function pathsInfo( size: item.size, // expand fields securityFileStatus: item.securityFileStatus, - lastCommit: item.lastCommit ? { - date: new Date(item.lastCommit.date), - title: item.lastCommit.title, - id: item.lastCommit.id, - }: undefined, + lastCommit: item.lastCommit + ? { + date: new Date(item.lastCommit.date), + title: item.lastCommit.title, + id: item.lastCommit.id, + } + : undefined, })); } diff --git a/packages/hub/src/lib/space-info.spec.ts b/packages/hub/src/lib/space-info.spec.ts index aafa9b88f..ea966f98b 100644 --- a/packages/hub/src/lib/space-info.spec.ts +++ b/packages/hub/src/lib/space-info.spec.ts @@ -19,9 +19,9 @@ describe("spaceInfo", () => { }); it("should return the space info with author", async () => { - const info: SpaceEntry & Pick = await spaceInfo({ + const info: SpaceEntry & Pick = await spaceInfo({ name: "huggingfacejs/client-side-oauth", - additionalFields: ['author'], + additionalFields: ["author"], }); expect(info).toEqual({ id: "659835e689010f9c7aed608d", @@ -30,15 +30,15 @@ describe("spaceInfo", () => { likes: expect.any(Number), private: false, sdk: "static", - author: 'huggingfacejs', + author: "huggingfacejs", }); }); it("should return the space info for a given revision", async () => { - const info: SpaceEntry & Pick = await spaceInfo({ + const info: SpaceEntry & Pick = await spaceInfo({ name: "huggingfacejs/client-side-oauth", - additionalFields: ['sha'], - revision: 'e410a9ff348e6bed393b847711e793282d7c672e' + additionalFields: ["sha"], + revision: "e410a9ff348e6bed393b847711e793282d7c672e", }); expect(info).toEqual({ id: "659835e689010f9c7aed608d", @@ -47,7 +47,7 @@ describe("spaceInfo", () => { likes: expect.any(Number), private: false, sdk: "static", - sha: 'e410a9ff348e6bed393b847711e793282d7c672e', + sha: "e410a9ff348e6bed393b847711e793282d7c672e", }); }); }); diff --git a/packages/hub/src/lib/space-info.ts b/packages/hub/src/lib/space-info.ts index fcbfee60d..942235382 100644 --- a/packages/hub/src/lib/space-info.ts +++ b/packages/hub/src/lib/space-info.ts @@ -32,7 +32,9 @@ export async function spaceInfo< ]).toString(); const response = await (params.fetch || fetch)( - `${params?.hubUrl || HUB_URL}/api/spaces/${params.name}/revision/${encodeURIComponent(params.revision ?? "HEAD")}?${search.toString()}`, + `${params?.hubUrl || HUB_URL}/api/spaces/${params.name}/revision/${encodeURIComponent( + params.revision ?? "HEAD" + )}?${search.toString()}`, { headers: { ...(accessToken ? { Authorization: `Bearer ${accessToken}` } : {}), diff --git a/packages/tasks-gen/.prettierignore b/packages/tasks-gen/.prettierignore new file mode 100644 index 000000000..cdbeac2bd --- /dev/null +++ b/packages/tasks-gen/.prettierignore @@ -0,0 +1,5 @@ +dist +snippets-fixtures +node_modules +README.md +pnpm-lock.yaml \ No newline at end of file diff --git a/packages/tasks-gen/README.md b/packages/tasks-gen/README.md index d78e62450..6adbe3211 100644 --- a/packages/tasks-gen/README.md +++ b/packages/tasks-gen/README.md @@ -14,6 +14,7 @@ pnpm generate-snippets-fixtures ``` If some logic has been updated, you should see the result with a + ``` git diff # the diff has to be committed if correct @@ -64,4 +65,3 @@ To update the specs manually, run: ``` pnpm inference-tgi-import ``` -