-
-
Notifications
You must be signed in to change notification settings - Fork 40
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
Add smt-encoding option to CLI check command #1054
Conversation
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.
Looks good, tho I have a few suggestions.
tla-bmcmt/src/main/scala/at/forsyte/apalache/tla/bmcmt/passes/BoundedCheckerPassImpl.scala
Show resolved
Hide resolved
@@ -85,6 +88,7 @@ class BoundedCheckerPassImpl @Inject() (val options: PassOptions, hintsStore: Fo | |||
params.discardDisabled = options.getOrElse("checker", "discardDisabled", true) | |||
params.checkForDeadlocks = !options.getOrElse("checker", "noDeadlocks", false) | |||
params.nMaxErrors = options.getOrElse("checker", "maxError", 1) | |||
params.smtEncoding = options.getOrElse("checker", "smt-encoding", "oopsla19") |
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.
As discussed elsewhere, what about also adding a fallback to an SMT_ENCODING
environment variable, that could let users set this for all runs in a given shell environment? (This also makes it easy to run all the integration tests with one flag or the other). I think that could be achieved just by getting the appropriate env var in the case that this is None
?
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.
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.
Ah that is a good question. I could see an argument either way.
If #1036 ends up including a more general configuration system, I think we'll need to rework this to accommodate either way. My gut feeling is that it would be worth adding the envvar fallback here just for testing purposes, and then that can be reworked for the configuration system later if needed. I think the envvar fallback can be accommodated here with:
params.smtEncoding = options.get("checker", "smt-encoding").orElse(sys.env.get("SMT_ENCODING")).getOrElse("oopsla19")
And in the documentation (perhaps also in the inline CLI docs?) we might note that the envvar is a fall back, but that the CLI flag takes precedence?
What do you think. Seem simple enough do integrate regardless of #1306, or do you think it'd better to wait?
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.
You can do both, but you have to define a sensible priority, which I assume would be (in order of lowest to highest):
- Apalache default
- ENV
- CONFIG
- CLI parameter
Changing OutputManager
might be a bit annoying, because this is a non-bool flag. I'd wait for #1048 (to add config file support, env can be done now), when config flags all go through PassOptions
and the manager doesn't track flags anymore.
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.
Also,
params.smtEncoding = options.getOrElse("checker", "smt-encoding", "oopsla19") | |
params.smtEncoding = options.getOrElse("checker", "smt-encoding", oopsla19Encoding) |
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.
@shonfeder I think we can add this now, but I have two questions:
-
In my Linux distro the
SMT_ENCODING
env var is not being used. I assume this is the same for other OSs. Is there a way to be sure? -
Your suggestion to update
params.smtEncoding
does not seem to work because the default forsmtEncoding
inCheckCmd
cannot beNone
. The code below works with""
as default, but is not very nice.
var smtEncodingCLI: Option[String] = options.get("checker", "smt-encoding")
smtEncodingCLI = if (smtEncodingCLI.get.equals("")) None else smtEncodingCLI
params.smtEncoding = smtEncodingCLI.orElse(sys.env.get("SMT_ENCODING")).getOrElse("oopsla19")
I tried using Option.filter to inline this, but it didn't work. Any suggestions?
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.
@Kukovec I think the priority order makes sense. Will leave CONFIG out for now, as suggested.
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.
I can have a look at the code later to see where you're getting hung up. I guess the getOrElse
method on options must not have the signature I expected (given the signature from Option for the method of the same name)? You solution there seems ok, tho could probably be streamlines with some mapping?
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.
By mapping you mean key-value pairs or something else? Not sure how the former can help here.
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.
Sorry, mapping was probably not a helpful word there. But I mean using map on an option type. Not terribly relevant tho.
Your suggestion to update params.smtEncoding does not seem to work because the default for smtEncoding in CheckCmd cannot be None.
I don't follow actually. iiuc, the code snippet I gave should not return None
as a default. It should default to the given string if all previous values in the chain are None
. Trying to compile it now seems to work OK. I'll make a PR into your branch by way of illustrating.
One other thought: now that we have a CLI arg, would it make sense to add one or more integration tests here that exercise it? |
There is nothing to test yet, so I'm not sure. I assume that after enabling the env var, no refactoring will be needed in the integration tests, unlike it was done in #1051 for the unit tests. My idea is to use the same tests for both encodings,since they should produce the same results. I plan to gradually enable parts of the test suite for the new encoding as development progresses. |
Co-authored-by: Shon Feder <shon@informal.systems>
Ok! That makes sense to me :) |
hmmm I don't know why CI is not running for this PR> |
Conflict on |
Could be! |
…encoding-option Suggestion for CLI option processing
/** | ||
* The SMT encoding to be used. | ||
*/ | ||
var smtEncoding: String = "" | ||
|
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.
I'd like to briefly review the way this value gets used to convince myself that an empty string make sense here. Otherwise, LGTM!
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.
Ok, I understand.
We use the ModelCheckerParams
essentially as a struct of parameter values that our various checker's consult to determine their behaviors. For some reason, some of these paramters are passed in via arguments to the constructor, and some are set via mutable assignment. This does not seem ideal to me, but @rodrigo7491 is just following the existing example.
Setting this value to an empty string as a default does not seem ideal to me, however, I have followup work planned that will transform these kind of flag into an enum (see #1056), and this will naturally be cleaned up as part of that work.
Tests added for any new codemake fmt-fix
(or had formatting run automatically on all files edited)See title. Closes #1053.