Skip to content

Conversation

@bmd3k
Copy link
Contributor

@bmd3k bmd3k commented Aug 2, 2022

When we introduced FeatureFlagMetadata in #5717, we included the`isArray' property, which allowed us to support feature flags that (1) have array type and (2) can be overriden with query parameters. There is only a single feature flag that satisfies this - enabledExperimentalPlugins/experimentalPlugin.

The isArray support adds complexity to the feature flag framework - parsing and encoding logic need special handling for array types in addition to basic types. I wondered if we could eliminate the complexity from the feature flag framework and instead isolate the array-handling to a narrower scope.

The idea: We can simplify the experimentalPlugin query parameter and then simplify FeatureFlagMetadata and the surrounding infrastructure.

We change experimentalPlugin query parameter to be a single comma-delimited value instead of multiple query parameters with single values. That is, we would now write experimentalPlugin=plugin1,plugin2,plugin3 where we previously would have written experimentalPlugin=plugin1&experimentalPlugin=plugin2&experimentalPlugin=plugin3.

Once experimentalPlugin is just a single query parameter there is a path towards removing isArray and simplifying the framework. We remove isArray. enabledExperimentalPlugins specifies a function for parseValue that knows how to convert strings of type 'val1,val2,val3' into a string[]. Fortunately we can rely on string[].toString() to encode the array value back to the query parameter string. The array-specific logic in the greater framework is removed. The complexity is now isolated to the definition of enabledExperimentalPlugins.

@bmd3k bmd3k requested a review from rileyajones August 2, 2022 15:24
Copy link
Contributor

@rileyajones rileyajones left a comment

Choose a reason for hiding this comment

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

This is a good cleanup, thanks. I doubt that the existing featureFlag appears in many links but do you think it could be worth adding some logic someplace (maybe in the datasource) that cleans it up (and ideally alerts the user) if the older style link is used?

// Optional function that translates a feature flag value into a query param
// value. If unspecified then any query param value will be encoded using
// value.toString().
encodeValue?: (value: T) => string;
Copy link
Contributor

Choose a reason for hiding this comment

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

It feels odd that this is required when T is string[] but I'm not sure it's actually worth making the typing more convoluted to enforce that. Could you leave a comment someplace noting it though?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I made a nice discovery while investigating this: string[].toString() does exactly what we want. That is ['val1', 'val2', 'val3'].toString() will output 'val1,val2,val3'. This means we don't even need encodeValue and we can continue to rely on toString() to do all the encoding.

I chatted with Riley offline and we agreed that would be the right way forward.

@bmd3k
Copy link
Contributor Author

bmd3k commented Aug 2, 2022

This is a good cleanup, thanks. I doubt that the existing featureFlag appears in many links but do you think it could be worth adding some logic someplace (maybe in the datasource) that cleans it up (and ideally alerts the user) if the older style link is used?

No, it's not worth it. This flag is practically unused for over a year.

I did check internal documentation. There is an example that uses the param but it only specifies a single value so no need to update it!

defaultValue: [],
queryParamOverride: 'experimentalPlugin',
parseValue: parseStringArray,
encodeValue: encodeStringArray,
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

@bmd3k bmd3k merged commit 1648ec1 into tensorflow:master Aug 3, 2022
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
…the feature flag infrastructure. (tensorflow#5836)

When we introduced `FeatureFlagMetadata` in tensorflow#5717, we included the`isArray' property, which allowed us to support feature flags that (1) have array type and (2) can be overriden with query parameters. There is only a single feature flag that satisfies this - enabledExperimentalPlugins/experimentalPlugin.

The isArray support adds complexity to the feature flag framework - parsing and encoding logic need special handling for array types in addition to basic types. I wondered if we could eliminate the complexity from the feature flag framework and instead isolate the array-handling to a narrower scope.

The idea: We can simplify the `experimentalPlugin` query parameter and then simplify FeatureFlagMetadata and the surrounding infrastructure.

We  change experimentalPlugin query parameter to be a single comma-delimited value instead of multiple query parameters with single values. That is, we would now write `experimentalPlugin=plugin1,plugin2,plugin3` where we previously would have written `experimentalPlugin=plugin1&experimentalPlugin=plugin2&experimentalPlugin=plugin3`.

Once experimentalPlugin is just a single query parameter there is a path towards removing `isArray` and simplifying the framework. We remove `isArray`.  enabledExperimentalPlugins specifies a function for parseValue that knows how to convert strings of type 'val1,val2,val3' into a string[]. And, fortunately, we can rely on string[].toString() to encode the array value back to the query parameter string. The array-specific logic in the greater framework is removed. The complexity is now isolated to the definition of enabledExperimentalPlugins.
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
…the feature flag infrastructure. (tensorflow#5836)

When we introduced `FeatureFlagMetadata` in tensorflow#5717, we included the`isArray' property, which allowed us to support feature flags that (1) have array type and (2) can be overriden with query parameters. There is only a single feature flag that satisfies this - enabledExperimentalPlugins/experimentalPlugin.

The isArray support adds complexity to the feature flag framework - parsing and encoding logic need special handling for array types in addition to basic types. I wondered if we could eliminate the complexity from the feature flag framework and instead isolate the array-handling to a narrower scope.

The idea: We can simplify the `experimentalPlugin` query parameter and then simplify FeatureFlagMetadata and the surrounding infrastructure.

We  change experimentalPlugin query parameter to be a single comma-delimited value instead of multiple query parameters with single values. That is, we would now write `experimentalPlugin=plugin1,plugin2,plugin3` where we previously would have written `experimentalPlugin=plugin1&experimentalPlugin=plugin2&experimentalPlugin=plugin3`.

Once experimentalPlugin is just a single query parameter there is a path towards removing `isArray` and simplifying the framework. We remove `isArray`.  enabledExperimentalPlugins specifies a function for parseValue that knows how to convert strings of type 'val1,val2,val3' into a string[]. And, fortunately, we can rely on string[].toString() to encode the array value back to the query parameter string. The array-specific logic in the greater framework is removed. The complexity is now isolated to the definition of enabledExperimentalPlugins.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants