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

[DO NOT MERGE] Illustrate example quality improvement #3134

Draft
wants to merge 1 commit into
base: mikhailshilkov/all-examples-pre
Choose a base branch
from

Conversation

mikhailshilkov
Copy link
Member

No description provided.

mikhailshilkov added a commit that referenced this pull request Mar 11, 2024
### Problem

Program generation (`x.GenerateProgram` functions for each language)
have side effects since they change the `program` object passed to them
in-place. Currently, we pass the same `program` object through the
entire pipleline of example generation for all languages. This means,
that all languages except nodejs (which is the first in the list) is
affected by previous languages in subtle ways.

Mostly, this seems to break schema type information in
hard-to-understand ways. See the list of issues and a diff link below
for examples.

### Change

This PR moves the invocation of `hcl2.BindProgram` inside the language
loop, which prevents us from sharing the `program`. This should
eliminate the cross-language effects.

Entirely unexpectedly to me, this leads to a substantial performance
_gain_ not penalty: the schema generation time reduced from 110s to 13s
on my laptop!

The second code change you see here is extending the ability to write
examples to disk from HCL-only to any language. (see below)

### Validation

I logged all examples in all languages before and after the change, and
pushed them to [this
PR](#3134). This way
it's easier to validate the results.

700+ python, 200+ go, and a number of csharp examples are pure
improvements with better type instantiations. The only seeming
regression are C# changes from `new[] {}` to `new() {}` where the old
option looks correct. I guess that's something that worked by luck then?

### Issues Fixed

Fix #2608
Fix #2575
Fix #2084
Fix #2083
Fix #2275
Fix #2047
Fix #1479
Fix #2827 (the example it shows is fixed)
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

1 participant