kunwp1 commented on code in PR #5901:
URL: https://github.com/apache/texera/pull/5901#discussion_r3484907647
##########
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.ts:
##########
@@ -755,23 +764,115 @@ export class ComputingUnitSelectionComponent implements
OnInit {
}
}
- addEnvironment(): void {
+ showPVEmodalVisible(): void {
+ this.pveModalVisible = true;
+ this.getPVEs();
+ this.refreshAvailableDbPves();
+ }
+
+ isSavedPveInstalledInCu(name: string): boolean {
+ const trimmed = name.trim();
+ return this.pves.some(p => p.isLocked && p.name.trim() === trimmed);
+ }
+
+ private refreshAvailableDbPves(): void {
+ this.workflowPveService
+ .listUserPves()
+ .pipe(untilDestroyed(this))
+ .subscribe({
+ next: records => {
+ this.availableDbPves = records;
+ },
+ error: (err: unknown) => {
+ console.error("Failed to fetch saved Python environments", err);
+ this.availableDbPves = [];
+ },
+ });
+ }
+
+ // Triggered when the user picks a saved PVE in the picker. Builds a new
+ // env card from its name + packages and starts CU install flow
+ // (createVirtualEnvironment), so pip output streams into the same panel.
+ installFromSavedPve(veid: number): void {
+ const saved = this.availableDbPves.find(p => p.veid === veid);
+ if (!saved) return;
+
+ const trimmedName = saved.name.trim();
+ const dbRows = this.parseDbPackages(saved.packages);
+
+ const existingIndex = this.pves.findIndex(p => p.isLocked && p.name.trim()
=== trimmedName);
+ if (existingIndex !== -1) {
+ this.applySavedPveAsUpdate(existingIndex, saved.name, dbRows);
+ return;
+ }
+
this.pves.push({
- name: "",
+ name: saved.name,
userPackages: [],
- newPackages: [],
+ newPackages: dbRows,
deletingPackages: [],
pipOutput: "",
prettyPipOutput: "",
expanded: true,
isInstalling: false,
isLocked: false,
});
+
+ const newIndex = this.pves.length - 1;
+
+ setTimeout(() => this.createVirtualEnvironment(newIndex), 0);
}
- showPVEmodalVisible(): void {
- this.pveModalVisible = true;
- this.getPVEs();
+ private parseDbPackages(packages: Record<string, string> | null |
undefined): PveUserPackageRow[] {
+ return Object.entries(packages ?? {}).map(([name, raw]) => {
+ const match = raw?.match?.(/^(==|>=|<=)(.*)$/);
+ return {
+ name,
+ versionOp: (match ? match[1] : "==") as "==" | ">=" | "<=",
+ version: match ? match[2] : raw ?? "",
+ };
+ });
+ }
+
+ // Computes the diff between the saved DB record and the locked card's
+ // current user packages, then triggers the existing update path
+ private applySavedPveAsUpdate(index: number, displayName: string, dbRows:
PveUserPackageRow[]): void {
+ const existing = this.pves[index];
+
+ const dbByName = new Map(dbRows.map(p => [p.name.trim().toLowerCase(),
p]));
+ const existingByName = new Map(existing.userPackages.map(p =>
[p.name.trim().toLowerCase(), p]));
+
+ const toInstall: PveUserPackageRow[] = [];
+ const toDelete: { name: string; version: string }[] = [];
+
+ dbByName.forEach((db, key) => {
+ const cur = existingByName.get(key);
+ if (!cur) {
+ toInstall.push({ name: db.name, versionOp: db.versionOp, version:
db.version });
+ } else if ((cur.version ?? "").trim() !== (db.version ?? "").trim()) {
+ toDelete.push({ name: cur.name, version: (cur.version ?? "").trim() });
+ toInstall.push({ name: db.name, versionOp: db.versionOp, version:
db.version });
+ }
Review Comment:
I don't understand this part. Is changing a constraint from `==1.26.0` to
`>=1.26.0` (same number, different operator) treated as no change and not
reinstalled? What's the logic behind this decision?
##########
frontend/src/app/workspace/component/power-button/computing-unit-selection.component.spec.ts:
##########
Review Comment:
Please use a different venv name that follows your new validation check.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]