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

Automated fix for refs/heads/bad-decrypt-fix #55

Open
wants to merge 1 commit into
base: bad-decrypt-fix
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Package.swift

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 34 additions & 18 deletions tools/codegen/core/experiments_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,9 @@ def IsValid(self, check_expiry=False):
print("expiry should be no more than two quarters from now")
return not self._error

def AddRolloutSpecification(self, allowed_defaults,
allowed_platforms, rollout_attributes):
def AddRolloutSpecification(
self, allowed_defaults, allowed_platforms, rollout_attributes
):
if self._error:
return False
if rollout_attributes["name"] != self._name:
Expand Down Expand Up @@ -281,8 +282,12 @@ def additional_constraints(self, platform):

class ExperimentsCompiler(object):
def __init__(
self, defaults, final_return, final_define, platforms_define,
bzl_list_for_defaults=None
self,
defaults,
final_return,
final_define,
platforms_define,
bzl_list_for_defaults=None,
):
self._defaults = defaults
self._final_return = final_return
Expand Down Expand Up @@ -318,8 +323,9 @@ def AddRolloutSpecification(self, rollout_attributes):
)
return self._experiment_definitions[
rollout_attributes["name"]
].AddRolloutSpecification(self._defaults, self._platforms_define,
rollout_attributes)
].AddRolloutSpecification(
self._defaults, self._platforms_define, rollout_attributes
)

def _GenerateExperimentsHdrForPlatform(self, platform, file_desc):
for _, exp in self._experiment_definitions.items():
Expand Down Expand Up @@ -372,8 +378,11 @@ def GenerateExperimentsHdr(self, output_file, mode):
for platform in sorted(self._platforms_define.keys()):
if platform == "posix":
continue
print(f"\n#{'if' if idx ==0 else 'elif'} "
f"defined({self._platforms_define[platform]})", file=H)
print(
f"\n#{'if' if idx ==0 else 'elif'} "
f"defined({self._platforms_define[platform]})",
file=H,
)
self._GenerateExperimentsHdrForPlatform(platform, H)
idx += 1
print("\n#else", file=H)
Expand Down Expand Up @@ -442,12 +451,12 @@ def _GenerateExperimentsSrcForPlatform(self, platform, mode, file_desc):
if "kDefaultForDebugOnly" in have_defaults:
print("#ifdef NDEBUG", file=file_desc)
if "kDefaultForDebugOnly" in have_defaults:
print("const bool kDefaultForDebugOnly = false;",
file=file_desc)
print(
"const bool kDefaultForDebugOnly = false;", file=file_desc
)
print("#else", file=file_desc)
if "kDefaultForDebugOnly" in have_defaults:
print("const bool kDefaultForDebugOnly = true;",
file=file_desc)
print("const bool kDefaultForDebugOnly = true;", file=file_desc)
print("#endif", file=file_desc)
print("}", file=file_desc)
print(file=file_desc)
Expand All @@ -459,7 +468,7 @@ def _GenerateExperimentsSrcForPlatform(self, platform, mode, file_desc):
experiments_metadata_var_name = "g_experiment_metadata"
print(
f"const ExperimentMetadata {experiments_metadata_var_name}[] = {{",
file=file_desc
file=file_desc,
)
for _, exp in self._experiment_definitions.items():
print(
Expand Down Expand Up @@ -494,8 +503,11 @@ def GenerateExperimentsSrc(self, output_file, header_file_path, mode):
for platform in sorted(self._platforms_define.keys()):
if platform == "posix":
continue
print(f"\n#{'if' if idx ==0 else 'elif'} "
f"defined({self._platforms_define[platform]})", file=C)
print(
f"\n#{'if' if idx ==0 else 'elif'} "
f"defined({self._platforms_define[platform]})",
file=C,
)
self._GenerateExperimentsSrcForPlatform(platform, mode, C)
idx += 1
print("\n#else", file=C)
Expand All @@ -507,7 +519,9 @@ def _GenTestExperimentsExpectedValues(self, platform):
defs = ""
for _, exp in self._experiment_definitions.items():
defs += _EXPERIMENTS_EXPECTED_VALUE(
SnakeToPascal(exp.name), self._final_return[exp.default(platform)])
SnakeToPascal(exp.name),
self._final_return[exp.default(platform)],
)
return defs

def GenTest(self, output_file):
Expand All @@ -524,8 +538,10 @@ def GenTest(self, output_file):
for platform in sorted(self._platforms_define.keys()):
if platform == "posix":
continue
defs += (f"\n#{'if' if idx ==0 else 'elif'} "
f"defined({self._platforms_define[platform]})")
defs += (
f"\n#{'if' if idx ==0 else 'elif'} "
f"defined({self._platforms_define[platform]})"
)
defs += self._GenTestExperimentsExpectedValues(platform)
idx += 1
defs += "\n#else"
Expand Down
7 changes: 5 additions & 2 deletions tools/codegen/core/gen_experiments.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,11 @@ def _GenerateExperimentFiles(args, mode):
rollouts = yaml.safe_load(f.read())

compiler = exp.ExperimentsCompiler(
DEFAULTS, FINAL_RETURN, FINAL_DEFINE, PLATFORMS_DEFINE,
BZL_LIST_FOR_DEFAULTS
DEFAULTS,
FINAL_RETURN,
FINAL_DEFINE,
PLATFORMS_DEFINE,
BZL_LIST_FOR_DEFAULTS,
)

experiment_annotation = "gRPC Experiments: "
Expand Down