[MDS] Install Vega sample data#6218
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6218 +/- ##
=======================================
Coverage 67.46% 67.46%
=======================================
Files 3368 3368
Lines 65422 65431 +9
Branches 10557 10560 +3
=======================================
+ Hits 44134 44145 +11
+ Misses 18717 18714 -3
- Partials 2571 2572 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
| ): string => { | ||
| const { spec } = props; | ||
| const { spec, spacing } = props; | ||
| const stringifiedSpacing = !!spacing ? spacing : 2; |
There was a problem hiding this comment.
a shorter way to write this const stringifiedSpacing = spacing || 2;
| import { SavedObject, updateDataSourceNameInVegaSpec } from '../../../../../../core/server'; | ||
|
|
||
| describe('getSavedObjectsWithDataSource()', () => { | ||
| const getVisualizationSavedObjects = (): Array<SavedObject<any>> => { |
There was a problem hiding this comment.
nonblocking: you can move this large json object to a data.json file and then load it with one line
import data from './data.json'
| - [Discover] Options button to configure legacy mode and remove the top navigation option ([#6170](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6170)) | ||
| - [Multiple Datasource] Add default functionality for customer to choose default datasource ([#6058](https://github.com/opensearch-project/OpenSearch-Dashboards/issues/6058)) | ||
| - [Multiple Datasource] Add import support for Vega when specifying a datasource ([#6123](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6123)) | ||
| - [Workspace] Validate if workspace exists when setup inside a workspace ([#6154](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6154)) |
There was a problem hiding this comment.
@huyaboo would you rebase from main, so others change won't showup in your PR
There was a problem hiding this comment.
The CHANGELOG.md change was because my commit adds a new line at the end of the file
f006109 to
94fcc10
Compare
CHANGELOG.md
Outdated
| ### 🔩 Tests | ||
|
|
||
| - Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322)) No newline at end of file | ||
| - Update caniuse to fix failed integration tests ([#2322](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/2322)) |
There was a problem hiding this comment.
I believe it was a newline added to the end of my CHANGELOG.md
There was a problem hiding this comment.
@huyaboo let's rebase with main. Other contributor's change should not show in your PR.
| ): string => { | ||
| const { spec } = props; | ||
| const { spec, spacing } = props; | ||
| const stringifiedSpacing = spacing || 2; |
There was a problem hiding this comment.
So the type of spacing is number, why is it called stringifiedSpacing? Also, why it is || 2 but not other number? what if spacing is 0?
There was a problem hiding this comment.
stringifiedSpacing is how much indenting should occur when an HJSON document is stringified. It's set to 2 as that seems to be the default for most Vega visualizations. If it were 0 there would be no indenting between the lines so it would look something like this:
{
data: {
url: {
index: some_index
body: {
...
}
}
}
...
}
There was a problem hiding this comment.
Can we add those explanation as comments?
| const updatedVegaSpec = updateDataSourceNameInVegaSpec({ | ||
| spec: vegaSpec, | ||
| newDataSourceName: dataSourceTitle, | ||
| spacing: 1, |
There was a problem hiding this comment.
why do we hard code spacing as 1 and what does it do?
There was a problem hiding this comment.
The reason spacing is 1 is because there is one sample data visualization (sankey visualization) that would cause a URL too long error. This setting limits the spacing so the visualization will still be rendered/accessed.
There was a problem hiding this comment.
Can we add those explanation as comments?
|
LGTM, thanks |
CHANGELOG.md
Outdated
| - [Multiple Datasource] Make sure customer always have a default datasource ([#6237](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6237)) | ||
| - [Workspace] Add workspace list page ([#6182](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6182)) | ||
|
|
||
| - [Multiple Datasource] Append `data_source_name` to the Vega spec and add datasource reference when installing sample data ([#6218](https://github.com/opensearch-project/OpenSearch-Dashboards/pull/6218)) |
There was a problem hiding this comment.
nit: can we add simpler text instead of adding details so that it would be easy to understand by anyone? maybe [Multiple Datasource] Add multi data source support to sample vega visualizations
| import { SavedObject, SavedObjectsClientContract } from '../types'; | ||
|
|
||
| /** | ||
| * Given a Vega spec, the new datasource (by name), and spacing, |
There was a problem hiding this comment.
It's not clear from this line, what exactly this function is doing.
|
Can you update with rebase before merge? |
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
bca768d to
c000459
Compare
Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
|
The backport to To backport manually, run these commands in your terminal: # Navigate to the root of your repository
cd $(git rev-parse --show-toplevel)
# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add ../.worktrees/OpenSearch-Dashboards/backport-2.x 2.x
# Navigate to the new working tree
pushd ../.worktrees/OpenSearch-Dashboards/backport-2.x
# Create a new branch
git switch --create backport/backport-6218-to-2.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 8810f085164243532bf8d87f3952c30172ff8d22
# Push it to GitHub
git push --set-upstream origin backport/backport-6218-to-2.x
# Go back to the original working tree
popd
# Delete the working tree
git worktree remove ../.worktrees/OpenSearch-Dashboards/backport-2.xThen, create a pull request where the |
* Add data_source_name to sample data install Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add unit test coverage Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Resolve CHANGELOG.md conflicts Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor logic Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Remove newline Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Remove newline Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add comments for spacing Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Update jsdoc Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> --------- Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> (cherry picked from commit 8810f08)
* Add data_source_name to sample data install Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add unit test coverage Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Resolve CHANGELOG.md conflicts Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Refactor logic Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Remove newline Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Remove newline Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Add comments for spacing Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> * Update jsdoc Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> --------- Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com> (cherry picked from commit 8810f08) Signed-off-by: Huy Nguyen <73027756+huyaboo@users.noreply.github.com>
Description
With #6123 and #5975 , MDS now fully supports Vega and importing. This PR will fix Vega visualizations when installing sample data. Specifically, the
data_source_namefield will be appended to eachurlbody of the Vega spec and the datasource reference added to the saved object metadata.Issues Resolved
Closes #5927
Screenshot
Screen.Recording.2024-03-19.at.4.47.35.PM.mov
Testing the changes
Data Source Sampledata_source_name: Data Source Samplewas added to eachurlbody of the Vega spec and the datasource reference is included in the saved object metadata.Check List
yarn test:jestyarn test:jest_integration