-
Notifications
You must be signed in to change notification settings - Fork 279
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
feat: Substance mutations as data + refactored program generator #601
Conversation
Codecov Report
@@ Coverage Diff @@
## main #601 +/- ##
==========================================
- Coverage 64.90% 63.88% -1.03%
==========================================
Files 40 43 +3
Lines 6734 7074 +340
Branches 1298 1342 +44
==========================================
+ Hits 4371 4519 +148
- Misses 2355 2546 +191
- Partials 8 9 +1
Continue to review full report at Codecov.
|
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.
LGTM! These changes have definitely made the code a lot more modular which is great, and I can see that inserting a new mutation will take only a modest amount of work now. Looking forward to trying it out when I implement the new swap-in mutator! I left some comments--basically all nits--on the PR.
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.
LGTM overall. I was unable to run the new examples on my own machine because of import issues from penrose, but I'm not sure if that's an issue with my machine at the moment or not.
Description
This PR introduces the
Mutation
module, which contains all the Substance mutation types and validation functions. The main improvement is that mutations are no longer executed inline inSynthesizer
anymore. Instead, mutations are encoded as data and can be executed individually (executeMutation
) or in a batch (executeMutations
).Aside from the refactoring, this branch also contains the
Search
module, which are experimental functions for by-example synthesis. This module is currently unused.Implementation strategy and design decisions
Mutation
type: every type of mutation (e.g.Add
,Delete
,ChangeStmtType
etc) has its own attributes enough for executing it. For instance,SwapStmtArgs
has the target statement and the indices to swap. A mutation can also haveadditionalMutations
, which are related mutations.Mutation
types; (2) if you only have a vague target such asSubStmt
(which might be something likeAutoLabel All
and not a valid target for any of the mutations), you can use thecheck*
guard functions to check if a certain kind of mutation is possible for the given target.Synthesizer
class mutates Substance programs by enumeratingAdd
,Delete
, andUpdate
mutations and randomly selecting one of them in each step.generate*
functions: instead of building up a Substance program throughSynthesizer
's internal fields opaquely, these generator functions return one or more Substance statements, which is later converted intoAdd
mutations bySynthesizer
.Examples with steps to reproduce them
TODO
Checklist
yarn test
yarn docs
and there were no errors when generating the HTML siteOpen questions
generate*
functions: theSynthesizerContext
passed into them is still mutated instead of returned. Should we make them completely pure instead?One known problem with the current approach is: these functions mutate the context when generating mutations that might not selected at the end, so you'll see extra ids even if the mutations are never executed :(.Synthesizer
doesn't enumerate all the mutations. Instead, it's still making some random choices such as picking a particular statement to edit.weights
is still not used in the system for picking amongAdd
,Delete
andUpdate
.