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

Support yaml scenarios #275

Merged
merged 28 commits into from
Nov 12, 2019
Merged

Support yaml scenarios #275

merged 28 commits into from
Nov 12, 2019

Conversation

markaren
Copy link
Contributor

@markaren markaren commented Jun 18, 2019

This will be a controversial PR I guess. Uses YAML as the language for defining scenarios.
As you may see, the YAML parser API is almost identical to the JSON API. Furthermore it is backwards compatible.

closes #271

@markaren markaren requested a review from restenb June 19, 2019 06:48
@ljamt
Copy link
Member

ljamt commented Jun 19, 2019

I don't think it's a question about JSON or YAML, but more a question of prioritisation of time. Spending a few hours is of course no problem, but you still need to fix the cse-server-go to not break the demo application.

@markaren
Copy link
Contributor Author

How is cse-server-go related to this (have not looked)? Replacing the current JSON scenarios can be done in seconds. But I'm not saying this should be merged prior to the next release, although it would be beneficial to users.

@markaren
Copy link
Contributor Author

That last commit should probably be "fixed" upstream first. But at least this PR shows how easy it is to switch to YAML. What I really want is a discussion on if this is something we want or not. IMO JSON is not suited for this kind of use.

@restenb
Copy link
Member

restenb commented Jun 19, 2019

How is cse-server-go related to this (have not looked)? Replacing the current JSON scenarios can be done in seconds. But I'm not saying this should be merged prior to the next release, although it would be beneficial to users.

I guess the issue is mainly parsing. Both cse-server-go and cse-client currently assumes JSON as the format, so there's a good chunk of code to rehash if we now change it to YAML. The easiest approach is probably to parse the YAML back into JSON on the server, but that's not very fit for purpose either. That would assume such a parser already exists.

@markaren
Copy link
Contributor Author

markaren commented Jun 19, 2019

I have a hard time understanding why cse-client and cse-server would have to know anything about the scenario language except for the the file ending. But I will have a quick look myself.

@restenb
Copy link
Member

restenb commented Jun 19, 2019

I have a hard time understanding why cse-client and cse-server would have to know anything about the scenario language except for the the file ending. But I will have a quick look myself.

The view code for example goes straight off the incoming JSON data and turns that into a live table of ongoing scenario events. There are some implementation details there that would not be immediately compatible with a different format and therefore have to be rewritten.

It's not particularly difficult to do, it would just take time that could be spent elsewhere right now.

@markaren
Copy link
Contributor Author

markaren commented Jun 19, 2019

Since YAML is a superset of JSON, you can actually feed the original JSON into this parser and it will still work. So users can actually decide if they want to write JSON or YAML. This PR supports both.

But as @restenb points out, it boils down to spending time on the server/client. But we are in no hurry.

Edit 1:
My suggestion would be to keep using JSON in the front-end. In stead of passing the original file, we convert the parsed struct into JSON. The cavecat is that we would need both a JSON and YAML lib in the core.

Edit 2:
Or we expose the necessary information over the C API.

@markaren markaren changed the title Replace json with yaml for scenarios Support yaml scenarios Sep 5, 2019
@markaren
Copy link
Contributor Author

markaren commented Nov 7, 2019

This PR has to receive a YAY or NAY tomorrow or it can just be closed.

Copy link
Member

@kyllingstad kyllingstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!

The only comment I have is that it should be tested with JSON as well as YAML input. If I remember last Friday's meeting correctly, we decided that we'd keep JSON support and continue to use JSON in the client for the time being. Hence, we should also test that it works.

@markaren
Copy link
Contributor Author

That can be fixed!

@markaren
Copy link
Contributor Author

markaren commented Nov 11, 2019

Since I converted scenario_parser_test to a Boost.test module, this will break hard with PR #463

Edit: Well, hard and hard.. managable

@markaren
Copy link
Contributor Author

@hplatou Can you confirm that it is a Jenkins/conan issue for the build failing on Windows w/o FMU-proxy and not something related to the changes in this PR?

Copy link
Member

@kyllingstad kyllingstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! Now all we need to do is figure out why the Jenkins build fails.

@kyllingstad
Copy link
Member

@hplatou Can you confirm that it is a Jenkins/conan issue for the build failing on Windows w/o FMU-proxy and not something related to the changes in this PR?

Wild stab: Could it be because Findyaml-cpp.cmake is not included in the install() command in CMakeLists.txt?

@markaren
Copy link
Contributor Author

What I think is strange is that the build output for the single failed build is full of fmuproxy references, while the build should not include fmuproxy.

@markaren
Copy link
Contributor Author

markaren commented Nov 11, 2019

But it is not clear to me if we should include Findyaml-cpp at all. It should not be necessary, but both me and Kristoffer has experienced cases where this file is not found by CMake (when we do not provide it).

@kyllingstad
Copy link
Member

But it is not clear to me if we should include Findyaml-cpp at all. It should not be necessary, but both me and Kristroffer have experienced cases where this file is not found by CMake (when we do not provide it).

I tried installing the yaml-cpp Conan package on my computer now, and on both Windows and Linux it provides a CMake configuration file (yaml-cpp-config.cmake) in its package directory. Hence, the Findyaml-cpp.cmake script provided in this PR shouldn't really be necessary.

@kyllingstad
Copy link
Member

I've also tried checking out this branch, deleting cmake/Findyaml-cpp.cmake and running a full configure&build. It works fine on Linux, but fails to find the package on Windows, as @markaren also experienced.

Looking at the generated conanbuildinfo.cmake, the reason seems to be that the yaml-cpp package directory for some reason is not added to the CONAN_CMAKE_MODULE_PATH variable, and therefore does not get added to CMAKE_PREFIX_PATH, which again means that find_package() is unable to locate yaml-cpp-config.cmake. I have no idea why, and unfortunately I don't have any more time to look into this right now, but this may be a lead for someone else.

cmake/Findyaml-cpp.cmake Outdated Show resolved Hide resolved
Co-Authored-By: Kristoffer Eide <[email protected]>
@markaren
Copy link
Contributor Author

After googling a little bit, it seems the current issues are related to multiple innstallations of yaml-cpp on the Jenskins server. yaml-cpp 0.6.2 from bincrafters and 0.6.3 from conan-center.

@eidekrist
Copy link
Member

After googling a little bit, it seems the current issues are related to multiple innstallations of yaml-cpp on the Jenskins server. yaml-cpp 0.6.2 from bincrafters and 0.6.3 from conan-center.

I fixed it! 💪

@markaren
Copy link
Contributor Author

After googling a little bit, it seems the current issues are related to multiple innstallations of yaml-cpp on the Jenskins server. yaml-cpp 0.6.2 from bincrafters and 0.6.3 from conan-center.

I fixed it! 💪

Nice!

@markaren markaren merged commit cfcddb3 into master Nov 12, 2019
@markaren
Copy link
Contributor Author

🎂 🍾 🎈

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.

PoC YAML scenario parser
5 participants