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

[BUG] cli parse command output is written to intermediate directory but not copied to output directory #1072

Closed
danwt opened this issue Nov 3, 2021 · 4 comments · Fixed by #1073
Assignees
Labels

Comments

@danwt
Copy link
Contributor

danwt commented Nov 3, 2021

Appears in APALACHE version 0.17.0 build f62f370

Description

The command apalache-mc parse --output=<filename> <tlafile> does not actually write the output to $filename in the output directory. In fact, it actually writes the output to the intermediate directory, which is only visible if passing --write-intermediate.

The command line parameters used to run the tool

apalache-mc parse --output=<filename> <tlafile>

Expected behavior

A file should be created in the output directory.

Log files

System information

  • Apalache version [apalache-mc version]: APALACHE version 0.17.0 build f62f370
  • OS [e.g. Ubuntu Linux or Mac OS, and the current version]: OSX 11.5
  • JDK version [e.g. OpenJDK 0.8.0]: OpenJDK Runtime Environment Zulu16.32+15-CA (build 16.0.2+7)

Additional context

Reproduce with file main.tla

------------------------------------ MODULE main -----------------------------

\* @type: () => Bool;
Init ==
    /\ TRUE

Next == TRUE

===============================================================================
tree 3
.
├── apalache-pkg-0.17.0-full.jar
└── main.tla

java -jar apalache-pkg-0.17.0-full.jar parse --output=foobar.tla main.tla

tree 3
.
├── _apalache-out
│  └── main.tla_2021-11-03T19-20-28_10048578539153344840
│     ├── detailed.log
│     └── run.txt
├── apalache-pkg-0.17.0-full.jar
└── main.tla


java -jar apalache-pkg-0.17.0-full.jar --write-intermediate=true parse --output=foobar.tla main.tla

tree 4

.
├── _apalache-out
│  └── main.tla_2021-11-03T19-22-08_5579138356771785926
│     ├── detailed.log
│     ├── intermediate
│     │  ├── 00_OutParser.json
│     │  ├── 00_OutParser.tla
│     │  └── foobar.tla
│     └── run.txt
├── apalache-pkg-0.17.0-full.jar
└── main.tla
@danwt danwt added the bug label Nov 3, 2021
@danwt danwt changed the title [BUG] --output flag has no effect with parse command when used from the cli. [BUG] cli parse command output is written to intermediate directory but not copied to output directory Nov 3, 2021
@shonfeder shonfeder self-assigned this Nov 3, 2021
@shonfeder
Copy link
Contributor

shonfeder commented Nov 3, 2021

If I'm not mistaken, this is all by design, following #1025.

@shonfeder shonfeder reopened this Nov 3, 2021
@shonfeder
Copy link
Contributor

shonfeder commented Nov 3, 2021

I did not mean to close this, especially not with such a curt message. Sorry!

To elaborate, iiuc:

  • The parse output files are intermediate files.
  • Those are only generated now when --write-intermediate is passed.
  • All intermediate files are now written to the intermediate sub directory.

However, I think the documentation did not get updated to reflect the conditional generation of the output file, and I could see an argument that parse should imply that this intermediate output is meant to be created. However, I'm kind if inclined to the other side of argument. The parse subcommand is useful to check syntactic correctness (this is the main use it is documented as serving), and for specialist usage where one wants to consume the intermediate output, I think it's reasonable to provide a flag.

This is just my preliminary analysis tho, I don't have strong feelings here.

Would be good to get more feedback from @danwt and @Kukovec.

@shonfeder shonfeder removed their assignment Nov 3, 2021
@danwt
Copy link
Contributor Author

danwt commented Nov 3, 2021

* The parse output files are intermediate files.

* Those are only generated now when `--write-intermediate` is passed.

* All intermediate files are now written to the `intermediate` sub directory.

Ah ok so it's true parse is mainly used internally but it is also exposed in the cli as a useful piece of functionality in of itself, so in that usage scenario it should probably be written to the output directory. Especially since the --output argument is given.

@shonfeder
Copy link
Contributor

shonfeder commented Nov 3, 2021

Ah! I'm sorry! I misread! I read output as the new out-dir flag. I don't think this is by design at all, and it does seem like a new bug. Clearly the output flag is meant to specify the output file. My bad!

@shonfeder shonfeder self-assigned this Nov 3, 2021
shonfeder pushed a commit that referenced this issue Nov 4, 2021
* Fix integration tests to check for parse file creation

* Add writer construction utilities to OutputManager

* Restore ability to write parsing to --output file

Additionally:

- Fix output CLI parser to parse an optional value rather than just a
string
- Fix TlaWriterFactory to support writing to given PrintWriters, and not
just locations inside of the output dir

* Log error if intermediate dir can't exist


Co-authored-by: Igor Konnov <igor@informal.systems>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants