Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
attempt fix
Browse files
ui/src/app/api/hf-hub/route.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import { NextRequest, NextResponse } from 'next/server';
|
| 2 |
import { whoAmI, createRepo, uploadFiles, datasetInfo } from '@huggingface/hub';
|
| 3 |
-
import { readdir, stat } from 'fs/promises';
|
| 4 |
-
import { createReadStream } from 'fs';
|
| 5 |
import path from 'path';
|
| 6 |
|
| 7 |
export async function POST(request: NextRequest) {
|
|
@@ -64,7 +63,7 @@ export async function POST(request: NextRequest) {
|
|
| 64 |
|
| 65 |
const normalizeRepoPath = (value: string) => value.replace(/\\/g, '/').replace(/^\/+/, '');
|
| 66 |
|
| 67 |
-
const addUploadContent = (repoFilePath: string, content:
|
| 68 |
const normalizedRepoPath = normalizeRepoPath(repoFilePath);
|
| 69 |
if (!normalizedRepoPath || uploadedPaths.has(normalizedRepoPath)) {
|
| 70 |
return;
|
|
@@ -74,7 +73,9 @@ export async function POST(request: NextRequest) {
|
|
| 74 |
};
|
| 75 |
|
| 76 |
const addUploadFile = async (absolutePath: string, repoFilePath: string) => {
|
| 77 |
-
|
|
|
|
|
|
|
| 78 |
};
|
| 79 |
|
| 80 |
const walkDirectory = async (basePath: string, repoPrefix: string) => {
|
|
@@ -141,7 +142,10 @@ export async function POST(request: NextRequest) {
|
|
| 141 |
}
|
| 142 |
|
| 143 |
if (manifest) {
|
| 144 |
-
|
|
|
|
|
|
|
|
|
|
| 145 |
}
|
| 146 |
|
| 147 |
if (filesToUpload.length === 0) {
|
|
|
|
| 1 |
import { NextRequest, NextResponse } from 'next/server';
|
| 2 |
import { whoAmI, createRepo, uploadFiles, datasetInfo } from '@huggingface/hub';
|
| 3 |
+
import { readdir, stat, readFile } from 'fs/promises';
|
|
|
|
| 4 |
import path from 'path';
|
| 5 |
|
| 6 |
export async function POST(request: NextRequest) {
|
|
|
|
| 63 |
|
| 64 |
const normalizeRepoPath = (value: string) => value.replace(/\\/g, '/').replace(/^\/+/, '');
|
| 65 |
|
| 66 |
+
const addUploadContent = (repoFilePath: string, content: Blob) => {
|
| 67 |
const normalizedRepoPath = normalizeRepoPath(repoFilePath);
|
| 68 |
if (!normalizedRepoPath || uploadedPaths.has(normalizedRepoPath)) {
|
| 69 |
return;
|
|
|
|
| 73 |
};
|
| 74 |
|
| 75 |
const addUploadFile = async (absolutePath: string, repoFilePath: string) => {
|
| 76 |
+
const buffer = await readFile(absolutePath);
|
| 77 |
+
const file = new File([buffer], path.basename(absolutePath));
|
| 78 |
+
addUploadContent(repoFilePath, file);
|
| 79 |
};
|
| 80 |
|
| 81 |
const walkDirectory = async (basePath: string, repoPrefix: string) => {
|
|
|
|
| 142 |
}
|
| 143 |
|
| 144 |
if (manifest) {
|
| 145 |
+
const manifestBlob = new Blob([
|
| 146 |
+
JSON.stringify(manifest, null, 2)
|
| 147 |
+
], { type: 'application/json' });
|
| 148 |
+
addUploadContent('manifest.json', manifestBlob);
|
| 149 |
}
|
| 150 |
|
| 151 |
if (filesToUpload.length === 0) {
|