Skip to content

Add PresetService (User Presets Step 3) - #1164

Merged
zuozhiw merged 40 commits into
masterfrom
Albert-PresetService
Jan 14, 2022
Merged

zuozhiw merged 40 commits into
masterfrom
Albert-PresetService

Conversation

@MysteriousChallenger

@MysteriousChallenger MysteriousChallenger commented Jun 12, 2021 •

Copy link
Copy Markdown
Contributor

Final feature demo:

Kapture 2022-01-13 at 23 36 00


This PR is extracted from #1041 as step 2 of the User Preset feature.

rebase of picked commits pertaining to PresetServiceService onto Albert-UserDictionaryService

PresetService provides the ability to save and "apply" collections of settings (represented by objects) that a user might find convenient to save and apply as a group. These groups are called Presets.

PresetService uses DictionaryService to store presets (it creates kind of a view in the database sense, of the user dictionary, that only includes Presets)

Changes from last review (for Yicong)

  • Code comments
  • fixed subscription memory leak by using takeUntil(observable), where said observable completes on NgOndestroy
  • DictionaryService now attempts to init whenever client logs in (sorry, you'll have to re-review my changes to DictionaryService)
  • PresetService now has public ready promise/value member
    • This indicates that its init isn't complete until DictionaryService's init is complete (which is async, and cant be awaited in the constructor)
  • DeletePreset now built into PresetService (don't know why I ever didn't have that)
  • Revert Changes to Styles.scss to fix Karma test runner interface (I originally changed them as a workaround for an ng-zorro component that's no longer used)

Note: for this step, I had less time and more complex code to test. I'm not sure I caught all the bugs, but it passes unit tests.
The quality of the code in this pr is lesser, in my opinion, so You'll have to be a little more careful on my behalf.

adds user_dictionary database table and JOOQ generated DAOs and POJOs
user_dictionary stores uid+key -> json-value pairs, storing arbitrary json data for each user
fixed sql formatting, capitalized error messages, fixed edge case of missing json properties in requests
turns out XHR doesn't allow get requests to have a body, despite generating content-type/length headers and it being allowed in the inspector.
the dictionary service provides the frontend with observable event streams and w/r functions for the user dictionary resource.

It also provides userDictionary objects that are proxies to the user dictionary resource:
- get operations yield values from the user dictionary resource,
- set operations post values to the user dictionary resource
refactored to use new backend api. Get/Set/Delete operations now return Observables instead of Promises.
the @autofill annotation causes the annotated property to be marked as autofillable when serialized into a json schema.

In addition to each @autofill property having a "type" property in the json schema, they will also have an "autofill" property which is always set to true.
If the property is not annotated with @autofill, it will not have the property "autofill" at all
dropdowns show presets for applicable operators in the operator property editor
refactored preset service to depend on workflowActionService instead of the other way around. This fixes tests because workflowActionService no longer needs ngMessageModule to display message whenever a preset is applied.
refactor preset service for new dictionary service api,
dictionary service auto-init, preset service added functions, Subscription leak fix
],
client:{
clearContext: false // leave Jasmine Spec Runner output visible in browser
clearContext: false, // leave Jasmine Spec Runner output visible in browser

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Included by mistake, Fix pending

@Yicong-Huang Yicong-Huang mentioned this pull request Jun 26, 2021
2 of 3 tasks
@MysteriousChallenger

MysteriousChallenger commented Nov 19, 2021 •

Copy link
Copy Markdown
Contributor Author
  1. The basic functionality is working again.
  2. All the visible UI changes are now a part of the preset wrapper component (Custom wrapper around form fields)
  3. UserDictionary is now refactored to UserConfig wherever referenced.

Opinions welcome @zuozhiw

image

Todo

  • write tests
  • disable save button or show why a preset failed to save?

MysteriousChallenger and others added 7 commits December 3, 2021 04:29
Give error message when user attempts to save a preset
while some preset fields aren't filled in
just checking if my changes break unit tests of other components
…utocomplete, use createPreset in favor of updateOrCreatePreset

@zuozhiw zuozhiw left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MysteriousChallenger Thanks a lot for making the changes. This feature now looks very good. I have tried it on my own and liked it a lot.

I have reviewed the code and made some minor changes. This PR now looks good and I approve it.

Before we merge this PR, we need to get @Yicong-Huang invovled. This is because we renamed a SQL table (user_dictionary -> user_config in this PR), @Yicong-Huang needs to be aware of this DDL change.

@Xiao-zhen-Liu

Copy link
Copy Markdown
Contributor

Discussion 1/11: Zuozhi will find a time with Yicong to merge it and change the production server database by the end of week

@zuozhiw
zuozhiw merged commit c3af446 into master Jan 14, 2022
@zuozhiw
zuozhiw deleted the Albert-PresetService branch January 14, 2022 07:44
zuozhiw added a commit that referenced this pull request Jan 21, 2022
In #1164 we accidentally deleted code related to displaying workflow version. This PR adds back the logic. (fixes issue #1406)

I have tested the fix and both workflow versions and the user presets functionailities work well. 
![Kapture 2022-01-19 at 17 26 45](https://user-images.githubusercontent.com/12578068/150245616-418956af-cf42-4144-84bd-c09f9843c3fe.gif)
@zuozhiw zuozhiw added the ddl-change Changes to the TexeraDB DDL label Jul 21, 2022
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
Final feature demo:

![Kapture 2022-01-13 at 23 36 00](https://user-images.githubusercontent.com/12578068/149469927-b62bfa43-4701-4498-a489-565aea36da2c.gif)

---------------------------

This PR is extracted from apache#1041 as step 2 of the User Preset feature.

rebase of picked commits pertaining to PresetServiceService onto Albert-UserDictionaryService

PresetService provides the ability to save and "apply" collections of settings (represented by objects) that a user might find convenient to save and apply as a group. These groups are called Presets.

PresetService uses DictionaryService to store presets (it creates kind of a *view* in the database sense, of the user dictionary, that only includes Presets)

Changes from last review (for Yicong)
 - Code comments
 - fixed subscription memory leak by using takeUntil(observable), where said observable completes on NgOndestroy
 - DictionaryService now attempts to init whenever client logs in (sorry, you'll have to re-review my changes to DictionaryService)
 - PresetService now has public ready promise/value member 
   - This indicates that its init isn't complete until DictionaryService's init is complete (which is async, and cant be awaited in the constructor)
 - DeletePreset now built into PresetService (don't know why I ever didn't have that)
 - Revert Changes to Styles.scss to fix Karma test runner interface (I originally changed them as a workaround for an ng-zorro component that's no longer used)

 Note: for this step, I had less time and more complex code to test. I'm not sure I caught all the bugs, but it passes unit tests.
The quality of the code in this pr is lesser, in my opinion, so You'll have to be a little more careful on my behalf.



Co-authored-by: Zuozhi Wang <[email protected]>
Co-authored-by: Yicong Huang <[email protected]>
yangzhang75 pushed a commit to yangzhang75/texera that referenced this pull request Jun 22, 2026
In apache#1164 we accidentally deleted code related to displaying workflow version. This PR adds back the logic. (fixes issue apache#1406)

I have tested the fix and both workflow versions and the user presets functionailities work well. 
![Kapture 2022-01-19 at 17 26 45](https://user-images.githubusercontent.com/12578068/150245616-418956af-cf42-4144-84bd-c09f9843c3fe.gif)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Sep 24, 2026
### What changes were proposed in this PR?

Removes three `PresetService` members that no production code calls:
`updateOrCreatePreset`, `isValidNewOperatorPreset`, and the exported
`PresetDictionary` type. Pure deletion, no behaviour change: **−175
lines**.

### History

| | |
| --- | --- |
| **Introduced by** | apache#1164 (2022-01-13) — "Add PresetService (User
Presets Step 3)", which built out the preset API surface |
| **Usage removed by** | **never wired up** — no production file has
ever called `updateOrCreatePreset` or `isValidNewOperatorPreset`, and
`PresetDictionary` has zero references worktree-wide. Only the service's
own spec exercises them |

> Reviewer note: the wired-up half of the service stays — `savePresets`,
`getPresets`, `applyPreset`, `isValidOperatorPreset`, `isValidPreset`
and the Ajv type guards all keep live consumers.
`common/formly/preset-wrapper/**` calls none of the removed three
(checked line by line in both the `.ts` and the `.html`). Note
`isValidOperatorPreset` (live) and `isValidNewOperatorPreset` (removed)
differ by one word — only the latter goes.

### Any related issues, documentation, discussions?

Closes apache#8611

### How was this PR tested?

Existing tests only — this PR removes methods and the spec blocks that
covered them.

From `frontend/`:

- `npx ng test --watch=false --include='**/preset.service.spec.ts'` — 48
tests pass.
- `yarn --cwd frontend format:ci` — clean.

Verification, re-runnable by a reviewer:

```
git grep -n "updateOrCreatePreset\|isValidNewOperatorPreset\|PresetDictionary"
git grep -n isValidOperatorPreset    # the live sibling, untouched
```

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5)

🤖 Generated with [Claude Code](https://claude.com/claude-code)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 10, 2026
### What changes were proposed in this PR?
Remove the preset wrapper's write-only base state, unused typing
subscription, unreachable search branch, constant menu flag with its
`nzVisible` binding, and unused template index. Opening and save events
still refresh the preset list, which is now a `readonly Preset[]`
holding the arrays the service emits rather than copies of them;
apply/save/delete behavior is preserved. A field without
`parent.fieldGroup` is still rejected at initialization, now by the
guard with a message, before the preset fetch subscribes, instead of by
a `TypeError` from a discarded `filterPresetFromForm()` call. **+18/−196
lines.**

The menu flag has never been enabled by production code, and the base
state has no live reader. Both were introduced in
[apache#1164](apache#1164) on January 13, 2022.

### Any related issues, documentation, discussions?
Closes apache#9379.

### How was this PR tested?
From `frontend/`:
```
node .yarn/releases/yarn-4.14.1.cjs format:ci
node node_modules/typescript/bin/tsc --noEmit -p src/tsconfig.app.json
node node_modules/typescript/bin/tsc --noEmit -p src/tsconfig.spec.json
node .yarn/releases/yarn-4.14.1.cjs build:ci
node node_modules/@angular/cli/bin/ng.js test --watch=false --include=src/app/common/formly/preset-wrapper/preset-wrapper.component.spec.ts --include=src/app/workspace/service/preset/preset.service.spec.ts --include=src/app/workspace/component/property-editor/operator-property-edit-frame/operator-property-edit-frame.component.spec.ts
```
350 passed; one existing skipped case. Removing the `parent.fieldGroup`
check from the guard fails only its initialization test.

### Was this PR authored or co-authored using generative AI tooling?
Generated-by: Codex (GPT-6), Claude Code (Claude Opus 5.5)
renovate-bot pushed a commit to renovate-bot/apache-_-texera that referenced this pull request Nov 26, 2026
### What changes were proposed in this PR?

Remove code that nothing uses, or that repeats work already done, across
16 files in the frontend, Amber, the shared config and observability
modules, and the sbt license helper (**+22/−152 lines**). There is no
behavior change.

- **`PresetService`:** `getOperatorPreset`,
`filterOperatorPresetProperties` and the private `ajvStrip` validator
they share have no caller outside their own spec. Their two spec blocks
go with them.
- **`UserConfigService`:** `set` and `delete` return their request
observables, and no caller reads them; `PresetService`, the only caller,
discards both. They now return `void`, so the `shareReplay` carriers and
the `of` import go. Each call still sends its request once and updates
the local dictionary when the request succeeds.
- **Resource registry:** `ResourceDescriptor.setCover` and its dataset
and model implementations have no caller outside the registry's own
spec. The dataset and model pages set a cover through
`DatasetService.updateDatasetCoverImage` and
`ModelService.updateModelCoverImage` directly. The spec drops its
`setCover` call, the matching assertion and the `updateModelCoverImage`
stub, and the workflow descriptor's comment stops naming the hook.
- **`StorageConfig`:** 12 JDBC, Iceberg and S3 name constants that
nothing reads. Every reader, such as `ComputingUnitManagingResource`,
uses the same names from `EnvironmentalVariable`. The four cleanup and
warehouse constants stay, because `StorageConfigSpec` reads them.
- **Telemetry:** `WorkflowMetricsRecorder.init` calls
`WorkflowMetrics.ensureBound()` right after
`setActiveExecutionsSupplier`, which already calls it.
`OtelInit.initialized` only ever holds an `OpenTelemetrySdk`, so it is
now typed that way, and `resetForTest` loses a fallback arm that could
not run.
- **`CollaborationResource`:** the `heartbeat`, `tryLock`, `acquireLock`
and `restoreVersion` patterns bind names that their bodies never read,
so each becomes `_`.
- **Result table:** nothing reads the `#statsRow` template reference.
- **`search-results.component.spec.ts`:** the card-template host imports
`NgTemplateOutlet`, which its template never uses.
- **`TexeraWebApplication`:** drops a commented-out call to
`discardUncommittedChangesOfAllDatasets` and its TODO. That method no
longer exists.
- **`AddMetaInfLicenseFiles`:** drops `import
com.typesafe.sbt.packager.universal.UniversalPlugin.autoImport._`, which
nothing in the helper uses.

| Event | PR / Commit |
| --- | --- |
| Introduced by | `PresetService`: apache#1164 (2022-01-14);
`UserConfigService`: apache#1162 (2021-06-27); resource registry: apache#8299
(2026-08-31); `StorageConfig`: apache#3337 (2025-04-06); telemetry: apache#5375
(2026-10-25) and apache#5376 (2026-10-27); `CollaborationResource`: apache#1427
(2022-02-15); result table: apache#2931 (2024-10-14); search results spec:
apache#6565 (2026-07-20); `TexeraWebApplication`: apache#2391 (2024-02-20),
commented out by apache#2733 (2024-07-15); `AddMetaInfLicenseFiles`: apache#4367
(2026-04-17) |
| Usage removed by | `TexeraWebApplication`: apache#3314 (2025-03-12) deleted
`discardUncommittedChangesOfAllDatasets`. `AddMetaInfLicenseFiles`:
apache#4449 (2026-04-29) removed the last `Universal` reference. Everything
else: unused since introduction. |

As of 2026-11-25:
- No caller has read the `UserConfigService` return values in the more
than 5 years since they were added.
- The two `PresetService` helpers have had no caller outside their spec
for almost 5 years, and the `CollaborationResource` bindings have been
unused for as long.
- The `#statsRow` reference has been unread for over 2 years.
- The commented call has pointed at a deleted method, and the
`StorageConfig` constants have been unread, for over a year and a half
each.
- The Universal import has been unused for almost 7 months.
- The `setCover` hook has had no caller in the almost 3 months it has
existed, and the telemetry duplicates have done nothing in the month
since they were added.

### Any related issues, documentation, discussions?

Closes apache#9695.

### How was this PR tested?

Ran on this branch and on `main` at `d1a0c5e673` (Windows 11; Node 24
with Yarn 4.14.1; JDK 17):

```bash
cd frontend
npx ng test --watch=false --include='**/preset.service.spec.ts' --include='**/user-config.service.spec.ts' --include='**/preset-wrapper.component.spec.ts' --include='**/result-table-frame.component.spec.ts' --include='**/search-results.component.spec.ts' --include='**/resource-registry.service.spec.ts'
npx tsc --noEmit -p src/tsconfig.app.json
npx tsc --noEmit -p src/tsconfig.spec.json
yarn prettier-eslint --list-different $(git diff --name-only --relative origin/main -- src)
yarn eslint $(git diff --name-only --relative origin/main -- src)
cd ..
sbt Config/test Observability/test "WorkflowExecutionService/testOnly org.apache.texera.web.resource.CollaborationResourceSpec org.apache.texera.web.observability.WorkflowMetricsRecorderSpec"
sbt Config/scalafmtCheckAll Observability/scalafmtCheckAll WorkflowExecutionService/scalafmtCheckAll "Config/scalafixAll --check" "Observability/scalafixAll --check" "WorkflowExecutionService/scalafixAll --check"
```

- **Frontend:** the six specs run 199 tests on this branch and 206 on
`main`, all passing. The 7 extra on `main` are the deleted helpers' own
spec cases; every other test keeps its name and outcome. Both
typechecks, prettier-eslint and ESLint pass.
- **Scala:** the `Config` and `Observability` suites and the two Amber
specs run 212 tests, all passing on both sides with the same names and
outcomes. scalafmt and scalafix pass for all three projects.
- Every sbt run compiles the build definition, so
`AddMetaInfLicenseFiles.scala` compiled with and without the import.

To re-check, both commands return no hits on this branch:

```bash
git grep -nwE "getOperatorPreset|filterOperatorPresetProperties|ajvStrip|setCover" -- frontend/src
git grep -nE "ENV_(JDBC|ICEBERG|S3)_" -- common/config/src/main/scala/org/apache/texera/common/config/StorageConfig.scala
```

### Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Claude Opus 5.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ddl-change Changes to the TexeraDB DDL feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants