Skip to content
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

Implement Experiments feature #4994

Merged
merged 19 commits into from Sep 29, 2022
Merged

Implement Experiments feature #4994

merged 19 commits into from Sep 29, 2022

Conversation

inlined
Copy link
Member

@inlined inlined commented Sep 19, 2022

This is a WIP. I still need to add the experiments command (which, ironically, until API council approves will be hidden behind a preview/experiment).

TODO: Add experiments:enable/disable/list/describe/clear commands (follow-up PR?)
TODO: Get representatives of each experiment to provide a shortDescription, verify if any should be public, and verify any assertEnabled calls.

@inlined inlined changed the title Add official experiments support WIP: Migrate to experiments library Sep 19, 2022
@@ -281,7 +281,7 @@ export async function resolveBackend(
nonInteractive?: boolean
): Promise<{ backend: backend.Backend; envs: Record<string, params.ParamValue> }> {
let paramValues: Record<string, params.ParamValue> = {};
if (previews.functionsparams) {
if (experiments.isEnabled("functionsparams")) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@Berlioz Does this still need to be hidden behind an experiment or do we think we are stable enough to roll forward? (If not, can we leave a comment on when this should be rolled forward?)

@@ -272,7 +272,7 @@ export async function prepare(
* This must be called after `await validate.secretsAreValid`.
*/
updateEndpointTargetedStatus(wantBackends, context.filters || []);
if (previews.skipdeployingnoopfunctions) {
if (experiments.isEnabled("skipdeployingnoopfunctions")) {
Copy link
Member Author

Choose a reason for hiding this comment

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

@TheIronDev When does this experiment go away?

src/deploy/index.ts Show resolved Hide resolved
src/experiments.ts Outdated Show resolved Hide resolved
src/experiments.ts Outdated Show resolved Hide resolved
src/experiments.ts Outdated Show resolved Hide resolved
src/experiments.ts Outdated Show resolved Hide resolved
src/experiments.ts Outdated Show resolved Hide resolved
@inlined
Copy link
Member Author

inlined commented Sep 19, 2022

A note to all people tagged for review on your experiment. If your experiment is going to have external users, you should add a log whenever executing experimental codepaths that mentions "experimental" in bold. E.g. "Deploying functions with experimental support for Python" or "Deploying hosting with experimental support for web frameworks"

@inlined inlined changed the title WIP: Migrate to experiments library Implement Experiments feature Sep 22, 2022
@codecov-commenter
Copy link

codecov-commenter commented Sep 23, 2022

Codecov Report

Base: 55.88% // Head: 55.89% // Increases project coverage by +0.00% 🎉

Coverage data is based on head (b0dfaa8) compared to base (20d3d7c).
Patch coverage: 47.69% of modified lines in pull request are covered.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4994   +/-   ##
=======================================
  Coverage   55.88%   55.89%           
=======================================
  Files         305      305           
  Lines       20325    20351   +26     
  Branches     4094     4100    +6     
=======================================
+ Hits        11359    11375   +16     
- Misses       8011     8021   +10     
  Partials      955      955           
Impacted Files Coverage Δ
src/init/features/functions/index.ts 82.66% <ø> (+1.89%) ⬆️
src/emulator/controller.ts 13.07% <10.00%> (-0.08%) ⬇️
src/utils.ts 66.19% <11.11%> (ø)
src/deploy/index.ts 29.57% <33.33%> (-0.43%) ⬇️
src/deploy/functions/build.ts 56.28% <50.00%> (ø)
src/deploy/functions/prepare.ts 30.05% <50.00%> (ø)
src/experiments.ts 58.06% <58.06%> (ø)
src/deploy/functions/release/planner.ts 87.40% <100.00%> (+0.28%) ⬆️
src/deploy/functions/runtimes/index.ts 54.16% <100.00%> (-1.84%) ⬇️
src/emulator/downloadableEmulators.ts 23.30% <100.00%> (ø)
... and 1 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@inlined
Copy link
Member Author

inlined commented Sep 27, 2022

ping?

src/commands/experiments-clear.ts Outdated Show resolved Hide resolved
logger.error(`Did you mean ${potentials[0]}?`);
} else if (potentials.length) {
logger.error(
`Did you mean ${potentials.slice(0, -1).join(",")} or ${potentials[potentials.length - 1]}?`
Copy link
Contributor

Choose a reason for hiding this comment

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

optionally:

Suggested change
`Did you mean ${potentials.slice(0, -1).join(",")} or ${potentials[potentials.length - 1]}?`
`Did you mean ${potentials.slice(0, -1).join(",")} or ${utils.last(potentials)}?`

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, but I also changed the signature of last to never return undefined since that only happened when someone passed a non-array which should never happen due to the signature of the method.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm an idiot and last can return undefined if the array is non-empty. Will fix

src/commands/experiments-describe.ts Outdated Show resolved Hide resolved
src/commands/experiments-clear.ts Outdated Show resolved Hide resolved
src/commands/experiments-disable.ts Outdated Show resolved Hide resolved
src/commands/index.ts Outdated Show resolved Hide resolved
src/deploy/index.ts Show resolved Hide resolved
src/experiments.ts Show resolved Hide resolved
src/experiments.ts Show resolved Hide resolved
src/handlePreviewToggles.ts Show resolved Hide resolved
@bkendall bkendall self-assigned this Sep 27, 2022
experiments.setEnabled(experiment, null);
experiments.flushToDisk();
logger.info(`Cleared preferences for experiment ${bold(experiment)}`);
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this throw instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually, Michael asked us to remove this feature for now.

} else if (potentials.length) {
logger.error(`Did you mean ${potentials.slice(0, -1).join(",")} or ${last(potentials)}?`);
}
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this throw instead?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

}
table.push(["n", name, exp.shortDescription]);
}
logger.info(table.toString());
Copy link
Contributor

Choose a reason for hiding this comment

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

One detail that can be punted on until later: for --json (machine readable) output, we could export the table as a JSON-ish object (just return an object in this method). Would that be easy enough to do?

Copy link
Member Author

Choose a reason for hiding this comment

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

I couldn't get this to work. You'll have to teach me how --json works with the commands library

@inlined inlined enabled auto-merge (squash) September 28, 2022 23:34
@inlined inlined merged commit c3ec450 into master Sep 29, 2022
@inlined inlined deleted the inlined.experiments branch September 29, 2022 18:30
christhompsongoogle pushed a commit that referenced this pull request Sep 30, 2022
Add experiments to the Firebase CLI.  New commands:

```
firebase experiments:enable <experiment>
firebase experiments:disable <experiment>
firebase experiments:describe <experiment>
firebase experiments:list
```
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.

None yet

4 participants