Skip to content

Commit

Permalink
Updated infer's interior promises to mutate attributes directly
Browse files Browse the repository at this point in the history
  • Loading branch information
lancegliser committed Sep 26, 2024
1 parent a8f1c5b commit b09498c
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/features/sources/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,18 @@ export abstract class InferFeatureAttributesBase {
}
};

const items = await Promise.all(
await Promise.all(
columns.map(async (featureName) => {
// This will automatically cache the required values into `this.statistics`.
await this.getStatistics(featureName);
const featureAttributes = await getFeatureAttributes(featureName);

return { featureName, featureAttributes };
attributes[featureName] = { ...featureAttributes, ...attributes[featureName] };
}),
);
items.forEach(({ featureName, featureAttributes }) => {
attributes[featureName] = { ...featureAttributes, ...attributes[featureName] };
});

// Determine additional attributes. The infer methods require basic attributes and statistics to be completed.
const additions = await Promise.all(
await Promise.all(
columns.map(async (featureName) => {
const additions: Partial<FeatureAttributes> = {};

Expand Down Expand Up @@ -120,12 +117,9 @@ export abstract class InferFeatureAttributesBase {
additions.sample = await this.getSample(featureName);
}

return { featureName, additions };
attributes[featureName] = { ...additions, ...attributes[featureName] };
}),
);
additions.forEach(({ featureName, additions }) => {
attributes[featureName] = { ...additions, ...attributes[featureName] };
});

return attributes;
}
Expand Down

0 comments on commit b09498c

Please sign in to comment.