Skip to content
Open
Show file tree
Hide file tree
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
3 changes: 0 additions & 3 deletions src/constants/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export const FIREBASE_CONFIG = {

//firestore collection names
export const FIRESTORE_COLLECTIONS = {
RESULTS: "results",
RECIPES: "recipes",
CONFIGS: "configs",
OBJECTS: "objects",
Expand All @@ -22,8 +21,6 @@ export const FIRESTORE_COLLECTIONS = {
//firestore field names
export const FIRESTORE_FIELDS = {
NAME: "name",
BATCH_JOB_ID: "batch_job_id",
ORIGINAL_LOCATION: "original_location",
RECIPE_PATH: "recipe_path",
INHERIT: "inherit",
COMPOSITION: "composition",
Expand Down
1 change: 0 additions & 1 deletion src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
export interface Document {
name?: string;
original_location?: string;
recipe_path?: string;
recipe?: string;
config?: string;
Expand Down
7 changes: 3 additions & 4 deletions src/utils/aws.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import JSZip from "jszip";
import { getOutputsDirectory } from "./firebase";
import { getJobStatus } from "./firebase";
import { getS3ListUrl } from "../constants/aws";


Expand Down Expand Up @@ -80,9 +80,8 @@ export const downloadOutputsFromS3 = async (outputsDir: string, jobId: string) =

export const downloadOutputs = async (jobId: string, outputsDir?: string) => {
if (!outputsDir) {
// If uploading result files took too long, outputDir may not have been
// set when the job completed. Fetch it from Firestore.
outputsDir = await getOutputsDirectory(jobId);
const jobStatus = await getJobStatus(jobId);
outputsDir = jobStatus?.outputs_directory ?? "";
}
await downloadOutputsFromS3(outputsDir, jobId);
}
20 changes: 0 additions & 20 deletions src/utils/firebase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,17 +98,6 @@ const mapQuerySnapshotToDocs = (querySnapshot: QuerySnapshot<DocumentData>) => {
})) as FirestoreDoc[];
};

const extractSingleDocumentData = (
querySnapshot: QuerySnapshot<DocumentData>,
field?: string
) => {
let result = "";
querySnapshot.forEach((doc) => {
result = field ? doc.data()[field] : doc.data();
});
return result;
};

// Query functions for our use case using generic functions
const getJobStatus = async (
jobId: string
Expand All @@ -126,14 +115,6 @@ const getJobStatus = async (
return docs[0] || undefined;
};

const getOutputsDirectory = async (jobId: string) => {
const querySnapshot = await queryDocumentById(
FIRESTORE_COLLECTIONS.JOB_STATUS,
jobId
);
return extractSingleDocumentData(querySnapshot, "outputs_directory");
};

const getAllDocsFromCollection = async (collectionName: string) => {
const querySnapshot = await queryAllDocuments(collectionName);
return mapQuerySnapshotToDocs(querySnapshot);
Expand Down Expand Up @@ -283,5 +264,4 @@ export {
docCleanup,
getRecipeManifestFromFirebase,
getRecipeDataFromFirebase,
getOutputsDirectory,
};