bobbai00 commented on code in PR #3772:
URL: https://github.com/apache/texera/pull/3772#discussion_r2400182968
##########
core/gui/src/app/workspace/service/workflow-result-export/workflow-result-export.service.ts:
##########
@@ -26,30 +26,39 @@ import { PaginatedResultEvent, ResultExportResponse } from
"../../types/workflow
import { NotificationService } from
"../../../common/service/notification/notification.service";
import { ExecuteWorkflowService } from
"../execute-workflow/execute-workflow.service";
import { ExecutionState, isNotInExecution } from
"../../types/execute-workflow.interface";
-import { filter } from "rxjs/operators";
+import { catchError, filter, map, take, tap } from "rxjs/operators";
import { OperatorResultService, WorkflowResultService } from
"../workflow-result/workflow-result.service";
import { DownloadService } from
"../../../dashboard/service/user/download/download.service";
import { HttpResponse } from "@angular/common/http";
import { ExportWorkflowJsonResponse } from
"../../../dashboard/service/user/download/download.service";
import { DashboardWorkflowComputingUnit } from
"../../types/workflow-computing-unit";
import { GuiConfigService } from "../../../common/service/gui-config.service";
+import { DatasetService } from
"../../../dashboard/service/user/dataset/dataset.service";
+import { parseFilePathToDatasetFile } from "../../../common/type/dataset-file";
@Injectable({
providedIn: "root",
})
export class WorkflowResultExportService {
hasResultToExportOnHighlightedOperators: boolean = false;
hasResultToExportOnAllOperators = new BehaviorSubject<boolean>(false);
+ private datasetDownloadableMap = new Map<string, boolean>();
+ private datasetLabelMap = new Map<string, string>();
+ private restrictedOperatorMap = new Map<string, Set<string>>();
+ private datasetListLoaded = false;
Review Comment:
If you can make the request triggered only when user open the export modal,
these caches are not needed. In general we should reduce the status caching.
##########
core/gui/src/app/workspace/service/workflow-result-export/workflow-result-export.service.ts:
##########
@@ -60,36 +69,283 @@ export class WorkflowResultExportService {
this.workflowActionService.getJointGraphWrapper().getJointOperatorHighlightStream(),
this.workflowActionService.getJointGraphWrapper().getJointOperatorUnhighlightStream()
).subscribe(() => {
- // check if there are any results to export on highlighted operators
(either paginated or snapshot)
- this.hasResultToExportOnHighlightedOperators =
-
isNotInExecution(this.executeWorkflowService.getExecutionState().state) &&
- this.workflowActionService
- .getJointGraphWrapper()
- .getCurrentHighlightedOperatorIDs()
- .filter(
- operatorId =>
- this.workflowResultService.hasAnyResult(operatorId) ||
-
this.workflowResultService.getResultService(operatorId)?.getCurrentResultSnapshot()
!== undefined
- ).length > 0;
-
- // check if there are any results to export on all operators (either
paginated or snapshot)
- let staticHasResultToExportOnAllOperators =
-
isNotInExecution(this.executeWorkflowService.getExecutionState().state) &&
- this.workflowActionService
- .getTexeraGraph()
- .getAllOperators()
- .map(operator => operator.operatorID)
- .filter(
- operatorId =>
- this.workflowResultService.hasAnyResult(operatorId) ||
-
this.workflowResultService.getResultService(operatorId)?.getCurrentResultSnapshot()
!== undefined
- ).length > 0;
-
- // Notify subscribers of changes
-
this.hasResultToExportOnAllOperators.next(staticHasResultToExportOnAllOperators);
+ this.updateExportAvailabilityFlags();
+ });
+ }
+
+ /**
+ * Registers triggers to recompute dataset restrictions when the workflow
graph changes.
+ * Monitors operator/link additions, deletions, property changes, and
operator enable/disable events.
+ */
+ private registerRestrictionRecomputeTriggers(): void {
Review Comment:
This request is triggered too frequent. Is there anyway to trigger it only
when user click the export button and open the export modal?
##########
core/gui/src/app/workspace/service/workflow-result-export/workflow-result-export.service.ts:
##########
@@ -26,30 +26,39 @@ import { PaginatedResultEvent, ResultExportResponse } from
"../../types/workflow
import { NotificationService } from
"../../../common/service/notification/notification.service";
import { ExecuteWorkflowService } from
"../execute-workflow/execute-workflow.service";
import { ExecutionState, isNotInExecution } from
"../../types/execute-workflow.interface";
-import { filter } from "rxjs/operators";
+import { catchError, filter, map, take, tap } from "rxjs/operators";
import { OperatorResultService, WorkflowResultService } from
"../workflow-result/workflow-result.service";
import { DownloadService } from
"../../../dashboard/service/user/download/download.service";
import { HttpResponse } from "@angular/common/http";
import { ExportWorkflowJsonResponse } from
"../../../dashboard/service/user/download/download.service";
import { DashboardWorkflowComputingUnit } from
"../../types/workflow-computing-unit";
import { GuiConfigService } from "../../../common/service/gui-config.service";
+import { DatasetService } from
"../../../dashboard/service/user/dataset/dataset.service";
+import { parseFilePathToDatasetFile } from "../../../common/type/dataset-file";
@Injectable({
providedIn: "root",
})
export class WorkflowResultExportService {
Review Comment:
This service is suppose to be a stateless, singleton service. The below
changes bring lots of state to this service, please consider refactoring them
##########
core/gui/src/app/workspace/service/workflow-result-export/workflow-result-export.service.ts:
##########
@@ -106,6 +362,47 @@ export class WorkflowResultExportService {
destination: "dataset" | "local" = "dataset", // default to dataset
unit: DashboardWorkflowComputingUnit | null // computing unit for cluster
setting
): void {
+ this.refreshDatasetMetadata()
Review Comment:
This is the place where all `blocking` computation should happen I believe.
And to compute it, you don't need to cache the state at the class level.
--
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]