-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Introduce the run GET parameter #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -54,6 +54,11 @@ export let TAB = '__tab__'; | |||
export let DISAMBIGUATOR = 'disambiguator'; | |||
|
|||
/** | |||
* The (string) name for the run of the selected dataset in the graph dashboard. | |||
*/ | |||
export const SELECTED_DATASET = 'selected_dataset'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this just called 'run'
? We call it a run everywhere else in the UI (within this plugin and across other plugins); I don't see the need for new terminology.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little conflict I'm grappling with is that the graph can load many "datasets" (as used in the standalone explorer). Within the graph dashboard, those datasets happen to correspond to runs.
The selected_dataset
(or run
) param is only used by the graph dashboard. If we rename to run
, that piece of the URL would appear when the user navigates to other dashboards as well (but is not actually used and is semantically awkward given how the user can select many runs at once). What do you think is the best way to go there?
@@ -193,6 +199,7 @@ | |||
value: true, // TODO(@chihuahua): Reconcile this setting with Health Pills. | |||
readOnly: true, | |||
}, | |||
_selectedDataset: Number, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't look like it responds to changes in the hash. Other plugins have bidirectional linkage.
Is there a reason that you don't want to use
properties: {
_selectedDatasetName: {
type: String,
notify: true,
value: storage.getStringInitializer('run', /*default=*/'', /*useLocalStorage=*/false),
observer: '_selectedDatasetNameObserver',
},
},
_selectedDatasetNameObserver: storage.getStringObserver(
'run', /*default=*/'', /*useLocalStorage=*/false),
that then has an additional observer on _selectedDatasetName
that looks up the index and sets _selectedDataset
accordingly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. This took some debugging to figure out. The 1st argument to getStringObserver
must also be the name of the polymer module property to sync with:
const newVal = this[propertyName]; |
I might change that in a PR because it caught me a little by surprise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Specifically, I think we can change getStringObserver
's signature to be
getStringObserver(
propertyName: string,
defaultVal: string,
useLocalStorage = false,
polymerModuleProperty?: string): Function
and polymerModuleProperty
would only apply if useLocalStorage
were false.
SELECTED_DATASET, /*useLocalStorage=*/ false); | ||
if (selectedDatasetRun) { | ||
let datasetFound = false; | ||
for (let i = 0; i < datasets.length; i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is all just
const dataset = datasets.findIndex(x => x.name === selectedDatasetRun);
if (dataset === -1) {
// error code
} else {
this.set('_selectedDataset', dataset);
}
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes! Done.
5fb4c97
to
30c4eec
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that the requirement that the store key and the property name be equal is surprising and seriously limiting, and would support a change.
Some API comments for that change:
-
Why should
polymerModuleProperty
only apply whenuseLocalStorage
isfalse
? If we’re writing to local storage, we might just as well want the local storage key to differ from the key on the Polymer object. -
Can we rename
polymerModuleProperty
topolymerProperty
? -
Can we rename
propertyName
tokey
, just to avoid confusion? (I know it’s existing.) -
Note that you will also have to change
getStringInitializer
. -
I presume that you will also change the utility functions for other types.
-
This API is bloating, and positional arguments with default values are not usually the best solution. You might consider changing the function’s signature to the following:
interface Options<T> = { defaultValue?: T; polymerProperty?: string; useLocalStorage?: boolean; } function getStringObserver(key: string, options?: Options<T>) { return getObserver(key, { defaultValue: '', polymerProperty: key, useLocalStorage: false, ...options, }); }
This can be factored into
export const [getStringObserver, getStringInitializer] = makeBindings(getString, setString, ''); export const [getNumberObserver, getNumberInitializer] = makeBindings(getNumber, setNumber, 0); // etc. function makeBindings<T>(get: ..., set: ..., defaultDefaultValue: T) { return [..., ...]; }
Perhaps I can throw up a proof-of-concept and you can see what you think?
@@ -54,6 +54,11 @@ export let TAB = '__tab__'; | |||
export let DISAMBIGUATOR = 'disambiguator'; | |||
|
|||
/** | |||
* The (string) name for the run of the selected dataset in the graph dashboard. | |||
*/ | |||
export const RUN = 'run'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This constant shouldn't be in storage.ts
; there's no reason that the core storage module should need to know about the graph dashboard. Instead, how about const RUN_STORAGE_KEY = 'RUN';
in tf-graph-dashboard.html
? (No need to export anything; it can be local within the <script>
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -193,6 +200,17 @@ | |||
value: true, // TODO(@chihuahua): Reconcile this setting with Health Pills. | |||
readOnly: true, | |||
}, | |||
run: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment here noting the name of this property must coincide with the value of storage.RUN
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can rebase onto #509 (which has been merged) to avoid this complexity.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also checked that correct behavior was preserved (The URL changes when the run changes. The correct run is loaded when run=
is set. A non-existent run triggers the dialog.).
See #509 per discussion above. |
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that they're okay with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
7212a51
to
0a41ec1
Compare
0a41ec1
to
9a9aeb7
Compare
CLAs look good, thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The API comments you noted above SG! I really like how we can now clearly set the polymer property and the string key to use. And passing those options in an object indeed seems better than adding optional function parameters.
@@ -54,6 +54,11 @@ export let TAB = '__tab__'; | |||
export let DISAMBIGUATOR = 'disambiguator'; | |||
|
|||
/** | |||
* The (string) name for the run of the selected dataset in the graph dashboard. | |||
*/ | |||
export const RUN = 'run'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@@ -193,6 +200,17 @@ | |||
value: true, // TODO(@chihuahua): Reconcile this setting with Health Pills. | |||
readOnly: true, | |||
}, | |||
run: { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also checked that correct behavior was preserved (The URL changes when the run changes. The correct run is loaded when run=
is set. A non-existent run triggers the dialog.).
Fantastic. Thanks. |
Introduced a run GET parameter for the graph dashboard. The
value of this parameter is the name of the dataset (run) to load. This
parameter lets users send links to other users of the graph dashboard
that load specific datasets. Fixes #306.
When the user changes the dataset in the graph dashboard UI, the URL
parameter correspondingly changes. I tested this behavior out using the
various runs of the scalars demo. The correct dataset loads given the
selected_dataset parameter, and the URL changes when the dataset is
changed in the UI.
For instance, http://localhost:6006/#graphs&selected_dataset=temperature%3At0%3D270%2CtA%3D270%2CkH%3D0.001 makes the dashboard load the correct dataset.
If no dataset with the specified name can be found, we show a dialog
that notifies the user. This avoids misleading the user.
Set the type of the graph dashboard's
_datasets
property to Array. It hadpreviously been Object (incorrect).