Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flav/create fake doc script #11543

Merged
merged 3 commits into from
Mar 29, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions front/scripts/upload_fake_data_source_document.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { getDustDataSourcesBucket } from "@app/lib/file_storage";
import { makeScript } from "@app/scripts/helpers";

const fakeDocument = {
document_id: "not_found",
full_text: "",
sections: {
prefix: null,
content: null,
sections: [],
},
};

// Some data sources don't have a proper document in GCS, this script uploads a fake one.
// Relocation workflows expect a document to be present in GCS for each data source document.
makeScript(
{
path: {
type: "string",
demandOption: true,
},
},
async ({ path, execute }, logger) => {
const fileStorage = getDustDataSourcesBucket();

if (execute) {
await fileStorage
.file(path)
.save(Buffer.from(JSON.stringify(fakeDocument, null, 2)), {
contentType: "application/json",
});

logger.info(
`Successfully uploaded fake document to gs://${fileStorage.name}/${path}`
);
} else {
logger.info(
`About to upload fake document to gs://${fileStorage.name}/${path}`
);
}
}
);
Loading